View Source NervesLogging.KmsgParser (nerves_logging v0.2.2)

Functions for parsing kmsg strings

Summary

Functions

Parse out the kmsg facility, severity, and message (including the timestamp and host) from a kmsg-formatted string.

Functions

@spec parse(String.t()) ::
  {:ok,
   %{
     facility: NervesLogging.SyslogParser.facility(),
     severity: NervesLogging.SyslogParser.severity(),
     message: String.t(),
     timestamp: integer(),
     sequence: integer(),
     flags: [atom()]
   }}
  | {:error, :parse_error}

Parse out the kmsg facility, severity, and message (including the timestamp and host) from a kmsg-formatted string.

See https://elixir.bootlin.com/linux/latest/source/Documentation/ABI/testing/dev-kmsg for full details.

Most messages are of the form:

priority,sequence,timestamp,flag;message

priority is an integer that when broken apart gives you a facility and severity. sequence is a monotonically increasing counter timestamp is the time in microseconds flag is almost always - message is everything else

This parser only supports the minimum kmsg reports. The spec above describes more functionality, but it appears to be uncommon and I haven't seen any examples yet in my testing.