ramoops_logger v0.3.0 RamoopsLogger View Source

This is an in-memory backend for the Elixir Logger that can survive reboots.

Install it by adding it to your config.exs:

use Mix.Config

config :logger, backends: [:console, RamoopsLogger]

# The defaults
config :logger, RamoopsLogger,
  pmsg_path: "/dev/pmsg1",
  recovered_log_path: "/sys/fs/pstore/pmsg-ramoops-1"

Or add manually:

iex> Logger.add_backend(RamoopsLogger)
:ok
# Configure only if the defaults don't work on your system
iex> Logger.configure(RamoopsLogger, pmsg_path: "/dev/pmsg1")

After a reboot, you can check if a log exists by calling available_log?/0.

Link to this section Summary

Types

Options for configuring the backend

Functions

Check to see if there a log

Dump the contents of the ramoops pstore file to the console

Read the file contents from the ramoops pstore file. This is useful if you want to pragmatically do something with the file contents, like post to an external server.

Return the path to the recovered log

Link to this section Types

Link to this type

backend_option() View Source
backend_option() :: {:pmsg_path, Path.t()} | {:recovered_log_path, Path.t()}

Options for configuring the backend:

  • :pmsg_path - Path to pmsg device (default is /dev/pmsg0)
  • :recovered_log_path - Path to recovered log files from previous boots (default is /sys/fs/pstore/pmsg-ramoops-0)

These are either specified in the Application config (e.g., config.exs) like this:

config :logger, RamoopsLogger,
  pmsg_path: "/dev/pmsg1",
  recovered_log_path: "/sys/fs/pstore/pmsg-ramoops-1"

Or configured at runtime like:

iex> Logger.configure(RamoopsLogger, pmsg_path: "/dev/pmsg1")

Link to this section Functions

Link to this function

available_log?() View Source
available_log?() :: boolean()

Check to see if there a log

Link to this function

dump() View Source
dump() :: :ok | {:error, File.posix()}

Dump the contents of the ramoops pstore file to the console

Link to this function

read() View Source
read() :: {:ok, binary()} | {:error, File.posix()}

Read the file contents from the ramoops pstore file. This is useful if you want to pragmatically do something with the file contents, like post to an external server.

Link to this function

recovered_log_path() View Source
recovered_log_path() :: Path.t()

Return the path to the recovered log

The path won't exist if there was nothing to recover on boot.