Generic Logging
DataAxesFormats.GenericLogging
—
Module
Generic macros and functions for logging, that arguably should belong in a more general-purpose package.
We do not re-export the macros and functions defined here from the top-level
DataAxesFormats
namespace. That is, even if
using DataAxesFormats
, you will
not
have these generic names polluting your namespace. If you do want to reuse them in your code, explicitly write
using DataAxesFormats.GenericLogging
.
DataAxesFormats.GenericLogging.setup_logger
—
Function
setup_logger(
io::IO = stderr;
[level::LogLevel = Warn,
show_time::Bool = true,
show_module::Bool = true,
show_location::Bool = false]
)::Nothing
Setup a global logger that will print into
io
, printing messages with a timestamp prefix.
By default, this will only print warnings. Note that increasing the log level will apply to
everything
. An alternative is to set up the environment variable
JULIA_DEBUG
to a comma-separated list of modules you wish to see the debug messages of.
If
show_time
, each message will be prefixed with a
yyyy-dd-mm HH:MM:SS.sss
timestamp prefix.
If
show_module
, each message will be prefixed with the name of the module emitting the message.
If
show_location
, each message will be prefixed with the file name and the line number emitting the message.
When multi-processing is used, a
P<id>:
process index is added to the log entries. When multi-threading is used, a
T<id>:
thread index is added to the log entries, as well as a
K<id>:
task index. To generate the latter, this stores a unique
:task_id
index in the
task_local_storage
. This is important since a task may migrate between threads.
DataAxesFormats.GenericLogging.@logged
—
Macro
@logged function something(...)
return ...
end
Automatically log (in
Debug
level) every invocation to the function. This will also log the values of the arguments. Emits a second log entry when the function returns, with the result (if any).