NervesHubLink.Logger (nerves_hub_link_atomvm_esp32_ex v0.1.2)

Copy Markdown View Source

Logging that does not kill the process that logged.

AtomVM's :logger accepts a list or a map and raises badarg on anything else, before any handler sees the event. Elixir strings are binaries, so the most natural line an Elixir developer can write is the one that crashes:

:logger.info("started")   # badarg, and the caller dies

This converts a binary to a charlist and passes everything else through.

require NervesHubLink.Logger, as: Log
Log.info("started")
Log.warning(%{event: :retrying, attempt: 3})

It is :logger underneath, so :nh_logger picks these up like any other event and sends them to NervesHub. Nothing here talks to the agent, which is why it works before the agent exists and keeps working if it dies.

For a line that should reach NervesHub whatever :logger is configured to do, NervesHubLink.send_log/4 sends one directly.

Summary

Functions

Log at alert.

Log at alert, with a format string and arguments.

Log at critical.

Log at critical, with a format string and arguments.

Log at debug.

Log at debug, with a format string and arguments.

Log at emergency.

Log at emergency, with a format string and arguments.

Log at error.

Log at error, with a format string and arguments.

Log at info.

Log at info, with a format string and arguments.

Log at a level chosen at runtime.

Log at notice.

Log at notice, with a format string and arguments.

What :logger will actually be given.

Log at warning.

Log at warning, with a format string and arguments.

Functions

alert(message)

Log at alert.

alert(format, args)

Log at alert, with a format string and arguments.

critical(message)

Log at critical.

critical(format, args)

Log at critical, with a format string and arguments.

debug(message)

Log at debug.

debug(format, args)

Log at debug, with a format string and arguments.

emergency(message)

Log at emergency.

emergency(format, args)

Log at emergency, with a format string and arguments.

error(message)

Log at error.

error(format, args)

Log at error, with a format string and arguments.

info(message)

Log at info.

info(format, args)

Log at info, with a format string and arguments.

log(level, message)

Log at a level chosen at runtime.

log(level, format, args)

notice(message)

Log at notice.

notice(format, args)

Log at notice, with a format string and arguments.

safe(message)

What :logger will actually be given.

Public because it is the whole point of this module, and asserting on it is more honest than asserting on the shape a particular logger hands a handler: AtomVM's and OTP's differ, and the device runs AtomVM's.

warning(message)

Log at warning.

warning(format, args)

Log at warning, with a format string and arguments.