NAME

Log::Message::Structured::Stringify::Sprintf - Traditional style log lines

SYNOPSIS

package MyLogEvent;
use Moose;
use namespace::autoclean;

has [qw/ foo bar /] => ( is => 'ro', required => 1 );

# Note: you MUST compose these together and after defining your attributes!
with 'Log::Message::Structured::Stringify::Sprintf' => {
    format_string => q{The value of foo is "%s" and the value of bar is "%s"},
    attributes => [qw/ foo bar /],
}, 'Log::Message::Structured';

... elsewhere ...

use aliased 'My::Log::Event';

$logger->log(Event->new( foo => "ONE MILLION", bar => "ONE BILLION" ));
# Logs an object which will stringify to:
The value of foo is "ONE MILLION" and the value of bar is "ONE BILLION".

DESCRIPTION

Implelements the stringify method required by Log::Message::Structured as a parameterised Moose role.

PARAMETERS

attributes

Array of attributes whos values will be interpolated into the format string.

format_string

This format string is fed to sprintf with the values from the attributes to produce the output.

AUTHOR AND COPYRIGHT

Tomas Doran (t0m) <bobtfish@bobtfish.net>.

LICENSE

Licensed under the same terms as perl itself.