Log Functions

emergency()

Logs an “emergency” level message.

emergency("External power supply is unavailable")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

alert()

Logs an “alert” level message.

alert("Storage disk is above 90% full, cleanup is required")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

critical()

Logs a “critical” level message.

critical("Acme 3.7V Li-Po Battery Driver is unavailable, unable to continue build")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

error()

Log an “error” level message.

error("Acme LDSv6 Driver failed loading device.ini")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

warning()

Logs a “warning” level message.

warning("No configuration found for Acme VCMx Driver, using driver defaults")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

notice()

Logs a “notice” level message.

notice("Acme CPU32v6xx Power Control Driver build completed")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

info()

Log an “info” level message.

info("Started building external system assets")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

debug()

Log a “debug” level message.

debug("Network: eth4, via pci@0004:01:00.0 (serial: e4:1d:2d:67:83:56)")

The following parameters are supported:

  • < message >
  • < mode >: (option)
  • CONTEXT: (optional)
  • OUTPUT: (optional)
  • LIST_SEPARATOR: (optional)

See log() function for parameter descriptions and examples.

log()

Log a message with an arbitrary level.

log(INFO_LEVEL "Removing expired tmp files from cache storage")

Behind the scene, log() uses the output() function to print messages to the console. It supports the following parameters:

  • < level >: The PSR log level (see RSP_LOG_LEVELS)
  • < message >: string, variable or list message to output.
  • < mode >: (option), cmake message mode, e.g. WARNING, NOTICE, STATUS, …etc. Defaults to the mode that is associated with the given log level (see RSP_LOG_LEVELS_CMAKE).
  • CONTEXT: (optional), Evt. variables to output in a “context” associated with the log message.
  • OUTPUT: (optional), output variable. If specified, message is assigned to variable, instead of being printed to stdout or stderr.
  • LIST_SEPARATOR: (optional), Separator to used, if a list variable is given as message. Defaults to \n (newline).

Mode

Unless you specify the cmake message mode, log() will automatically apply the mode that is associated with the specified PSR log level (defined by the RSP_LOG_LEVELS_CMAKE property).

Consequently, in situations when you need to deviate from the default associated mode, simply specify the desired message mode.

# Log a "warning" level message, but use a STATUS cmake message mode
log(WARNING_LEVEL "Config NOT found for VCMx Driver, using defaults" STATUS)

The above example will print a message similar to this:

-- warning: Config NOT found for VCMx Driver, using defaults
   Timestamp: 2025-02-05 11:33:32.190620

Context

The CONTEXT parameter allows you to associate one or more variables with the given log entry.

log(
    NOTICE_LEVEL "Assets build completed"
    CONTEXT
        assets_dir
        my_assets_list
)

The above shown example will print a message similar to this:

notice: Assets build completed
   Context: 
   [
      assets_dir = build/resources/config
      my_assets_list = graft.conf;ports.init;power.json
   ]
   Timestamp: 2025-02-05 11:08:40.912747

Timestamp

By default, a timestamp is appended at the end of each logged message. You can modify this behaviour, and the timestamp format by changing the following predefined properties:

Property Default Description
RSP_LOG_SHOW_TIMESTAMP true State whether to append timestamp for log entries, or not
RSP_LOG_TIMESTAMP_FORMAT %Y-%m-%d %H:%M:%S.%f Timestamp format. See CMake documentation for details.
RSP_LOG_TIMESTAMP_UTC false True if timestamp is UTC, false if timestamp is local

Note

Properties should be set before you include the rsp/logging module or by force caching the property.

Output

See “Capture Output“ for additional information about the OUTPUT parameter.

Lists

See output “Lists” for additional information about the LIST_SEPARATOR parameter.