1Log::ger(3) User Contributed Perl Documentation Log::ger(3)
2
3
4
6 Log::ger - A lightweight, flexible logging framework
7
9 version 0.023
10
12 In your module (producer):
13
14 package Foo;
15 use Log::ger; # will import some logging methods e.g. log_warn, log_error
16
17 sub foo {
18 ...
19 # produce some logs
20 log_error "an error occurred: %03d - %s", $errcode, $errmsg;
21 ...
22 log_debug "http response: %s", $http; # automatic dumping of data
23 }
24 1;
25
26 In your application (consumer/listener):
27
28 use Foo;
29 use Log::ger::Output 'Screen';
30
31 foo();
32
34 Log::ger is yet another logging framework with the following features:
35
36 · Separation of producers and consumers/listeners
37
38 Like Log::Any, this offers a very easy way for modules to produce
39 some logs without having to configure anything. Configuring output,
40 level, etc can be done in the application as log
41 consumers/listeners. To read more about this, see the documentation
42 of Log::Any or Log::ger::Manual (but nevertheless see
43 Log::ger::Manual on why you might prefer Log::ger to Log::Any).
44
45 · Lightweight and fast
46
47 Slim distribution. No non-core dependencies, extra functionalities
48 are provided in separate distributions to be pulled as needed.
49
50 Low startup overhead. Only ~0.5-1ms. For comparison, strict
51 ~0.2-0.5ms, warnings ~2ms, Log::Any 0.15 ~2-3ms, Log::Any 1.049
52 ~8-10ms, Log::Log4perl ~35ms. This is measured on a 2014-2015 PC
53 and before doing any output configuration. For more benchmarks, see
54 Bencher::Scenarios::LogGer or try yourself e.g. with bencher-code:
55
56 % bencher-code 'use Log::ger' 'use Log::Any' --startup
57
58 Fast. Low null-/stealth-logging overhead, about 1.5x faster than
59 Log::Any, 3x faster than Log4perl, and 5x faster than Log::Fast.
60
61 Conditional compilation. There is a plugin to optimize away
62 unneeded logging statements, like assertion/conditional
63 compilation, so they have zero runtime performance cost. See
64 Log::ger::Plugin::OptAway.
65
66 Being lightweight means the module can be used more universally,
67 from CLI to long-running daemons to inside routines with tight
68 loops.
69
70 · Flexible
71
72 Customizable levels and routine/method names. Can be used in a
73 procedural or OO style. Log::ger can mimic the interface of
74 Log::Any, Log::Contextual, Log::Log4perl, or some other popular
75 logging frameworks, to ease migration or adjust with your personal
76 style.
77
78 Per-package settings. Each importer package can use its own
79 format/layout, output. For example, some modules that are migrated
80 from Log::Any uses Log::Any-style logging, while another uses
81 native Log::ger style, and yet some other uses block formatting
82 like Log::Contextual. This eases code migration and teamwork. Each
83 module author can preserve her own logging style, if wanted, and
84 all the modules still use the same framework.
85
86 Dynamic. Outputs and levels can be changed anytime during run-time
87 and logging routines will be updated automatically. This is useful
88 in situation like a long-running server application: you can turn
89 on tracing logs temporarily to debug problems, then turn them off
90 again, without restarting your server.
91
92 Interoperability. There are modules to interop with Log::Any,
93 either consume Log::Any logs (see Log::Any::Adapter::LogGer) or
94 produce logs to be consumed by Log::Any (see
95 Log::ger::Output::LogAny).
96
97 Many output modules and plugins. See "Log::ger::Output::*",
98 "Log::ger::Format::*", "Log::ger::Layout::*",
99 "Log::ger::Plugin::*". Writing an output module in Log::ger is
100 easier than writing a Log::Any::Adapter::*.
101
102 For more documentation, start with Log::ger::Manual.
103
105 Some other popular logging frameworks: Log::Any, Log::Contextual,
106 Log::Log4perl, Log::Dispatch, Log::Dispatchouli.
107
109 perlancar <perlancar@cpan.org>
110
112 This software is copyright (c) 2017 by perlancar@cpan.org.
113
114 This is free software; you can redistribute it and/or modify it under
115 the same terms as the Perl 5 programming language system itself.
116
117
118
119perl v5.28.0 2017-08-03 Log::ger(3)