Macro service_logging::log[][src]

macro_rules! log {
    ( $queue:expr,  $sev:expr,  $( $key:tt $_t:tt  $val:expr ),* ) => { ... };
}

The log! macro can be used to create structured log entries for later use by Logger.send The first two parameters are fixed:

  • a writable queue (or something with a log() method)
  • severity level All remaining parameters are in the form key:value. Key is any word (using the same syntax as
use service_logging::{log, LogQueue, Severity::Info};
let mut lq = LogQueue::default();

// log http parameters
log!(lq, Info, method: "GET", url: "https://example.com", status: 200);

Parameters are of the form: (queue, severity, key:value, key:value, ...). queue is any object that implements fn add(&mut self, e: [LogEntry]) (such as LogQueue or Context)

Values can be anything that implements ToString Key names must use the same syntax as a rust identifier, e.g., no spaces, punctuation, etc.

The following keys are "special" (known to Coralogix and used for categorization in the coralogix dashboard): text, category, class_name, method_name, thread_id If text is not defined, all non-coralogix keys are converted into a json string and passed as the value of 'text'. (If text is also defined, any non-coralogix keys will be silently dropped).