Reputation: 25117
Is it possible to configure Mojo::Log in a way so it adds the line number to the log messages?
Upvotes: 1
Views: 241
Reputation: 149
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.
Upvotes: 0
Reputation: 2960
Doesn't look like it, but you can use a special literal in there yourself:
$log->debug(__LINE__ . ': Some debug message.');
Upvotes: 5