use Moo;
use Scalar::Util qw(weaken);
-has format => ( is => 'ro', required => 1, default => sub { '[%l %r] %s' } );
+has format => ( is => 'ro', required => 1, default => sub { '[%l %r] %f:%i %p::%m %s' } );
has level_names => ( is => 'ro', required => 1 );
has min_level => ( is => 'ro', required => 1 );
has max_level => ( is => 'ro' );
return {
'%' => '%', t => $self->_render_time($metadata->{timestamp}),
r => $self->_render_remote($metadata->{object_remote}),
- s => $self->_render_log(@$content), l => $level, p => $metadata->{package},
+ s => $self->_render_log(@$content), l => $level,
+ p => $metadata->{package}, m => $metadata->{method},
+ f => $metadata->{filename}, i => $metadata->{line},
};
}
#caller_level is useless when log forwarding is in place
#so we won't tempt people with using it for now - access
#to caller level will be available in the future
- delete $metadata{caller_level};
+ my $caller_level = delete $metadata{caller_level};
$metadata{object_remote} = $self->_remote_metadata;
$metadata{timestamp} = time;
+
+ my @caller_info = caller($caller_level);
+ $metadata{filename} = $caller_info[1];
+ $metadata{line} = $caller_info[2];
+
+ @caller_info = caller($caller_level + 1);
+ $metadata{method} = $caller_info[3];
+ $metadata{method} =~ s/^${package}:://;
+
foreach my $logger ($self->_get_loggers(%metadata)) {
$logger->$level([ $generator->(@args) ], \%metadata);
}