Coder Social home page Coder Social logo

log-dispatch's Introduction

NAME

Log::Dispatch - Dispatches messages to one or more outputs

VERSION

version 2.71

SYNOPSIS

use Log::Dispatch;

# Simple API
#
my $log = Log::Dispatch->new(
    outputs => [
        [ 'File',   min_level => 'debug', filename => 'logfile' ],
        [ 'Screen', min_level => 'warning' ],
    ],
);

$log->info('Blah, blah');

# More verbose API
#
my $log = Log::Dispatch->new();
$log->add(
    Log::Dispatch::File->new(
        name      => 'file1',
        min_level => 'debug',
        filename  => 'logfile'
    )
);
$log->add(
    Log::Dispatch::Screen->new(
        name      => 'screen',
        min_level => 'warning',
    )
);

$log->log( level => 'info', message => 'Blah, blah' );

my $sub = sub { my %p = @_; return reverse $p{message}; };
my $reversing_dispatcher = Log::Dispatch->new( callbacks => $sub );

DESCRIPTION

This module manages a set of Log::Dispatch::* output objects that can be logged to via a unified interface.

The idea is that you create a Log::Dispatch object and then add various logging objects to it (such as a file logger or screen logger). Then you call the log method of the dispatch object, which passes the message to each of the objects, which in turn decide whether or not to accept the message and what to do with it.

This makes it possible to call single method and send a message to a log file, via email, to the screen, and anywhere else, all with very little code needed on your part, once the dispatching object has been created.

METHODS

This class provides the following methods:

Log::Dispatch->new(...)

This method takes the following parameters:

  • outputs( [ [ class, params, ... ], [ class, params, ... ], ... ] )

    This parameter is a reference to a list of lists. Each inner list consists of a class name and a set of constructor params. The class is automatically prefixed with 'Log::Dispatch::' unless it begins with '+', in which case the string following '+' is taken to be a full classname. e.g.

      outputs => [ [ 'File',          min_level => 'debug', filename => 'logfile' ],
                   [ '+My::Dispatch', min_level => 'info' ] ]
    

    For each inner list, a new output object is created and added to the dispatcher (via the add() method).

    See "OUTPUT CLASSES" for the parameters that can be used when creating an output object.

  • callbacks( \& or [ \&, \&, ... ] )

    This parameter may be a single subroutine reference or an array reference of subroutine references. These callbacks will be called in the order they are given and passed a hash containing the following keys:

      ( message => $log_message, level => $log_level )
    

    In addition, any key/value pairs passed to a logging method will be passed onto your callback.

    The callbacks are expected to modify the message and then return a single scalar containing that modified message. These callbacks will be called when either the log or log_to methods are called and will only be applied to a given message once. If they do not return the message then you will get no output. Make sure to return the message!

$dispatch->clone()

This returns a shallow clone of the original object. The underlying output objects and callbacks are shared between the two objects. However any changes made to the outputs or callbacks that the object contains are not shared.

$dispatch->log( level => $, message => $ or \& )

Sends the message (at the appropriate level) to all the output objects that the dispatcher contains (by calling the log_to method repeatedly).

The level can be specified by name or by an integer from 0 (debug) to 7 (emergency).

This method also accepts a subroutine reference as the message argument. This reference will be called only if there is an output that will accept a message of the specified level.

$dispatch->debug (message), info (message), ...

You may call any valid log level (including valid abbreviations) as a method with a single argument that is the message to be logged. This is converted into a call to the log method with the appropriate level.

For example:

$log->alert('Strange data in incoming request');

translates to:

$log->log( level => 'alert', message => 'Strange data in incoming request' );

If you pass an array to these methods, it will be stringified as is:

my @array = ('Something', 'bad', 'is', 'here');
$log->alert(@array);

# is equivalent to

$log->alert("@array");

You can also pass a subroutine reference, just like passing one to the log() method.

$dispatch->log_and_die( level => $, message => $ or \& )

Has the same behavior as calling log() but calls _die_with_message() at the end.

You can throw exception objects by subclassing this method.

If the carp_level parameter is present its value will be added to the current value of $Carp::CarpLevel.

$dispatch->log_and_croak( level => $, message => $ or \& )

A synonym for $dispatch-log_and_die()>.

$dispatch->log_to( name => $, level => $, message => $ )

Sends the message only to the named object. Note: this will not properly handle a subroutine reference as the message.

$dispatch->add_callback( $code )

Adds a callback (like those given during construction). It is added to the end of the list of callbacks. Note that this can also be called on individual output objects.

$dispatch->remove_callback( $code )

Remove the given callback from the list of callbacks. Note that this can also be called on individual output objects.

$dispatch->callbacks()

Returns a list of the callbacks in a given output.

$dispatch->level_is_valid( $string )

Returns true or false to indicate whether or not the given string is a valid log level. Can be called as either a class or object method.

$dispatch->would_log( $string )

Given a log level, returns true or false to indicate whether or not anything would be logged for that log level.

$dispatch->is_$level

There are methods for every log level: is_debug(), is_warning(), etc.

This returns true if the logger will log a message at the given level.

$dispatch->add( Log::Dispatch::* OBJECT )

Adds a new output object to the dispatcher. If an object of the same name already exists, then that object is replaced, with a warning if $^W is true.

$dispatch->remove($)

Removes the output object that matches the name given to the remove method. The return value is the object being removed or undef if no object matched this.

$dispatch->outputs()

Returns a list of output objects.

$dispatch->output( $name )

Returns the output object of the given name. Returns undef or an empty list, depending on context, if the given output does not exist.

$dispatch->_die_with_message( message => $, carp_level => $ )

This method is used by log_and_die and will either die() or croak() depending on the value of message: if it's a reference or it ends with a new line then a plain die will be used, otherwise it will croak.

OUTPUT CLASSES

An output class - e.g. Log::Dispatch::File or Log::Dispatch::Screen - implements a particular way of dispatching logs. Many output classes come with this distribution, and others are available separately on CPAN.

The following common parameters can be used when creating an output class. All are optional. Most output classes will have additional parameters beyond these, see their documentation for details.

  • name ($)

    A name for the object (not the filename!). This is useful if you want to refer to the object later, e.g. to log specifically to it or remove it.

    By default a unique name will be generated. You should not depend on the form of generated names, as they may change.

  • min_level ($)

    The minimum logging level this object will accept. Required.

  • max_level ($)

    The maximum logging level this object will accept. By default the maximum is the highest possible level (which means functionally that the object has no maximum).

  • callbacks( \& or [ \&, \&, ... ] )

    This parameter may be a single subroutine reference or an array reference of subroutine references. These callbacks will be called in the order they are given and passed a hash containing the following keys:

      ( message => $log_message, level => $log_level )
    

    The callbacks are expected to modify the message and then return a single scalar containing that modified message. These callbacks will be called when either the log or log_to methods are called and will only be applied to a given message once. If they do not return the message then you will get no output. Make sure to return the message!

  • newline (0|1)

    If true, a callback will be added to the end of the callbacks list that adds a newline to the end of each message. Default is false, but some output classes may decide to make the default true.

