Log::Di...ch::File(3)
okay bestie, welcome to the manual page Log::Di...ch::File(3) β that's the manual name, and it's chillin' under User Contributed Perl Documentation. we're talking about Log::Dispatch::File here, version 2.71, and it's giving βlet me write your logs to a fileβ energy. no cap.
π NAME π
Log::Dispatch::File β Object for logging to files
β¨ VERSION β¨
version 2.71
πΈ SYNOPSIS πΈ
use Log::Dispatch;
my $log = Log::Dispatch->new(
outputs => [
[
'File',
min_level => 'info',
filename => 'Somefile.log',
mode => '>>',
newline => 1
]
],
);
$log->emerg("I've fallen and I can't get up");
π¦ DESCRIPTION π¦
This module gives you a simple object for logging to files under the Log::Dispatch::* system. literally its whole job, and it ate.
Heads up: by default, a newline will not be added automatically at the end of a message. if you want that little line break, pass newline => 1. periodt.
NOTE: if you're writing to a single log file from multiple processes, the log output may become interleaved and garbled. that's the messy group-chat-with-no-thread-discipline vibe. use the Log::Dispatch::File::Locked output instead, which allows multiple processes to safely share a single file. slay.
π CONSTRUCTOR π
The constructor takes the following parameters in addition to the standard parameters documented in Log::Dispatch::Output:
filename ($)β the filename to be opened for writing. that's the main character, obviously.mode ($)β the mode the file should be opened with. valid options are'write','>','append','>>', or the relevant constants from Fcntl. the default is'write'. iconic little default.binmode ($)β a layer name to be passed tobinmode, like":encoding(UTF-8)"or":raw". very layer, very demure.close_after_write ($)β whether or not the file should be closed after each write. this defaults tofalse.
if this is true, then the mode will always be append, so that the file is not re-written for each new message. important detail, bestie.
lazy_open ($)β whether or not the file should be opened only on first write. this defaults tofalse. lowkey patient of it.autoflush ($)β whether or not the file should be autoflushed. this defaults totrue.syswrite ($)β whether or not to perform the write usingsyswriteinperlfunc(), as opposed toprintinperlfunc(). this defaults tofalse. the usual caveats and warnings as documented insyswriteinperlfuncapply. don't say i didn't warn you.permissions ($)β if the file does not already exist, the permissions that it should be created with. optional. the argument passed must be a valid octal value, such as0600or the constants available from Fcntl, likeS_IRUSR|S_IWUSR.
see chmod in perlfunc for more on potential traps when passing octal values around. most importantly, remember that if you pass a string that looks like an octal value, like this:
my $mode = '0644';
then the resulting file will end up with permissions like this:
--w----r-T
which is probably not what you want. seriously, bestie, that permission set is cursed π
π«Ά SUPPORT π«Ά
Bugs may be submitted at https://github.com/houseabsolute/Log-Dispatch/issues. go off, report responsibly π
π SOURCE π
The source code repository for Log-Dispatch can be found at https://github.com/houseabsolute/Log-Dispatch. iykyk.
π AUTHOR π
Dave Rolsky <autarch@urth.org>
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2023 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
The full text of the license can be found in the LICENSE file included with this distribution.
bye bestie π this page came from perl v5.42.0, dated 2023-04-21, and yes the manual name is still Log::Di...ch::File(3). go forth and log responsibly, mwah π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Log-Dispatch 2.71-bp160.1.2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms