slogger2

System logger

Syntax:

slogger2 [-b buffer_set[,buffer_set...]] [-c] [-p pid] 
         [-U user_name | uid[:gid[,sup_gid]*]]]
         [-v[v]...]

Runs on:

QNX Neutrino

Targets:

ARM, x86

Options:

-b buffer_set[,buffer_set...]
Specify the buffer sets to clear with the -c option.
-c
Clear the log buffers. If you specify the -b, only those buffers are cleared; otherwise, all buffers are cleared.
-p pid
(Debugging only) Run as the given client process ID.
-U user_name
-U uid[:gid[,sup_gid]*]]
Once running, run as the specified user, so that the program doesn't need to run as root:
  • In the first form, the service sets itself to be the named user and uses that user's groups. This form depends on the /etc/passwd and /etc/group files.
  • In the second form, the service sets its user ID, and optionally its group ID and supplementary groups, to the values provided.
-v[v]...
Be verbose; more v characters cause more verbosity.

Description:

The slogger2 daemon is the central manager of a system-logging framework that overcomes various limitations of the legacy slogger system. The primary goals for slogger2 are to:

The components of the system logger include:

libslog2, <slog2.h>
The library and header file for the API.
slogger2
The daemon process that's responsible for:
  • allocating buffers for each process
  • maintaining buffers (cleaning up buffers when processes die, etc.)
  • controlling verbosity
  • gathering logs
  • providing a means for other components to consume the logs
libslog2parse
A library that supports log parsing by other tools (e.g., slog2info).
slog2info
The realtime device-side viewer. It can consume the live stream from slogger2, as well as parse (using libslog2parse) and display saved slog2 files.

Buffer Management

The central slogger2 process manages a region of shared RAM that's preserved across device resets. All slog2 buffers are located here and survive both process crashes and full device resets. This gives slog2 the performance benefit of writing to RAM (instead of to flash or disk) without losing logs in these scenarios. However, in the case of complete removal of power source (e.g., battery removal), any log contents in RAM will be lost.

Individual slog2 instances are allocated from this region by slogger2 and are provided to the client process, via slog2_register(), in the form of a shared memory file. The libslog2 library uses shmem_open() to access each instance.

Within each slog2 instance there may be up to four buffers defined by the client process. These buffers can be any combination of 4 KB pages. The primary intent for these buffers is to enable high-rate logging into one buffer, while preserving a longer history of low-rate logging in another.

Note: The intent isn't for every subcomponent in a client process to have its own buffer. Each buffer introduces overhead, both in memory management and in terms of log-streaming performance. The expectation is that it will be rare for more than two buffers in a single instance to be used. For extreme situations, the client process can register multiple slog2 instances to satisfy a need for additional buffers.

The central slogger2 process is responsible for cleaning up the slog2 instances, including calling the shmem_unlink() function to remove the shared memory file.

Severity, verbosity, and filtering

Each log line is assigned one of the following severity levels (listed here in decreasing order):

SLOG2_SHUTDOWN
Shut down the system now (e.g., for OEM use).
SLOG2_CRITICAL
Unexpected unrecoverable error (e.g., hard disk error).
SLOG2_ERROR
Unexpected recoverable error (e.g., you need to reset a hardware controller).
SLOG2_WARNING
Expected error (e.g., parity error on a serial port).
SLOG2_NOTICE
Warning (e.g., out of paper).
SLOG2_INFO
Information (e.g., printing page 3).
SLOG2_DEBUG1
Debug messages (e.g., normal detail).
SLOG2_DEBUG2
Debug messages (e.g., fine detail).

The verbosity level controls which log lines are written in the slog2 buffer; if the severity level is greater than the verbosity level, the line is written in the buffer.

Filtering controls which log items are displayed to the user; the log contents aren't affected. You could filter the log by using (for example) grep, slog2info, or a custom log viewer.