preaction / Log-Any

Simple, fast Perl logging API compatible with any logging system
Other
13 stars 19 forks source link

Log::Any::Adapter::Multiplex doesn't print structured data to adapter #83

Open jenzajon opened 3 years ago

jenzajon commented 3 years ago

When logging structured data, Log::Any::Adapter::Multiplex's "structured" subroutine will use "_unstructured_log_args" to create an arrayref of the message and the stringified structured data. But, an adapter like Log::Any::Adapter::Stdout will only grab the first element as the $text. Comparing Log::Any::Adapter::Multiplex and Log::Any::Proxy, it looks like there needs to be a join with spaces in "structured" before passing on to the adapter's subroutine.

jenzajon commented 3 years ago

Example showing incorrect behavior:

#!perl
use strict;
use warnings;
use Log::Any qw( $log );
use Log::Any::Adapter;
use Log::Any::Adapter::Stdout;

Log::Any::Adapter->set( 'Multiplex', adapters => { 'Stdout' => [ log_level => 'debug' ] } );

$log->info( 'record: ', { id_no => 123456 } );

exit;

Incorrect behavior result:

record:

Example showing expected Stdout behavior:

#!perl
use strict;
use warnings;
use Log::Any qw( $log );
use Log::Any::Adapter;
use Log::Any::Adapter::Stdout;

Log::Any::Adapter->set( 'Stdout', log_level => 'info' );

$log->info( 'record: ', { id_no => 123456 } );

exit;

Result:

record:  {id_no => 123456}