Mojo::Log - Is it possible to add the line number to the messages?
-
25-07-2021 - |
题
Is it possible to configure Mojo::Log in a way so it adds the line number to the log messages?
解决方案
Nope. That is not a supported feature.
其他提示
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.
不隶属于 StackOverflow