Log::Message::Structured::Stringify::Sprintf - Traditional style log lines
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".
Implelements the stringify method required by Log::Message::Structured as a parameterised Moose role.
stringify
Array of attributes whos values will be interpolated into the format string.
This format string is fed to sprintf with the values from the attributes to produce the output.
Tomas Doran (t0m) <bobtfish@bobtfish.net>.
<bobtfish@bobtfish.net>
Licensed under the same terms as perl itself.
To install Log::Message::Structured, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Message::Structured
CPAN shell
perl -MCPAN -e shell install Log::Message::Structured
For more information on module installation, please visit the detailed CPAN module installation guide.