gelato v0.2.0 Gelato View Source
Gelato
is a opinionated logger backend
helper library to log events with telemetry
attached.
It is to be configured in config.exs
in the following way:
config :gelato,
uri: "http://127.0.0.1:9200",
events: [:app, :lib],
handler: :elastic
config :logger,
backends: [Gelato.Logger.Backend],
level: :debug
and might be used normally as a usual logger backend
Logger.info "users", name: "John", reference: "U-123456789"
Basically, it logs the payload with the telemetry attached to the configured ElasticSearch instance. The telemetry includes some process information by default, besides monotonic time and some additional parameters.
The process info data might be altered or switched off by passing :process_info
keyword parameter in call to Logger.log/3
. true
value (default) would
collect and store the current process info; any other value would be passed through
as is.
level
parameter is one of:debug | :info | :warn | :error
message
is mapped to ElasticSearch index when passed; possible values must be configured inconfig.exs
file in the list of telemetry eventspayload
is a keyword list to be passed to Elastic
Also it supports benchmarking with Elixir.Gelato.bench/4
. The latter will
execute the block passed to the function, surrounded with two calls to
Logger.log/3
to collect some additional info about this particular
block execution.
By default all the logger methods would attach process_info
to the events
sent to Elastic to alter / discard this pass process_info: SOMETHING
to
the call to all the exported functions’ payload. Unless SOMETHING
is true
,
this value will be used instead of real process info.
Link to this section Summary
Functions
Similar to Logger.log/3
but accepts a block.
Link to this section Functions
bench(level, tag \\ nil, entity, payload_and_do_block)
View Source (macro)bench( level :: Logger.level(), tag :: atom(), entity :: entity(), payload_and_do_block :: keyword() ) :: any()
Similar to Logger.log/3
but accepts a block.
The block will be executed, surrounded by calls to log
and the
telemetry data will be accumulated in the latter call.