Damien Krotkine > Log-Message-Structured-0.012 > Log::Message::Structured::Stringify::Sprintf

Download:
Log-Message-Structured-0.012.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

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

SYNOPSIS ^

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

    with 'Log::Message::Structured';

    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 ^

Augments the as_string method provided 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>. Damien Krotkine (dams) <dams@cpan.org>.

LICENSE ^

Licensed under the same terms as perl itself.

syntax highlighting: