File: log_message_structured.t

package info (click to toggle)
liblog-dispatch-message-passing-perl 0.009-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 280 kB
  • sloc: perl: 1,406; makefile: 9; sh: 4
file content (38 lines) | stat: -rw-r--r-- 890 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use strict;
use warnings;
use FindBin qw/ $Bin /;
use lib "$Bin/lib";

use Test::More;

BEGIN {
    plan skip_all => "Broken currently";
    plan skip_all => 'Need Log::Message::Structured'
        unless do { local $@; eval { require Log::Message::Structured } };
}

use JSON qw/ decode_json /;
use TestStorage;
use Log::Dispatch;
use Log::Dispatch::Message::Passing;
use Message::Passing::Output::Test;

my $log = Log::Dispatch->new;

my $test = Message::Passing::Output::Test->new;

$log->add(Log::Dispatch::Message::Passing->new(
    name      => 'myapp_logstash',
    min_level => 'debug',
    output     => $test,
));
$log->warn(TestStorage->new(foo => "bar"));

is $test->message_count, 1;
my ($msg) = $test->messages;
my $data = decode_json(delete($msg->{message}));
is_deeply $msg, {level => 'warn', name => 'myapp_logstash'};
is $data->{__CLASS__}, 'TestStorage';

done_testing;