1Log::Dispatch::File(3)User Contributed Perl DocumentationLog::Dispatch::File(3)
2
3
4
6 Log::Dispatch::File - Object for logging to files
7
9 use Log::Dispatch::File;
10
11 my $file = Log::Dispatch::File->new( name => 'file1',
12 min_level => 'info',
13 filename => 'Somefile.log',
14 mode => 'append' );
15
16 $file->log( level => 'emerg', message => "I've fallen and I can't get up\n" );
17
19 This module provides a simple object for logging to files under the
20 Log::Dispatch::* system.
21
23 * new(%p)
24 This method takes a hash of parameters. The following options are
25 valid:
26
27 * name ($)
28 The name of the object (not the filename!). Required.
29
30 * min_level ($)
31 The minimum logging level this object will accept. See the
32 Log::Dispatch documentation on Log Levels for more informa‐
33 tion. Required.
34
35 * max_level ($)
36 The maximum logging level this obejct will accept. See the
37 Log::Dispatch documentation on Log Levels for more informa‐
38 tion. This is not required. By default the maximum is the
39 highest possible level (which means functionally that the
40 object has no maximum).
41
42 * filename ($)
43 The filename to be opened for writing.
44
45 * mode ($)
46 The mode the file should be opened with. Valid options are
47 'write', '>', 'append', '>>', or the relevant constants
48 from Fcntl. The default is 'write'.
49
50 * close_after_write ($)
51 Whether or not the file should be closed after each write.
52 This defaults to false.
53
54 If this is true, then the mode will aways be append, so
55 that the file is not re-written for each new message.
56
57 * autoflush ($)
58 Whether or not the file should be autoflushed. This
59 defaults to true.
60
61 * permissions ($)
62 If the file does not already exist, the permissions that it
63 should be created with. Optional. The argument passed
64 must be a valid octal value, such as 0600 or the constants
65 available from Fcntl, like S_IRUSR⎪S_IWUSR.
66
67 See "chmod" in perlfunc for more on potential traps when
68 passing octal values around. Most importantly, remember
69 that if you pass a string that looks like an octal value,
70 like this:
71
72 my $mode = '0644';
73
74 Then the resulting file will end up with permissions like
75 this:
76
77 --w----r-T
78
79 which is probably not what you want.
80
81 * callbacks( \& or [ \&, \&, ... ] )
82 This parameter may be a single subroutine reference or an
83 array reference of subroutine references. These callbacks
84 will be called in the order they are given and passed a
85 hash containing the following keys:
86
87 ( message => $log_message, level => $log_level )
88
89 The callbacks are expected to modify the message and then
90 return a single scalar containing that modified message.
91 These callbacks will be called when either the "log" or
92 "log_to" methods are called and will only be applied to a
93 given message once.
94
95 * log_message( message => $ )
96 Sends a message to the appropriate output. Generally this
97 shouldn't be called directly but should be called through the
98 "log()" method (in Log::Dispatch::Output).
99
101 Dave Rolsky, <autarch@urth.org>
102
103
104
105perl v5.8.8 2006-12-20 Log::Dispatch::File(3)