Wrapper around lager logger which limits the volume of info messages irrespectively of the lager's backend.
The calls chokecherry:info
, chokecherry:warning
, chokecherry:error
are getting translated into
the lager:info
, lager:warning
, lager:error
, retaining the proper arity.
There are two ways to log out the original module's name and the invocation process' Pid:
-
Use the compiler option right inside the file which uses the
chockecherry
:-compile([{parse_transform, chokecherry_transform}]).
Important: that line should precede this one:
-compile([{parse_transform, lager_transform}]).
-
Use that compiler option in the global
rebar.config
for the project:{erl_opts, [ % ... {parse_transform, chokecherry_transform}, {parse_transform, lager_transform} % ... }.
Important: the
chokecherry_transform
should precede thelager_transform
.
This application can be somewhat customized by redefining the following settings:
- the queue length for the shaper;
- timeout for the shaper.
Default settings are as follows:
[
{chokecherry, [
{shaper, [
{timeout, 1000},
{log_queue_capacity, 10000}
]}
]}
].
+------------+ +------------+ +------------+ +------------+
| | | | | | | |
| app +-----> shaper +-----> writer +-----> lager |
| | | | | | | |
+------------+ +------------+ +------------+ +------------+
shaper
accumulates incoming messages in the queue. If the queue size exceeds log_queue_capacity
within a certain time period (1 second), it sends an error_report
“chokecherry dropped N messages in the last second”,
and drops messages from the end of the queue, while receiving new ones and maintaining the maximum size of the queue.
writer
pulls messages from shaper
and transmits them to lager
.
- Simplify logic in
chokecherry_shaper
andchokecherry_writer
. - Configuration parameter
{writer, [{timeout, 200}]
doesn't need anymore.
- Added
chokecherry_shaper_logger
shaped messagesgen_event
manager.