Question

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

Was it helpful?

Solution

Nope. That is not a supported feature.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top