Skip to main content

log

Function log 

Source
pub fn log(level: u32, message: &str)
Expand description

Log a message to the host using the stored context.

Logs are written to the host’s per-app log file ({log_dir}/{app_name}.log) and forwarded to the host’s tracing subscriber, so they appear in the daemon’s main log output too.

This function is a no-op if the context was not provided during init or if the message contains invalid UTF-8.

§Arguments

  • level - Log level (0=trace, 1=debug, 2=info, 3=warn, 4=error). Use the log_level constants.
  • message - The log message (must not contain interior NUL bytes).

§Example

use node_app_sdk_rust::{log, log_level};

log(log_level::INFO, "App initialized successfully");
log(log_level::ERROR, "Something went wrong!");

Most callers should use the convenience macros (log_info!, log_error!, etc.) which accept format!-style arguments.