Skip to main content

init

Function init 

Source
pub fn init(data_dir: &Path, service_name: &str) -> Result<()>
Expand description

Initialise dual logging: pretty console (stderr) + JSON file.

§Arguments

  • data_dir — service data directory (e.g. ~/.soma). Logs go into {data_dir}/logs/{service_name}.log.
  • service_name — used as the log file name (e.g. "example").

§Errors

Returns an error if the log directory cannot be created or the log file cannot be opened for writing.

§CUSTOMIZE: EnvFilter precedence

Log levels are controlled by RUST_LOG. If unset, defaults to "info". Examples:

  • RUST_LOG=debug — show all debug logs
  • RUST_LOG=info,rmcp=warn — info level, suppress rmcp crate noise
  • RUST_LOG=soma=trace — trace this crate only

Both the console and file writers share the same EnvFilter, so they always emit the same set of events.