Created
January 30, 2014 10:14
-
-
Save mjemmeson/8705760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Mojo::Log::JSON; | |
use Mojo::Base 'Mojo::Log'; | |
use HTTP::Date qw/ time2iso /; | |
use JSON qw/ to_json /; | |
sub format { | |
my ( $self, $level, @lines ) = @_; | |
my %msg = ( | |
ref $lines[0] # | |
? %{ $lines[0] } # | |
: ( message => join( "\n", @lines ) ), | |
level => $level, | |
datetime => time2iso(), | |
); | |
return to_json( \%msg, { utf8 => 1, canonical => 1 } ) . "\n"; | |
} | |
1; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment