Log::Message::Structured::Stringify::Sprintf - Traditional style log lines
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".
Augments the as_string method provided by Log::Message::Structured as a parameterised Moose role.
as_string
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>. Damien Krotkine (dams) <dams@cpan.org>.
<bobtfish@bobtfish.net>
<dams@cpan.org>
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.