NAME

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

SYNOPSIS

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

# Note: you MUST compose these seperately (due to a bug in Moose right now)
#       and in this order (so that the stringify method is present before it's required)
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 /],
};
with 'Log::Message::Structured';

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

... elsewhere ...

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

$logger->log(message => Event->new( foo => "ONE MILLION", bar => "ONE BILLION" ));
# Logs:
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.