Question

Is it possible to configure Mojo::Log in a way so it adds the line number to the log messages?

Était-ce utile?

La solution

Nope. That is not a supported feature.

Autres conseils

Doesn't look like it, but you can use a special literal in there yourself:

$log->debug(__LINE__ . ': Some debug message.');

Do you have to use Mojo::Log? If you can use MojoX::Log::Log4perl, you're home free.

use MojoX::Log::Log4perl;

sub startup {
    ...
    my $logconfig =<<EOF;
    ...
    log4perl.appender.FILE.layout.ConversionPattern = [%d] %P %p %C,%L - %m%n
    ...
EOF

    my $mojox_logger = MojoX::Log::Log4perl->new( \$logconfig );
    $self->log($mojox_logger);
}

The %L in the ConversionPattern is for the line number.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top