1Log::Dispatch::File(3)User Contributed Perl DocumentationLog::Dispatch::File(3)
2
3
4

NAME

6       Log::Dispatch::File - Object for logging to files
7

VERSION

9       version 2.68
10

SYNOPSIS

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

DESCRIPTION

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
35       NOTE: If you are writing to a single log file from multiple processes,
36       the log output may become interleaved and garbled. Use the
37       Log::Dispatch::File::Locked output instead, which allows multiple
38       processes to safely share a single file.
39

CONSTRUCTOR

41       The constructor takes the following parameters in addition to the
42       standard parameters documented in Log::Dispatch::Output:
43
44       ·   filename ($)
45
46           The filename to be opened for writing.
47
48       ·   mode ($)
49
50           The mode the file should be opened with. Valid options are 'write',
51           '>', 'append', '>>', or the relevant constants from Fcntl. The
52           default is 'write'.
53
54       ·   binmode ($)
55
56           A layer name to be passed to binmode, like ":encoding(UTF-8)" or
57           ":raw".
58
59       ·   close_after_write ($)
60
61           Whether or not the file should be closed after each write. This
62           defaults to false.
63
64           If this is true, then the mode will always be append, so that the
65           file is not re-written for each new message.
66
67       ·   lazy_open ($)
68
69           Whether or not the file should be opened only on first write. This
70           defaults to false.
71
72       ·   autoflush ($)
73
74           Whether or not the file should be autoflushed. This defaults to
75           true.
76
77       ·   syswrite ($)
78
79           Whether or not to perform the write using "syswrite" in perlfunc(),
80           as opposed to "print" in perlfunc(). This defaults to false.  The
81           usual caveats and warnings as documented in "syswrite" in perlfunc
82           apply.
83
84       ·   permissions ($)
85
86           If the file does not already exist, the permissions that it should
87           be created with. Optional. The argument passed must be a valid
88           octal value, such as 0600 or the constants available from Fcntl,
89           like S_IRUSR|S_IWUSR.
90
91           See "chmod" in perlfunc for more on potential traps when passing
92           octal values around. Most importantly, remember that if you pass a
93           string that looks like an octal value, like this:
94
95            my $mode = '0644';
96
97           Then the resulting file will end up with permissions like this:
98
99            --w----r-T
100
101           which is probably not what you want.
102

SUPPORT

104       Bugs may be submitted at
105       <https://github.com/houseabsolute/Log-Dispatch/issues>.
106
107       I am also usually active on IRC as 'autarch' on "irc://irc.perl.org".
108

SOURCE

110       The source code repository for Log-Dispatch can be found at
111       <https://github.com/houseabsolute/Log-Dispatch>.
112

AUTHOR

114       Dave Rolsky <autarch@urth.org>
115
117       This software is Copyright (c) 2018 by Dave Rolsky.
118
119       This is free software, licensed under:
120
121         The Artistic License 2.0 (GPL Compatible)
122
123       The full text of the license can be found in the LICENSE file included
124       with this distribution.
125
126
127
128perl v5.28.0                      2018-08-22            Log::Dispatch::File(3)
Impressum