1Log::Contextual::TeeLogUgseerr(3C)ontributed Perl DocumeLnotga:t:iCoonntextual::TeeLogger(3)
2
3
4

NAME

6       Log::Contextual::TeeLogger - Output to more than one logger
7

VERSION

9       version 0.008001
10

SYNOPSIS

12        use Log::Contextual::SimpleLogger;
13        use Log::Contextual::TeeLogger;
14        use Log::Contextual qw( :log ),
15          -logger => Log::Contextual::TeeLogger->new({ loggers => [
16            Log::Contextual::SimpleLogger->new({ levels => [ 'debug' ] }),
17            Log::Contextual::SimpleLogger->new({
18              levels => [ 'info' ],
19              coderef => sub { print @_ },
20            }),
21          ]});
22
23        ## docs below here not yet edited
24
25        log_info { 'program started' }; # no-op because info is not in levels
26        sub foo {
27          log_debug { 'entered foo' };
28          ...
29        }
30

DESCRIPTION

32       This module is a simple logger made mostly for demonstration and
33       initial experimentation with Log::Contextual.  We recommend you use a
34       real logger instead.  For something more serious but not overly
35       complicated, take a look at Log::Dispatchouli.
36

METHODS

38   new
39       Arguments: "Dict[ levels => ArrayRef[Str], coderef => Optional[CodeRef]
40       ] $conf"
41
42        my $l = Log::Contextual::SimpleLogger->new({
43          levels => [qw( info warn )],
44          coderef => sub { print @_ }, # the default prints to STDERR
45        });
46
47       Creates a new SimpleLogger object with the passed levels enabled and
48       optionally a "CodeRef" may be passed to modify how the logs are
49       output/stored.
50
51       Levels may contain:
52
53        trace
54        debug
55        info
56        warn
57        error
58        fatal
59
60   $level
61       Arguments: @anything
62
63       All of the following six methods work the same.  The basic pattern is:
64
65        sub $level {
66          my $self = shift;
67
68          print STDERR "[$level] " . join qq{\n}, @_;
69             if $self->is_$level;
70        }
71
72       trace
73
74        $l->trace( 'entered method foo with args ' join q{,}, @args );
75
76       debug
77
78        $l->debug( 'entered method foo' );
79
80       info
81
82        $l->info( 'started process foo' );
83
84       warn
85
86        $l->warn( 'possible misconfiguration at line 10' );
87
88       error
89
90        $l->error( 'non-numeric user input!' );
91
92       fatal
93
94        $l->fatal( '1 is never equal to 0!' );
95
96       Note: "fatal" does not call "die" for you, see "EXCEPTIONS AND ERROR
97       HANDLING" in Log::Contextual
98
99   is_$level
100       All of the following six functions just return true if their respective
101       level is enabled.
102
103       is_trace
104
105        say 'tracing' if $l->is_trace;
106
107       is_debug
108
109        say 'debuging' if $l->is_debug;
110
111       is_info
112
113        say q{info'ing} if $l->is_info;
114
115       is_warn
116
117        say 'warning' if $l->is_warn;
118
119       is_error
120
121        say 'erroring' if $l->is_error;
122
123       is_fatal
124
125        say q{fatal'ing} if $l->is_fatal;
126

AUTHOR

128       Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
129
131       This software is copyright (c) 2018 by Arthur Axel "fREW" Schmidt.
132
133       This is free software; you can redistribute it and/or modify it under
134       the same terms as the Perl 5 programming language system itself.
135
136
137
138perl v5.32.0                      2020-07-28     Log::Contextual::TeeLogger(3)
Impressum