package Mojo::Log::JSON;
use Mojo::Base 'Mojo::Log';
our $VERSION = '0.04';
has codec => sub {
require JSON::MaybeXS;
JSON::MaybeXS->new->indent(0)->utf8->canonical;
};
has include_level =
ncoding utf-8
=head1 NAME
Mojo::Log::JSON - Simple JSON logger
=head1 SYNOPSIS
use Mojo::Log::JSON;
# Log to STDERR
my $logger = Mojo::Log::JSON->new;
# Customize log file locati
on, minimum log level and default fields
my $logger = Mojo::Log::JSON->new( #
path => '/var/log/mojo.log',
level => 'warn',
default_fields => {
package Mojo::Log::JSON::LogStash;
use Mojo::Base 'Mojo::Log::JSON';
use Time::HiRes qw/ gettimeofday /;
our $VERSION = '0.04';
has default_fields => sub {
{ '@version' => 1,
'@tim
ding utf-8
=head1 NAME
Mojo::Log::JSON::LogStash - Simple JSON logger to produce LogStash format logs
=head1 SYNOPSIS
package MyApp;
use Mojo::Log::JSON::LogStash;
sub startup {
fig.conf'
or die "can't run logstash-forwarder: $!";
my $logger = Mojo::Log::JSON::LogStash->new( handle => $handle );
$logger->default_fields->{foo} = "bar"; # add ex