LOG LEVELS

The log levels that Log::Dispatch uses are taken directly from the syslog man pages (except that I expanded them to full words). Valid levels are:

  • debug
  • info
  • notice
  • warning
  • error
  • critical
  • alert
  • emergency

Alternately, the numbers 0 through 7 may be used (debug is 0 and emergency is 7). The syslog standard of 'err', 'crit', and 'emerg' is also acceptable. We also allow 'warn' as a synonym for 'warning'.

SUBCLASSING

This module was designed to be easy to subclass. If you want to handle messaging in a way not implemented in this package, you should be able to add this with minimal effort. It is generally as simple as subclassing Log::Dispatch::Output and overriding the new and log_message methods. See the Log::Dispatch::Output docs for more details.

If you would like to create your own subclass for sending email then it is even simpler. Simply subclass Log::Dispatch::Email and override the send_email method. See the Log::Dispatch::Email docs for more details.

The logging levels that Log::Dispatch uses are borrowed from the standard UNIX syslog levels, except that where syslog uses partial words ("err") Log::Dispatch also allows the use of the full word as well ("error").

RELATED MODULES

Log::Dispatch::DBI

Written by Tatsuhiko Miyagawa. Log output to a database table.

Log::Dispatch::FileRotate

Written by Mark Pfeiffer. Rotates log files periodically as part of its usage.

Log::Dispatch::File::Stamped

Written by Eric Cholet. Stamps log files with date and time information.

Log::Dispatch::Jabber

Written by Aaron Straup Cope. Logs messages via Jabber.

Log::Dispatch::Tk

Written by Dominique Dumont. Logs messages to a Tk window.

Log::Dispatch::Win32EventLog

Written by Arthur Bergman. Logs messages to the Windows event log.

Log::Log4perl

An implementation of Java's log4j API in Perl. Log messages can be limited by fine-grained controls, and if they end up being logged, both native Log4perl and Log::Dispatch appenders can be used to perform the actual logging job. Created by Mike Schilli and Kevin Goess.

Log::Dispatch::Config

