View Source RamoopsLogger (ramoops_logger v0.3.1)

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

@type 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

@spec available_log?() :: boolean()

Check to see if there a log

@spec dump() :: :ok | {:error, File.posix()}

Dump the contents of the ramoops pstore file to the console

@spec 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.

@spec 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.