New WALL log level: Pantavisor messages on the device console

Pantavisor master now has a new log level, WALL. It works like INFO, but the messages it covers are also printed on the device console. This landed in pantavisor#790.

Background

Pantavisor log messages normally go to its log files, and to stdout if that output is enabled. Reading them on the console of a device meant using stdout output, which is verbose. WALL gives you a level meant for what should be visible to whoever is watching the console.

WALL is placed right before INFO and has value 3. Anything logged at WALL is handled like INFO, and in addition it is mirrored to the console.

Console format

Console messages carry a timestamp taken from CLOCK_MONOTONIC, in the same format dmesg uses. That way Pantavisor messages and kernel messages line up on the console and can be read together. This is what a line looks like:

[    6.217276] [PANTAVISOR] [platforms] WALL: platform 'awconnect' status is now STARTING
Part Description
[ 6.217276] Time since boot, dmesg style.
[PANTAVISOR] Fixed tag that tells the line apart from kernel output.
[platforms] Pantavisor module that emitted the message.
WALL: Level name. ERROR and FATAL messages use the same format.
platform 'awconnect' status is now STARTING The message, without the function and line prefix.

Three new helpers are available to emit these messages from the code: pv_wall_log(), pv_wall_vlog() and pv_wall_v(). As a first use, the platform status reporting now logs container status changes through them.

Deduplication

If stdout output is enabled, Pantavisor already prints its messages there, so showing the WALL messages on the console as well would give you every line twice. To avoid that, when stdout is on no WALL message is printed on the console.

How to use it

Console alerts are enabled by default. To turn them off, set the new key in pantavisor.config:

PV_LOG_CONSOLE_ALERTS=0

WALL can also be selected through PV_LOG_LEVEL like any other level.

Heads up: numeric levels shift by one

Adding WALL before INFO moves every level from INFO upwards one position. If you set PV_LOG_LEVEL with a number in a custom config, you need to add 1 to keep the same behavior. For example, DEBUG was 4 and is now 5, and INFO was 3 and is now 4. Devices that do not set PV_LOG_LEVEL are not affected.

The change includes a test for the console messages and the deduplication, and the overview and reference docs are updated.

Availability

WALL and PV_LOG_CONSOLE_ALERTS are in Pantavisor master now. Feedback is welcome in this thread, especially on other messages you would like to see on the console.

1 Like