Timber v3.0.0-alpha.2 Timber View Source
The functions in this module are high level convenience functions instended to define the broader / public API of the Timber library. It is recommended to use these functions instead of their deeper counterparts.
Link to this section Summary
Types
The target context to perform the operation
Functions
Adds context which will be included on log entries
Captures the duration in fractional milliseconds since the timer was started. See
start_timer/0
Removes a context key
Used to time runtime execution. For example, when timing a Timber.Events.HTTPResponseEvent
Link to this section Types
The target context to perform the operation.
:global
- This stores the context at a global level, meaning it will be present on every log line, regardless of which process generates the log line.:local
- This stores the context in the Logger Metadata which is local to the process
Link to this section Functions
add_context(Timber.Context.element(), context_location()) :: :ok
Adds context which will be included on log entries
The second parameter indicates where you want the context to be
stored. See context_location
for more details.
Captures the duration in fractional milliseconds since the timer was started. See
start_timer/0
.
remove_context_key(atom(), context_location()) :: :ok
Removes a context key.
The second parameter indicates which context you want the key to be removed from.
Used to time runtime execution. For example, when timing a Timber.Events.HTTPResponseEvent
:
timer = Timber.start_timer()
# .... make request
time_ms = Timber.duration_ms(timer)
event = HTTPResponseEvent.new(status: 200, time_ms: time_ms)
message = HTTPResponseEvent.message(event)
Logger.info(message, event: event)