Written by Tatsuhiko Miyagawa. Allows configuration of logging via a text file similar (or so I'm told) to how it is done with log4j. Simpler than Log::Log4perl.

Log::Agent

A very different API for doing many of the same things that Log::Dispatch does. Originally written by Raphael Manfredi.

SEE ALSO

Log::Dispatch::ApacheLog, Log::Dispatch::Email, Log::Dispatch::Email::MailSend, Log::Dispatch::Email::MailSender, Log::Dispatch::Email::MailSendmail, Log::Dispatch::Email::MIMELite, Log::Dispatch::File, Log::Dispatch::File::Locked, Log::Dispatch::Handle, Log::Dispatch::Output, Log::Dispatch::Screen, Log::Dispatch::Syslog

SUPPORT

Bugs may be submitted at https://github.com/houseabsolute/Log-Dispatch/issues.

SOURCE

The source code repository for Log-Dispatch can be found at https://github.com/houseabsolute/Log-Dispatch.

DONATIONS

If you'd like to thank me for the work I've done on this module, please consider making a "donation" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer.

Please note that I am not suggesting that you must do this in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me.

Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time (let's all have a chuckle at that together).

To donate, log into PayPal and send money to [email protected], or use the button at https://houseabsolute.com/foss-donations/.

AUTHOR

Dave Rolsky [email protected]

CONTRIBUTORS

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.

log-dispatch's People

Contributors

anirvan avatar autarch avatar carstengrohmann avatar dolmen avatar eserte avatar haarg avatar hartzell avatar jmaslak avatar jonswar avatar jorol avatar karenetheridge avatar kyzn avatar mschout avatar oalders avatar oschwald avatar plicease avatar preaction avatar rjattrill avatar salva avatar sergle avatar stevieb9 avatar wjackson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

log-dispatch's Issues

08-screen.t fails with PERL_UNICODE and 5.22.1

Migrated from rt.cpan.org #111143 (status was 'open')

Requestors:

Attachments:

From [email protected] (@madsen) on 2016-01-13 05:38:40:

With Perl 5.22.1, LANG=en_US.UTF-8, and PERL_UNICODE=SAL, 08-screen.t fails. It succeeds if I set either LANG=C or PERL_UNICODE=0.

With Perl 5.20.2, the test passes even with PERL_UNICODE=SAL.

I've attached the result of running

perl5.22.1 t/00-report-prereqs.t &>/tmp/00-report-prereqs.txt

along with the results of 00-report-prereqs.t for both 5.20.2 and 5.22.1.

Won't build

Tried to install LWP::ConsoleLogger::Easy, which requires Log::Dispatch. Running 5.24.0.

Attaching build.log, which can explain what went wrong better than I can.

build.log.txt

Log::Dispatch::File doesn't re-chmod after re-open in close_after_write mode

File created correctly first time. After file goes away due to rotation, file recreated but $self->{chmodded} is still set so it doesn't check the permissions this time and the file doesn't get chmod()ed. Pretty sure all you need is to add 'delete $_[0]->{chmodded}' in the last 'if' of log_message, and in the mean time the following nasty hack appears to be holding up:

{ package Log::Dispatch::File; use Class::Method::Modifiers;
  after log_message => sub { delete $_[0]->{chmodded} if $_[0]->{close} } }

Fix breakage / syntax error in Log::Dispatch::ApacheLog

Log::Dispatch::ApacheLog no longer works.

Trying to add an ApacheLog a logger throws error:

Undefined subroutine &Log::Dispatch::ApacheLog::validator called at /Users/mschout/Sync/gkgdrs/core/build/lib/perl5/site_perl/5.24.1/Log/Dispatch/ApacheLog.pm line 30.

Looking at the source code it seems that the sigil was missed on "validator". PR coming to address this shortly.

Add format

Log::Dispatch::Config has a nice format option which I would like to see in Log::Dispatch directly.

In my case I'd like to have a screen logger that prepends log messages with the time and the log level. I know this can be done with adding a callback, but since Log::Dispatch::Config provides such a convenient option, it would be nice when something like it would be directly available in all Log::Dispatch outputs.

Use octal notation for permissions in chmod error message

Hi Dave,

it would be great if you can improve the output of the chmod error in _open_file() from a decimal to an octal notation, because it would improve the readability significantly.

Current output:

Cannot chmod web/logs/debug.log to 438: Operation not permitted at ../lib/cpan/Log/Dispatch/File.pm line 118.

Improved output:

Cannot chmod web/logs/debug.log to 0666: Operation not permitted at ../lib/cpan/Log/Dispatch/File.pm line 118.

Thank you,
Carsten

Log::Dispatch::Screen mangles Unicode text

https://metacpan.org/release/DROLSKY/Log-Dispatch-2.70/view/lib/Log/Dispatch/Screen.pm says:

  • utf8 (0 or 1)

If this is true, then the output uses binmode to apply the :encoding(UTF-8) layer to the relevant handle for output.

Thus, if some other part of my code (or another module) already sets binmode $handle, ":encoding(UTF-8)", this should be a harmless no-op. But:

use strict;
use warnings;
use Log::Dispatch;

binmode STDOUT, ":encoding(UTF-8)";

my $log = Log::Dispatch->new(
    outputs => [
        [
            'Screen',
            min_level => 'debug',
            newline   => 1,
            stderr    => 0,
            utf8      => 1,
        ],
    ],
);

$log->warning("caf\N{U+00E9}");

Actual output:

$ perl try.pl
cafรƒยฉ

Expected output:

$ perl try.pl
cafรฉ

Log::Dispatch::Screen doesn't autoflush as documented

https://metacpan.org/release/DROLSKY/Log-Dispatch-2.70/view/lib/Log/Dispatch/Screen.pm says:

The handle will be autoflushed

But the module isn't flushing anything. The log messages just accumulate in memory until the internal buffer runs full.

Test code:

use strict;
use warnings;
use Log::Dispatch;

my $log = Log::Dispatch->new(
    outputs => [
        [
            'Screen',
            min_level => 'debug',
            newline   => 1,
            stderr    => 0,
        ],
    ],
);

for my $i (1 .. 10) {
    $log->warning("message $i");
    sleep 1;
}

Run it as perl try.pl | cat or strace perl try.pl > loggylog. In either case you can see the program sleep for 10 seconds, followed by a single write() containing all the output:

...
close(3)                                = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffee0516170) = 0
rt_sigaction(SIGHUP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGINT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGQUIT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGILL, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTRAP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGABRT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGFPE, NULL, {sa_handler=SIG_IGN, sa_mask=[FPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f2efb442520}, 8) = 0
rt_sigaction(SIGKILL, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGUSR1, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGUSR2, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPIPE, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGALRM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSTKFLT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGCHLD, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGCONT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSTOP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTSTP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTTIN, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTTOU, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGURG, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGXCPU, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGXFSZ, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGVTALRM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPROF, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGWINCH, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGIO, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPWR, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSYS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_2, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_3, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_4, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_5, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_6, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_7, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_8, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_9, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_10, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_11, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_12, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_13, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_14, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_15, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_16, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_17, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_18, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_19, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_20, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_21, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_22, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_23, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_24, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_25, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_26, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_27, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_28, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_29, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_30, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_31, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_32, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGABRT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGCHLD, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGIO, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
write(1, "message 1\nmessage 2\nmessage 3\nmessage 4\nmessage 5\nmessage 6\nmessage 7\nmessage 8\nmessage 9\nmessage 10\n", 101) = 101
exit_group(0)                           = ?
+++ exited with 0 +++

Log::Dispatch::Screen doesn't write to fd 1 or 2 as documented

https://metacpan.org/release/DROLSKY/Log-Dispatch-2.70/view/lib/Log/Dispatch/Screen.pm says:

this module opens it's own handle to fd 1 or 2 instead of using the global STDOUT or STDERR

Therefore I should be able to send STDOUT/STDERR elsewhere and still use my logger object (as long as file descriptors 1 and 2 are set correctly). But this doesn't work:

use strict;
use warnings;
use Log::Dispatch;

my $log = Log::Dispatch->new(
    outputs => [
        [
            'Screen',
            min_level => 'debug',
            newline   => 1,
            stderr    => 0,
        ],
    ],
);

open my $null, '>', '/dev/null' or die "$0: /dev/null: $!\n";
open my $fd_1, '>&=', 1 or die "$0: can't fdopen 1: $!\n";
*STDOUT = *$null{IO};

print STDOUT "I don't see this\n";
print $fd_1 "this is all right\n";

$log->warning("I should see this");

Actual output:

$ perl try.pl
this is all right

Expected output:

$ perl try.pl
this is all right
I should see this

local $?= undef warns in Log::Dispatch::Email::MailSender

Log::Dispatch::Email::MailSender localizes $?, but also assigns undef to it. This throws warnings, as $? is expected to always be a number. Replacing it with just local $? with no assignment should fix the issue. Alternatively, assigning 0 should work.

Please add fatal

Please add a 'fatal' method which should be the same as 'critical'. This would add compatibility with Log::Log4perl.

Tests fail on NFS-mounted temp drive

I'm seeing an issue on a NFS-mounted temp directory with t/file-locked.t failing. It does not fail with local disks. I wouldn't be surprised if my locking configuration isn't quite right on this host (nfs4, Linux kernel 4.4.0).

Interesting output (I set the tmp directory manually to an NFS-mounted subdir under my home directory):

t/file-locked.t ..
# Subtest: close_after_write = 0
    ok 1 - no exception forking children and writing to file
    not ok 2 - 10 children exited

    #   Failed test '10 children exited'
    #   at t/file-locked.t line 109.
    #          got: '9'
    #     expected: '10'
    ok 3 - 10812 exited with 0
    ok 4 - 10813 exited with 0
    ok 5 - 10808 exited with 0
    ok 6 - 10806 exited with 0
    ok 7 - 10815 exited with 0
    ok 8 - 10809 exited with 0
    ok 9 - 10807 exited with 0
    ok 10 - 10810 exited with 0
    ok 11 - 10811 exited with 0
    not ok 12 - file contains expected content

    #   Failed test 'file contains expected content'
    #   at t/file-locked.t line 138.
    #     Structures begin differing at:
    #          $got->[9] = '2'
    #     $expected->[9] = '1'
    # 1
    # 1
    # 1
    # 1
    # 1
    # 1
    # 2
    # 2
    # 2
    # 3
    # 2
    # 2
    # 3
    # 3
    # 2
    # 3
    # 3
    # 1
    # 1
    # 2
    # 3
    # 3
    # 2
    # 3
    # 1
    # 2
    # 3
    1..12
    # Looks like you failed 2 tests of 12.
not ok 1 - close_after_write = 0

Log-Any-Adapter-Dispatch broken since Log-Dispatch 2.60

See http://www.cpantesters.org/cpan/report/206238d6-f1c6-11e6-bb94-6bc77d6e3ab9 for example:

# Testing Log::Any::Adapter::Dispatch 0.06, Perl 5.024001, /tmp/basesmoker-reloperl-9QJ2/bin/perl
t/00-load.t ... ok
found extra parameters: [category] at /home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Exception/Class/Base.pm line 88.
	Exception::Class::Base::throw("Params::ValidationCompiler::Exception::Named::Extra", "message", "found extra parameters: [category]", "parameters", ARRAY(0x56080a23f5f0)) called at (eval 141)[/home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Eval/Closure.pm:149] line 98
	Eval::Closure::Sandbox_115::__ANON__[(eval 141)[/home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Eval/Closure.pm:149]:104]("outputs", ARRAY(0x56080a6e68f0), "category", "main") called at /home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Log/Dispatch.pm line 52
	Log::Dispatch::new("Log::Dispatch", "outputs", ARRAY(0x56080a6e68f0), "category", "main") called at /tmp/loop_over_bdir-16101-czJM5C/Log-Any-Adapter-Dispatch-0.06-0/blib/lib/Log/Any/Adapter/Dispatch.pm line 15
	Log::Any::Adapter::Dispatch::init(Log::Any::Adapter::Dispatch=HASH(0x56080a6e6b00), "outputs", ARRAY(0x56080a6e68f0), "category", "main") called at /home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Log/Any/Adapter/Base.pm line 16
	Log::Any::Adapter::Base::new("Log::Any::Adapter::Dispatch", "outputs", ARRAY(0x56080a6e68f0), "category", "main") called at /home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Log/Any/Manager.pm line 72
	Log::Any::Manager::_new_adapter_for_entry(Log::Any::Manager=HASH(0x56080978f100), HASH(0x56080a6e6ae8), "main") called at /home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Log/Any/Manager.pm line 171
	Log::Any::Manager::_reselect_matching_adapters(Log::Any::Manager=HASH(0x56080978f100), qr(.*)) called at /home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Log/Any/Manager.pm line 122
	Log::Any::Manager::set(Log::Any::Manager=HASH(0x56080978f100), "Dispatch", "outputs", ARRAY(0x56080a6e68f0)) called at /home/sand/src/perl/repoperls/installed-perls/host/k93x64sid/v5.24.1/fae6/lib/site_perl/5.24.1/Log/Any/Adapter.pm line 19
	Log::Any::Adapter::set("Log::Any::Adapter", "Dispatch", "outputs", ARRAY(0x56080a6e68f0)) called at t/dispatch.t line 62
# Looks like your test exited with 255 before it could output anything.
t/dispatch.t .. 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 56/56 subtests 

Test Summary Report
-------------------
t/dispatch.t (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 56 tests but ran 0.
Files=2, Tests=1,  0 wallclock secs ( 0.02 usr  0.02 sys +  0.27 cusr  0.05 csys =  0.36 CPU)
Result: FAIL
Failed 1/2 test programs. 0/1 subtests failed.
Makefile:779: recipe for target 'test_dynamic' failed
make: *** [test_dynamic] Error 255

I don't know if that module is doing something unsupported or if something got missed in the switch to Params::ValidationCompiler, but Log-Any-Adapter-Dispatch hasn't changed since 2010 so I guess it's not actively maintained.

It's still failing with 2.62 but you don't get the (possibly useful) stack trace.

How to get atomic writes with Log::Dispatch::File

Migrated from rt.cpan.org #108899 (status was 'open')

Requestors:

Attachments:

From [email protected] (@eserte) on 2015-11-13 13:42:10:

It seems that writes done from multiple processes to a shared file are only atomic if the file was opened with O_APPEND, at least on Linux and for reasonable string lengths. The attached script seems to confirm this statement --- with '>>' I get always 1000 lines of output, with '>' it's always less than 1000.

It would be nice if this could be mentioned in the Log::Dispatch::File documentation.

Some pointers about atomic writes:

split up multiline messages sent to Log::Dispatch::Syslog

Migrated from rt.cpan.org #26711 (status was 'open')

Requestors:

Attachments:

From [email protected] on 2007-04-26 14:05:04:

The Text::SimpleTable module in Catalyst routinely generates multi-line
strings which Catalyst routinely sends to it's logging output which when
piped into Log::Dispatch::Syslog looks very messy in the end result.
This patch allows these outputs to show up reasonably in syslog logs.

Test failure ("Log::Dispatch::Handle created log file should contain 'handle test\n'")

Migrated from rt.cpan.org #39272 (status was 'new')

Requestors:

From [email protected] (@eserte) on 2008-09-14 20:19:43:

I see that there are couple of test reports with the same failure (see
subject). On my machine, Log::Dispatch's test suite works fine with
perl5.8.8, but fails with perl5.10.0. I run both with ktrace and pasted
the interesting pieces below. My observations: there is indeed no
write() call in the failure case, and there's also a close() missing. So
maybe here is some kind of race condition, or a leak preventing the
close() to happen?

Regards,
Slaven

 58498 perl5.10.0 RET   write 71/0x47
 58498 perl5.10.0 CALL  close(0x3)
 58498 perl5.10.0 RET   close 0
 58498 perl5.10.0 CALL  open(0x84c2d20,0x601,0x1b6)
 58498 perl5.10.0 NAMI  "/tmp/vUN7K_gHxp/handle.log"
 58498 perl5.10.0 RET   open 3
 58498 perl5.10.0 CALL  ioctl(0x3,TIOCGETA,0xbfbfe620)
 58498 perl5.10.0 RET   ioctl -1 errno 25 Inappropriate ioctl for device
 58498 perl5.10.0 CALL  lseek(0x3,0,0,0,0x1)
 58498 perl5.10.0 RET   lseek 0
 58498 perl5.10.0 CALL  fstat(0x3,0x814caa0)
 58498 perl5.10.0 RET   fstat 0
 58498 perl5.10.0 CALL  fcntl(0x3,0x2,0x1)
 58498 perl5.10.0 RET   fcntl 0
 58498 perl5.10.0 CALL  open(0x84c2760,0,0x1b6)
 58498 perl5.10.0 NAMI  "/tmp/vUN7K_gHxp/handle.log"
 58498 perl5.10.0 RET   open 4
 58498 perl5.10.0 CALL  ioctl(0x4,TIOCGETA,0xbfbfe620)
 58498 perl5.10.0 RET   ioctl -1 errno 25 Inappropriate ioctl for device
 58498 perl5.10.0 CALL  lseek(0x4,0,0,0,0x1)
 58498 perl5.10.0 RET   lseek 0
 58498 perl5.10.0 CALL  fstat(0x4,0x814caa0)
 58498 perl5.10.0 RET   fstat 0
 58498 perl5.10.0 CALL  fcntl(0x4,0x2,0x1)
 58498 perl5.10.0 RET   fcntl 0
 58498 perl5.10.0 CALL  break(0x84c8000)
 58498 perl5.10.0 RET   break 0
 58498 perl5.10.0 CALL  read(0x4,0x84c7000,0x1000)
 58498 perl5.10.0 GIO   fd 4 read 0 bytes
       ""
 58498 perl5.10.0 RET   read 0
 58498 perl5.10.0 CALL  close(0x4)
 58498 perl5.10.0 RET   close 0
 58498 perl5.10.0 CALL  write(0x6,0x816e000,0x51)
 58498 perl5.10.0 GIO   fd 6 wrote 81 bytes
       "not ok 7 - Log::Dispatch::Handle created log file should contain
'handle test\\n'
       "
======================================================================

 59061 perl     RET   write 71/0x47
 59061 perl     CALL  close(0x3)
 59061 perl     RET   close 0
 59061 perl     CALL  open(0x84061c0,0x601,0x1b6)
 59061 perl     NAMI  "/tmp/lIj3yZjGKm/handle.log"
 59061 perl     RET   open 3
 59061 perl     CALL  fstat(0x3,0x2817aa20)
 59061 perl     RET   fstat 0
 59061 perl     CALL  fcntl(0x3,0x2,0x1)
 59061 perl     RET   fcntl 0
 59061 perl     CALL  break(0x8408000)
 59061 perl     RET   break 0
 59061 perl     CALL  break(0x8408800)
 59061 perl     RET   break 0
 59061 perl     CALL  fstat(0x3,0xbfbfe6d0)
 59061 perl     RET   fstat 0
 59061 perl     CALL  write(0x3,0x8068000,0xc)
 59061 perl     GIO   fd 3 wrote 12 bytes
       "handle test
       "
 59061 perl     RET   write 12/0xc
 59061 perl     CALL  close(0x3)
 59061 perl     RET   close 0
 59061 perl     CALL  open(0x8403f60,0,0x1b6)
 59061 perl     NAMI  "/tmp/lIj3yZjGKm/handle.log"
 59061 perl     RET   open 3
 59061 perl     CALL  fstat(0x3,0x2817aa20)
 59061 perl     RET   fstat 0
 59061 perl     CALL  fcntl(0x3,0x2,0x1)
 59061 perl     RET   fcntl 0
 59061 perl     CALL  fstat(0x3,0xbfbfc610)
 59061 perl     RET   fstat 0
 59061 perl     CALL  read(0x3,0x8068000,0x1000)
 59061 perl     GIO   fd 3 read 12 bytes
       "handle test
       "
 59061 perl     RET   read 12/0xc
 59061 perl     CALL  read(0x3,0x8068000,0x1000)
 59061 perl     GIO   fd 3 read 0 bytes
       ""
 59061 perl     RET   read 0
 59061 perl     CALL  close(0x3)
 59061 perl     RET   close 0
 59061 perl     CALL  break(0x8409000)
 59061 perl     RET   break 0
 59061 perl     CALL  write(0x6,0x806c000,0x4d)
 59061 perl     GIO   fd 6 wrote 77 bytes
       "ok 7 - Log::Dispatch::Handle created log file should contain
'handle test\\n'
       "

Test failure on Windows platforms

During testing, t/08-screen.t is failing 4 of 5 tests because of end-of-line mismatches between the result and expected strings. It appears that a trailing CR is being left on the result string, which causes all four failures.

This issue has also been reported on rt.cpan.org (ticket-id:106947).

This appears to be a testing bug, not a module bug.

Given the context of the testing code and the fact that the newline is being thrown out, it appears that only "utf-8" processing is being tested. The end-of-line encoding doesn't seem to be of any concern.

I must note that delving into perl I/O layers makes my brain hurt. But, after some research, I believe the issue at hand is that the STDOUT and STDERR streams are being opened in binary mode but are being expected to return text mode results (i.e., end-of-line/newline == "\n"). The streams either need to be opened in text mode (by appending a :crlf layer) or their output must be massaged more directly, dealing with the various possible end-of-line CRLF combinations.

Likely, the best repair is simply to add :crlf to the layer specification string within _run_helper. Alternatively, again within _run_helper, replace chomp $_ with s/\r?\n?$// (which will correctly strip newlines for the three most common variations: *nix, Win/DOS, and MAC [up to OS-9]).

.## References

http://www.perlmonks.org/?node_id=549385 @@ https://archive.is/hEXuF
http://www.perlmonks.org/?node_id=900026 @@ https://archive.is/5Njlx
http://stackoverflow.com/questions/13105361/utf-16-perl-input-output/13106990#13106990
http://stackoverflow.com/questions/17829744/how-to-prevent-perl-to-replace-unix-only-linefeeds/17833422#17833422
http://stackoverflow.com/questions/32013968/create-utf-16le-with-bom-and-crlf-line-separator-on-windows/32014346#32014346
https://en.wikipedia.org/wiki/Newline @@ https://archive.is/kRxQk

Add set_min_level() method

Migrated from rt.cpan.org #22901 (status was 'open')

Requestors:

Attachments:

From [email protected] on 2006-11-08 15:21:09:

( I may submit a patch for this later as tuits permit ).

In a large system it can be useful to have "debug" turned on for one
part, but not the whole thing.

Therefore, it's useful to be able set a global "min_level" through the
constructor, but override that later, at least temporarily.

A simple method like set_min_level($level) could do this.

It would be neat if there was an option for this declaration to go out
of scope and automatically revert to the previous value, but I don't see
that feature as required.

Mark

Log::Dispatch::File doesn't allow object filename

When the filename parameter passed to the Log::Dispatch::File constructor is an object that overloads stringification (as the new Mojo::File is) Params::Validate barfs rather than trying the stringification (or some other resolution method).

This has become interesting to me since Mojo::Home has recently changed to generate Mojo::File path objects rather than strings (as of Mojolicious v7.15).

As discussed on IRC, @autarch mentioned that he was intending to change the validation layer from Params::Validate to Params::ValidationCompiler which could handle the overloaded object. I'm including this as a reminder. Meantime I can handle the stringification on my end, but this can serve as a tracking bug/reminder.

Potentially allowing for log_and_die to be used in a terse fashion

Greetings. Would either of the following API adjustments be considered as acceptable? Firstly, for log_and_die and log_and_croak to allow for the level parameter to be optional, defaulting to "error". Secondly, for the same methods - or perhaps new ones - to accept a single parameter containing the message.

$log->log_and_die(level => 'error', message => 'Something happened');
$log->log_and_die(message => 'Something happened');
$log->log_and_die('Something happened');
$log->die('Something happened'); # ... perhaps?

Version 2.56 and Syslog.pm - unable to catch the die

Hi, on commit 13e4bcc you had ignored the die signal before any Sys::Syslog call (row 98 of the file Syslog.pm).

For me is critical to know if a message has been written by the syslogd (I have to produce legal logs).

See this little snippet of code:

use Log::Log4perl;

sub DIE_handler() {
  print 'DIE Handler - ' . "@_";

  exit(1);
}

sub main() {
  my $conf = q(
    log4perl.rootLogger=TRACE, syslog

    log4perl.appender.syslog = Log::Dispatch::Syslog
    log4perl.appender.syslog.facility = mail
    log4perl.appender.syslog.socket.type = tcp
    log4perl.appender.syslog.socket.port = 514
    log4perl.appender.syslog.layout = Log::Log4perl::Layout::SimpleLayout
  );

  Log::Log4perl::init(\$conf);

  my $logger = Log::Log4perl::get_logger();

  $SIG{__DIE__} = \&DIE_handler;
  $logger->trace('TRACE');

  print "Log message has been written!\n";
}

main();

My syslog appender is setted on TCP:514. Now, If I shut down the syslogd, with v2.54 I correctly have:

DIE Handler - no connection to syslog available
        - tcp connect: Connection refused at /opt/perl/lib/site_perl/5.16.3/Log/Dispatch/Syslog.pm line 109.

with v2.56 conversely:

Log message has been written!

As you can see, with the v2.56 my code says that the log message has been written, but it isn't true because the syslogd were down!

I think that this is a regression even because as the Sys::Syslog man page says, If we want to ignore the die, we can use the nofatal option:

nofatal - When set to true, openlog() and syslog() will only emit warnings instead of dying if the connection to the syslog can't be established.

Thank you in advance,
Emanuele

Log::Dispatch::Email::MIMELite dies when passed message has non utf8 wide characters (eg ansi cp1252)

Hi, I just wanted to suggest an addition of removing non syswritable characters in Log::Dispatch::Email::MIMELite before sending the message, as MIME::Lite doesn't catch this and dies with "Wide character in syswrite at Net::Cmd.pm line 210".

E.g. you could do
eval {decode( 'UTF-8', $p{message}, $Encode::FB_CROAK )} or $p{message} =~ s/[^\x00-\x7f]/?/g; before adding the message to the mail in order to remove the offending non-ascii characters if the string contains non UTF-8 wide chars (which are supported by Net::Cmd).

-regards,
Roland

Windows 10, MSYS2: Test t/file-locked.t fails

System info: Windows 10, MSYS2, perl version 5.32.0.

$ cpanm -v  Log::Dispatch
cpanm (App::cpanminus) 1.7044 on perl 5.032000 built for x86_64-msys-thread-multi
Work directory is /home/hakon/.cpanm/work/1595230026.26931
You have make /usr/bin/make
You have LWP 6.46
You have /usr/bin/tar: tar (GNU tar) 1.32
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
Searching Log::Dispatch () on cpanmetadb ...
--> Working on Log::Dispatch
Fetching http://www.cpan.org/authors/id/D/DR/DROLSKY/Log-Dispatch-2.69.tar.gz ... OK
Unpacking Log-Dispatch-2.69.tar.gz
Log-Dispatch-2.69/
Log-Dispatch-2.69/Makefile.PL
Log-Dispatch-2.69/META.yml
Log-Dispatch-2.69/Changes
Log-Dispatch-2.69/CONTRIBUTING.md
Log-Dispatch-2.69/LICENSE
Log-Dispatch-2.69/README.md
Log-Dispatch-2.69/perltidyrc
Log-Dispatch-2.69/META.json
Log-Dispatch-2.69/CODE_OF_CONDUCT.md
Log-Dispatch-2.69/lib/
Log-Dispatch-2.69/lib/Log/
Log-Dispatch-2.69/lib/Log/Dispatch/
Log-Dispatch-2.69/lib/Log/Dispatch/Conflicts.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Base.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Syslog.pm
Log-Dispatch-2.69/lib/Log/Dispatch/ApacheLog.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Email.pm
Log-Dispatch-2.69/lib/Log/Dispatch/File/
Log-Dispatch-2.69/lib/Log/Dispatch/File/Locked.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Null.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Email/
Log-Dispatch-2.69/lib/Log/Dispatch/Email/MIMELite.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Email/MailSend.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Email/MailSendmail.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Email/MailSender.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Handle.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Output.pm
Log-Dispatch-2.69/lib/Log/Dispatch/File.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Code.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Types.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Vars.pm
Log-Dispatch-2.69/lib/Log/Dispatch/Screen.pm
Log-Dispatch-2.69/lib/Log/Dispatch.pm
Log-Dispatch-2.69/xt/
Log-Dispatch-2.69/xt/release/
Log-Dispatch-2.69/xt/release/cpan-changes.t
Log-Dispatch-2.69/xt/release/meta-json.t
Log-Dispatch-2.69/xt/author/
Log-Dispatch-2.69/xt/author/pod-spell.t
Log-Dispatch-2.69/xt/author/no-tabs.t
Log-Dispatch-2.69/xt/author/portability.t
Log-Dispatch-2.69/xt/author/mojibake.t
Log-Dispatch-2.69/xt/author/test-version.t
Log-Dispatch-2.69/xt/author/test-dependents.t
Log-Dispatch-2.69/xt/author/pod-coverage.t
Log-Dispatch-2.69/xt/author/pod-syntax.t
Log-Dispatch-2.69/xt/author/eol.t
Log-Dispatch-2.69/xt/author/tidyall.t
Log-Dispatch-2.69/appveyor.yml
Log-Dispatch-2.69/weaver.ini
Log-Dispatch-2.69/perlcriticrc
Log-Dispatch-2.69/cpanfile
Log-Dispatch-2.69/tidyall.ini
Log-Dispatch-2.69/t/
Log-Dispatch-2.69/t/screen.t
Log-Dispatch-2.69/t/00-report-prereqs.dd
Log-Dispatch-2.69/t/close-after-write.t
Log-Dispatch-2.69/t/sendmail
Log-Dispatch-2.69/t/short-syntax.t
Log-Dispatch-2.69/t/file-locked.t
Log-Dispatch-2.69/t/00-report-prereqs.t
Log-Dispatch-2.69/t/lib/
Log-Dispatch-2.69/t/lib/Log/
Log-Dispatch-2.69/t/lib/Log/Dispatch/
Log-Dispatch-2.69/t/lib/Log/Dispatch/TestUtil.pm
Log-Dispatch-2.69/t/email-exit.t
Log-Dispatch-2.69/t/screen-helper.pl
Log-Dispatch-2.69/t/syslog-threads.t
Log-Dispatch-2.69/t/binmode.t
Log-Dispatch-2.69/t/syslog.t
Log-Dispatch-2.69/t/00-compile.t
Log-Dispatch-2.69/t/email-exit-helper.pl
Log-Dispatch-2.69/t/syslog-lock-without-preloaded-threads.t
Log-Dispatch-2.69/t/basic.t
Log-Dispatch-2.69/t/lazy-open.t
Log-Dispatch-2.69/MANIFEST
Log-Dispatch-2.69/INSTALL
Log-Dispatch-2.69/dist.ini
Entering Log-Dispatch-2.69
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.44)
Checking if you have Dist::CheckConflicts 0.02 ... Yes (0.11)
Running Makefile.PL
Configuring Log-Dispatch-2.69 ... Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Log::Dispatch
Writing MYMETA.yml and MYMETA.json
OK
Checking dependencies from MYMETA.json ...
Checking if you have Params::ValidationCompiler 0 ... Yes (0.30)
Checking if you have PerlIO 0 ... Yes (1.11)
Checking if you have Specio 0.32 ... Yes (0.46)
Checking if you have File::Temp 0 ... Yes (0.2309)
Checking if you have FindBin 0 ... Yes (1.51)
Checking if you have Scalar::Util 0 ... Yes (1.55)
Checking if you have Test::More 0.96 ... Yes (1.302175)
Checking if you have Module::Runtime 0 ... Yes (0.016)
Checking if you have warnings 0 ... Yes (1.47)
Checking if you have Specio::Library::String 0 ... Yes (0.46)
Checking if you have Specio::Library::Numeric 0 ... Yes (0.46)
Checking if you have parent 0 ... Yes (0.238)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.44)
Checking if you have Carp 0 ... Yes (1.50)
Checking if you have Test::Fatal 0 ... Yes (0.014)
Checking if you have IPC::Run3 0 ... Yes (0.048)
Checking if you have strict 0 ... Yes (1.11)
Checking if you have base 0 ... Yes (2.27)
Checking if you have Specio::Exporter 0 ... Yes (0.46)
Checking if you have Exporter 0 ... Yes (5.74)
Checking if you have Try::Tiny 0 ... Yes (0.30)
Checking if you have File::Spec 0 ... Yes (3.78)
Checking if you have Devel::GlobalDestruction 0 ... Yes (0.14)
Checking if you have Fcntl 0 ... Yes (1.13)
Checking if you have Data::Dumper 0 ... Yes (2.174)
Checking if you have IO::Handle 0 ... Yes (1.42)
Checking if you have utf8 0 ... Yes (1.22)
Checking if you have Dist::CheckConflicts 0.02 ... Yes (0.11)
Checking if you have Test::Needs 0 ... Yes (0.002006)
Checking if you have namespace::autoclean 0 ... Yes (0.29)
Checking if you have Specio::Library::Builtins 0 ... Yes (0.46)
Checking if you have Sys::Syslog 0.28 ... Yes (0.36)
Checking if you have lib 0 ... Yes (0.65)
Checking if you have IO::File 0 ... Yes (1.41)
Checking if you have Encode 0 ... Yes (3.06)
Checking if you have Getopt::Long 0 ... Yes (2.51)
Checking if you have Specio::Declare 0 ... Yes (0.46)
Checking if you have POSIX 0 ... Yes (1.94)
Building and testing Log-Dispatch-2.69 ... cp lib/Log/Dispatch/Email/MIMELite.pm blib/lib/Log/Dispatch/Email/MIMELite.pm
cp lib/Log/Dispatch/Code.pm blib/lib/Log/Dispatch/Code.pm
cp lib/Log/Dispatch/Base.pm blib/lib/Log/Dispatch/Base.pm
cp lib/Log/Dispatch/Conflicts.pm blib/lib/Log/Dispatch/Conflicts.pm
cp lib/Log/Dispatch/Handle.pm blib/lib/Log/Dispatch/Handle.pm
cp lib/Log/Dispatch/Email/MailSendmail.pm blib/lib/Log/Dispatch/Email/MailSendmail.pm
cp lib/Log/Dispatch/ApacheLog.pm blib/lib/Log/Dispatch/ApacheLog.pm
cp lib/Log/Dispatch/Syslog.pm blib/lib/Log/Dispatch/Syslog.pm
cp lib/Log/Dispatch/Vars.pm blib/lib/Log/Dispatch/Vars.pm
cp lib/Log/Dispatch/Email.pm blib/lib/Log/Dispatch/Email.pm
cp lib/Log/Dispatch/File.pm blib/lib/Log/Dispatch/File.pm
cp lib/Log/Dispatch/Screen.pm blib/lib/Log/Dispatch/Screen.pm
cp lib/Log/Dispatch/Email/MailSend.pm blib/lib/Log/Dispatch/Email/MailSend.pm
cp lib/Log/Dispatch/Email/MailSender.pm blib/lib/Log/Dispatch/Email/MailSender.pm
cp lib/Log/Dispatch/Output.pm blib/lib/Log/Dispatch/Output.pm
cp lib/Log/Dispatch/Null.pm blib/lib/Log/Dispatch/Null.pm
cp lib/Log/Dispatch/File/Locked.pm blib/lib/Log/Dispatch/File/Locked.pm
cp lib/Log/Dispatch.pm blib/lib/Log/Dispatch.pm
cp lib/Log/Dispatch/Types.pm blib/lib/Log/Dispatch/Types.pm
Manifying 18 pod documents
PERL_DL_NONLAZY=1 "/usr/bin/perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-compile.t ............................. ok
t/00-report-prereqs.t ...................... 1/1 #
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
#     Module               Want Have
#     -------------------- ---- ----
#     Dist::CheckConflicts 0.02 0.11
#     ExtUtils::MakeMaker   any 7.44
#
# === Configure Suggests ===
#
#     Module      Want Have
#     -------- ------- ----
#     JSON::PP 2.27300 4.04
#
# === Build Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 7.44
#
# === Test Requires ===
#
#     Module              Want     Have
#     ------------------- ---- --------
#     Data::Dumper         any    2.174
#     ExtUtils::MakeMaker  any     7.44
#     File::Spec           any     3.78
#     File::Temp           any   0.2309
#     FindBin              any     1.51
#     Getopt::Long         any     2.51
#     IO::File             any     1.41
#     IPC::Run3            any    0.048
#     POSIX                any     1.94
#     PerlIO               any     1.11
#     Test::Fatal          any    0.014
#     Test::More          0.96 1.302175
#     Test::Needs          any 0.002006
#     lib                  any     0.65
#     utf8                 any     1.22
#
# === Test Recommends ===
#
#     Module         Want     Have
#     ---------- -------- --------
#     CPAN::Meta 2.120900 2.150010
#
# === Runtime Requires ===
#
#     Module                     Want  Have
#     -------------------------- ---- -----
#     Carp                        any  1.50
#     Devel::GlobalDestruction    any  0.14
#     Dist::CheckConflicts       0.02  0.11
#     Encode                      any  3.06
#     Exporter                    any  5.74
#     Fcntl                       any  1.13
#     IO::Handle                  any  1.42
#     Module::Runtime             any 0.016
#     Params::ValidationCompiler  any  0.30
#     Scalar::Util                any  1.55
#     Specio                     0.32  0.46
#     Specio::Declare             any  0.46
#     Specio::Exporter            any  0.46
#     Specio::Library::Builtins   any  0.46
#     Specio::Library::Numeric    any  0.46
#     Specio::Library::String     any  0.46
#     Sys::Syslog                0.28  0.36
#     Try::Tiny                   any  0.30
#     base                        any  2.27
#     namespace::autoclean        any  0.29
#     parent                      any 0.238
#     strict                      any  1.11
#     warnings                    any  1.47
#
t/00-report-prereqs.t ...................... ok
t/basic.t .................................. ok
t/binmode.t ................................ ok
t/close-after-write.t ...................... ok
t/email-exit.t ............................. skipped: This test only runs for the maintainer
t/file-locked.t ............................
    #   Failed test '10 children exited'
    #   at t/file-locked.t line 109.
    #          got: '5'
    #     expected: '10'

    #   Failed test 'file contains expected content'
    #   at t/file-locked.t line 138.
    #     Structures begin differing at:
    #          $got->[17] = '3'
    #     $expected->[17] = '2'
    # 1
    # 1
    # 1
    # 1
    # 1
    # 2
    # 2
    # 2
    # 2
    # 3
    # 3
    # 3
    # 3
    # 2
    # 1
    # 1
    # 3
    # 1
    # 1
    # 2
    # 2
    # 1
t/file-locked.t ............................ 1/?     # Looks like you failed 2 tests of 8.

#   Failed test 'close_after_write = 0'
#   at t/file-locked.t line 21.
t/file-locked.t ............................ 2/?
    #   Failed test '10 children exited'
    #   at t/file-locked.t line 109.
    #          got: '5'
    #     expected: '10'

    #   Failed test 'file contains expected content'
    #   at t/file-locked.t line 138.
    #     Structures begin differing at:
    #          $got->[16] = '3'
    #     $expected->[16] = '2'
    # 1
    # 1
    # 1
    # 1
    # 1
    # 2
    # 2
    # 2
    # 3
    # 3
    # 3
    # 2
    # 2
    # 1
    # 3
    # 3
    # 1
    # 1
    # 1
    # 2
    # 1
    # Looks like you failed 2 tests of 8.

#   Failed test 'close_after_write = 1'
#   at t/file-locked.t line 21.
# Looks like you failed 2 tests of 2.
Cannot write to '/tmp/GooGpKXgE2/lock-test.log': No such file or directory at /home/hakon/.cpanm/work/1595230026.26931/Log-Dispatch-2.69/blib/lib/Log/Dispatch/File.pm line 101.
Cannot write to '/tmp/GooGpKXgE2/lock-test.log': No such file or directory at /home/hakon/.cpanm/work/1595230026.26931/Log-Dispatch-2.69/blib/lib/Log/Dispatch/File.pm line 101.
Cannot write to '/tmp/GooGpKXgE2/lock-test.log': No such file or directory at /home/hakon/.cpanm/work/1595230026.26931/Log-Dispatch-2.69/blib/lib/Log/Dispatch/File.pm line 101.
Cannot write to '/tmp/GooGpKXgE2/lock-test.log': No such file or directory at /home/hakon/.cpanm/work/1595230026.26931/Log-Dispatch-2.69/blib/lib/Log/Dispatch/File.pm line 101.
t/file-locked.t ............................ Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/2 subtests
t/lazy-open.t .............................. ok
t/screen.t ................................. ok
t/short-syntax.t ........................... ok
t/syslog-lock-without-preloaded-threads.t .. ok
t/syslog-threads.t ......................... ok
t/syslog.t ................................. ok

Test Summary Report
-------------------
t/file-locked.t                          (Wstat: 512 Tests: 2 Failed: 2)
  Failed tests:  1-2
  Non-zero exit status: 2
Files=13, Tests=84, 38 wallclock secs ( 0.08 usr  0.09 sys + 12.61 cusr  9.74 csys = 22.53 CPU)
Result: FAIL
Failed 1/13 test programs. 2/84 subtests failed.
make: *** [Makefile:996: test_dynamic] Error 255
FAIL
! Installing Log::Dispatch failed. See /home/hakon/.cpanm/work/1595230026.26931/build.log for details. Retry with --force to force install it.

Log::Dispatch complains about _should_log during global destruction.

rt-crontool from bestpractical uses Log::Dispatch which complains occasionally about this:

	(in cleanup) Can't call method "_should_log" on an undefined value at /usr/share/perl5/Log/Dispatch.pm line 269 during global destruction.

That line:

262 sub would_log {
263     my $self  = shift;
264     my $level = shift;
265 
266     return 0 unless $self->level_is_valid($level);
267 
268     foreach ( values %{ $self->{outputs} } ) {
269         return 1 if $_->_should_log($level);                                                                                
270     }
271 
272     return 0;
273 }

I'm using version 2.44, supplied to me by my vendor Debian. Is this a bug?

Regards,
Kai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.