1Log::ger::Plugin::MultiUlseevrelCLoongt(r3i)buted Perl DLoocgu:m:egnetra:t:iPolnugin::MultilevelLog(3)
2
3
4
6 Log::ger::Plugin::MultilevelLog - Create a log($LEVEL, ...)
7 subroutine/method
8
10 version 0.037
11
13 use Log::ger::Plugin MultilevelLog => (
14 # sub_name => 'log_it', # optional, defaults to 'log'
15 # method_name => 'log_it', # optional, defaults to 'log'
16 # exclusive => 1, # optional, defaults to 0
17 );
18 use Log::ger;
19
20 log('warn', 'This is a warning');
21 log('debug', 'This is a debug, data is %s', $data);
22
24 The Log::ger default is to create separate "log_LEVEL" subroutine (or
25 "LEVEL" methods) for each level, e.g. "log_trace" subroutine (or
26 "trace" method), "log_warn" (or "warn"), and so on. But sometimes you
27 might want a log routine that takes $level as the first argument. That
28 is, instead of:
29
30 log_warn('blah ...');
31
32 or:
33
34 $log->debug('Blah: %s', $data);
35
36 you prefer:
37
38 log('warn', 'blah ...');
39
40 or:
41
42 $log->log('debug', 'Blah: %s', $data);
43
44 This plugin can create such log routine for you.
45
46 Note: the multilevel log is slightly slower because of the extra
47 argument and additional string level -> numeric level conversion. See
48 benchmarks in Bencher::Scenarios::LogGer.
49
50 Note: the individual separate "log_LEVEL" subroutines (or "LEVEL"
51 methods) are still installed, unless you specify configuration
52 "exclusive" to true.
53
55 sub_name
56 String. Defaults to "log".
57
58 method_name
59 String. Defaults to "log".
60
61 exclusive
62 Boolean. If set to true, will block the generation of the default
63 "log_LEVEL" subroutines or "LEVEL" methods (e.g. "log_warn", "trace",
64 ...).
65
67 Log::ger::Plugin::HashArgs
68
70 perlancar <perlancar@cpan.org>
71
73 This software is copyright (c) 2020, 2019, 2018, 2017 by
74 perlancar@cpan.org.
75
76 This is free software; you can redistribute it and/or modify it under
77 the same terms as the Perl 5 programming language system itself.
78
79
80
81perl v5.32.0 2020-07-28Log::ger::Plugin::MultilevelLog(3)