CandleClock.ErrorLogger (candle_clock v1.4.0) View Source
Link to this section Summary
Functions
Formats the given error using Exception.format/3
.
Returns if the environment is within a catch or rescue clause.
Formats and logs the given error using Exception.format/3
and Logger.error/1
.
Formats and logs the given error
of the given kind
with an optional preceding message
.
Like log_error/3
, but is used to log caught exits.
Logs a formatted error with an optional preceding message.
Like log_error/3
, but also puts the givenmessage
before the formatted error.
Link to this section Types
Link to this section Functions
Formats the given error using Exception.format/3
.
Adds the current stack trace, if available.
Specs
in_catch?(Macro.Env.t()) :: boolean()
Returns if the environment is within a catch or rescue clause.
Use it like this in a macro:
defmacro maybe_get_stacktrace() do
if in_catch?(__CALLER__) do
quote do __STACKTRACE__ end
else
quote do [] end
end
end
Formats and logs the given error using Exception.format/3
and Logger.error/1
.
Depending on from where this macro is called, it will also include the stacktrace that was recorded with the error in the log message.
error
can be anything, special formatting will be done for certain Erlang error atoms or tuples,
as well as Elixir exceptions.
log_level
(default :error
) can be overwritten to log in a different level
metadata
optional metadata passed into the Logger
log_error_raw(message, kind, error, log_level \\ :error, metadata \\ [])
View Source (macro)Formats and logs the given error
of the given kind
with an optional preceding message
.
log_exit(error, pid \\ nil, log_level \\ :error, metadata \\ [])
View Source (macro)Like log_error/3
, but is used to log caught exits.
When the pid is given, it will pass {:EXIT, pid}
instead of :exit
to Exception.format/3
.
log_formatted(formatted, message, level \\ :error, metadata \\ [])
View SourceSpecs
log_formatted( binary(), message(), level :: Logger.level(), metadata :: Logger.metadata() ) :: no_return()
Logs a formatted error with an optional preceding message.
log_message_and_error(message, error, log_level \\ :error, metadata \\ [])
View Source (macro)Like log_error/3
, but also puts the givenmessage
before the formatted error.