Timber v2.0.0-rc1 Timber.LoggerBackends.HTTP
Provides a logger backend that dispatches logs via HTTP
The HTTP backend buffers and delivers log messages over HTTP to the Timber API. It uses batching and msgpack to deliver logs with high-throughput and little overhead.
Messages are always written to the buffer first. The buffer is only drained when it reaches its maximum allowed size or a specified amount of time has elapsed. This balances output with batching so that logs are sent even when the application doesn’t produce enough logs to fill the buffer.
The maximum allowed size of the buffer can be controlled with the :max_buffer_size
configuration
value.
All outgoing requests are made asynchronously. If a second request is made while the previous (first) request is still being processed, then the transport will enter synchronous mode, waiting for a response before proceeding with the request. Synchronous mode will cause any logging calls to block until the request completes.
Configuration
Custom HTTP client
The HTTP backend can use any HTTP client, so long as it supports asynchronous requests.
Suport for :hackney
is built into the library and is the default client, supported via
Timber.Transports.HTTP.HackneyClient
. You can define your own custom HTTP client by adhering
to the Timber.Transports.HTTP.Client
behaviour. Afterwards, you must specify your client
in the configuration:
config :timber, :http_client, MyHTTPClient
Summary
Types
The level of a log event is described as an atom
The message for a log event is given as IO.chardata. It is important not
to assume the message will be a String.t/0
The precision of the microsecond represents the precision with which the fractional seconds are kept
A representation of stateful data for this module
Time is represented both to the millisecond and to the microsecond with precision
Types
The level of a log event is described as an atom
The message for a log event is given as IO.chardata. It is important not
to assume the message will be a String.t/0
The precision of the microsecond represents the precision with which the fractional seconds are kept.
See Calendar.microsecond/0
for more information.
A representation of stateful data for this module
min_level
The minimum level to be logged. The Elixir Logger
module typically
handle filtering the log level, however this is a stop-gap for direct
testing as well as any custom levels.
time :: {hour, minute, second, millisecond} | {hour, minute, second, {microsecond, precision}}
Time is represented both to the millisecond and to the microsecond with precision.