Log::Message::Structured::Component::Hostname
Log::Message::Structured::Stringify::AsJSON
/;
has foo => ( is => 'ro', required => 1 );
... elsewhere ...
use aliased 'My
either pass around in your application, log in a traditional
manor as a log line, or serialize to JSON or YAML for transmission over the
network.
=head1 COMPONENTS
The consuming class can include co
m L<Log::Message::Structured::Stringify::Sprintf>
=item L<Log::Message::Structured::Stringify::AsJSON>
=item L<Log::Message::Structured::Stringify::AsYAML>
=back
=head1 AUTHOR AND COPYRIGHT
Tomas
package Log::Message::Structured::Stringify::AsJSON;
use Moose::Role;
use namespace::autoclean;
use JSON::Any;
use utf8 ();
requires 'as_hash';
around 'as_string' => sub {
my $orig = shift;
as_hash;
my $json = JSON::Any->objToJson( $hashref );
utf8::decode($json) if !utf8::is_utf8($json) and utf8::valid($json); # if it's valid utf8 mark it as such
return $json;
};
1;
__END
__
=pod
=head1 NAME
Log::Message::Structured::Stringify::AsJSON - JSON log lines
=head1 SYNOPSIS
package MyLogEvent;
use Moose;
use namespace::autoclean;
with qw/
Log::Me