Log::Message::Structured::Stringify::AsJSON - JSON log lines
package MyLogEvent; use Moose; use namespace::autoclean; # Note: you MUST compose these together as they depend on methods in each other with qw/ Log::Message::Structured Log::Message::Structured::Stringify::AsJSON /; has foo => ( is => 'ro', required => 1 ); ... elsewhere ... use aliased 'My::Log::Event'; $logger->log(message => Event->new( foo => "bar" )); # Logs: {"__CLASS__":"MyLogEvent","foo":1,"date":"2010-03-28T23:15:52Z","hostname":"mymachine.domain"}
Implelements the stringify method required by Log::Message::Structured, by delegateing to the freeze method provided by Log::Message::Structured, and thus returning a JSON string.
stringify
freeze
Calls the freeze method (provided by Log::Message::Structured to return JSON.
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.