Skip to main content

debug

Macro debug 

Source
debug!() { /* proc-macro */ }
Expand description

Log a debug message as a Copper structured log entry.

Accepted forms:

  • debug!("message {}", value)
  • debug!(ctx, "message {}", value)

When a CuContext is passed as the first argument, the emitted structured log entry also captures the current Copper callback origin:

  • culistid
  • component_id
  • task_index when the callback is running inside a task

The message argument must be a string literal. Only {} placeholders are supported. Remaining arguments can be unnamed expressions or named fields written as name = value.

§Example

use cu29_log_derive::debug;
let a = 1;
let b = 2;
debug!("a = {}, b = {}", my_value = a, b); // named and unnamed parameters

debug!(ctx, "processing {}", b); // same log plus runtime origin metadata

You can retrieve this data using the log_reader generated with your project and giving it the unified .copper log file and the string index file generated at compile time.

Note: In debug mode, the log will also be printed to the console. (ie slooow). In release mode, the log will be only be written to the unified logger.

This macro will be compiled out if the max log level is set to a level higher than Debug.