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 version 2.27
10
12 use Log::Dispatch;
13
14 my $log = Log::Dispatch->new(
15 outputs => [
16 [
17 'File',
18 min_level => 'info',
19 filename => 'Somefile.log',
20 mode => '>>',
21 newline => 1
22 ]
23 ],
24 );
25
26 $log->emerg("I've fallen and I can't get up");
27
29 This module provides a simple object for logging to files under the
30 Log::Dispatch::* system.
31
32 Note that a newline will not be added automatically at the end of a
33 message by default. To do that, pass "newline => 1".
34
36 The constructor takes the following parameters in addition to the
37 standard parameters documented in Log::Dispatch::Output:
38
39 · filename ($)
40
41 The filename to be opened for writing.
42
43 · mode ($)
44
45 The mode the file should be opened with. Valid options are
46 'write', '>', 'append', '>>', or the relevant constants from Fcntl.
47 The default is 'write'.
48
49 · binmode ($)
50
51 A layer name to be passed to binmode, like ":utf8" or ":raw".
52
53 · close_after_write ($)
54
55 Whether or not the file should be closed after each write. This
56 defaults to false.
57
58 If this is true, then the mode will aways be append, so that the
59 file is not re-written for each new message.
60
61 · autoflush ($)
62
63 Whether or not the file should be autoflushed. This defaults to
64 true.
65
66 · permissions ($)
67
68 If the file does not already exist, the permissions that it should
69 be created with. Optional. The argument passed must be a valid
70 octal value, such as 0600 or the constants available from Fcntl,
71 like S_IRUSR|S_IWUSR.
72
73 See "chmod" in perlfunc for more on potential traps when passing
74 octal values around. Most importantly, remember that if you pass a
75 string that looks like an octal value, like this:
76
77 my $mode = '0644';
78
79 Then the resulting file will end up with permissions like this:
80
81 --w----r-T
82
83 which is probably not what you want.
84
86 Dave Rolsky <autarch@urth.org>
87
89 This software is Copyright (c) 2010 by Dave Rolsky.
90
91 This is free software, licensed under:
92
93 The Artistic License 2.0
94
95
96
97perl v5.12.2 2010-10-16 Log::Dispatch::File(3)