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.028
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. I strive to make "use
54 Log::ger;" statement to be roughly as light as "use strict;" or
55 "use warnings;" so the impact of adding the statement is really
56 minimal and you can just add logging without much thought to most
57 of your modules. This is important to me because I want logging to
58 be pervasive.
59
60 To test for yourself, try e.g. with bencher-code:
61
62 % bencher-code 'use Log::ger' 'use Log::Any' --startup
63
64 Fast. Low null-/stealth-logging overhead, about 1.5x faster than
65 Log::Any, 3x faster than Log4perl, 5x faster than Log::Fast, ~40x
66 faster than Log::Contextual, and ~100x faster than Log::Dispatch.
67
68 For more benchmarks, see Bencher::Scenarios::LogGer.
69
70 Conditional compilation. There is a plugin to optimize away
71 unneeded logging statements, like assertion/conditional
72 compilation, so they have zero runtime performance cost. See
73 Log::ger::Plugin::OptAway.
74
75 Being lightweight means the module can be used more universally,
76 from CLI to long-running daemons to inside routines with tight
77 loops.
78
79 · Flexible
80
81 Customizable levels and routine/method names. Can be used in a
82 procedural or OO style. Log::ger can mimic the interface of
83 Log::Any, Log::Contextual, Log::Log4perl, or some other popular
84 logging frameworks, to ease migration or adjust with your personal
85 style.
86
87 Per-package settings. Each importer package can use its own
88 format/layout, output. For example, a module that is migrated from
89 Log::Any uses Log::Any-style logging, while another uses native
90 Log::ger style, and yet some other uses block formatting like
91 Log::Contextual. This eases code migration and teamwork. Each
92 module author can preserve her own logging style, if wanted, and
93 all the modules still use the same framework.
94
95 Dynamic. Outputs and levels can be changed anytime during run-time
96 and logging routines will be updated automatically. This is useful
97 in situation like a long-running server application: you can turn
98 on tracing logs temporarily to debug problems, then turn them off
99 again, without restarting your server.
100
101 Interoperability. There are modules to interop with Log::Any,
102 either consume Log::Any logs (see Log::Any::Adapter::LogGer) or
103 produce logs to be consumed by Log::Any (see
104 Log::ger::Output::LogAny).
105
106 Many output modules and plugins. See "Log::ger::Output::*",
107 "Log::ger::Format::*", "Log::ger::Layout::*",
108 "Log::ger::Plugin::*". Writing an output module in Log::ger is
109 easier than writing a Log::Any::Adapter::*.
110
111 For more documentation, start with Log::ger::Manual.
112
114 Some other popular logging frameworks: Log::Any, Log::Contextual,
115 Log::Log4perl, Log::Dispatch, Log::Dispatchouli.
116
117 If you still prefer debugging using the good old "print()", there's
118 Debug::Print.
119
121 perlancar <perlancar@cpan.org>
122
124 This software is copyright (c) 2019, 2018, 2017 by perlancar@cpan.org.
125
126 This is free software; you can redistribute it and/or modify it under
127 the same terms as the Perl 5 programming language system itself.
128
129
130
131perl v5.30.0 2019-07-26 Log::ger(3)