bugfixes-rs

Rust logging client for BugFixes. Local log output with file and line capture, global macros, explicit logger instances, and optional remote log, error and panic reporting.

Install

[dependencies]
bugfixes = "0.1.0"

Configure

Create an agent in the dashboard and set its key and secret. Without them, logs still print locally and remote reporting is skipped.

BUGFIXES_AGENT_KEY=your-key
BUGFIXES_AGENT_SECRET=your-secret
# optional
BUGFIXES_LOG_LEVEL=warn
BUGFIXES_LOCAL_ONLY=false

App setup

Initialise the global logger once at startup and install the panic hook, so crashes are reported as bugs:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    bugfixes::init_global_from_env()?;
    bugfixes::install_global_panic_hook();

    bugfixes::info!("server starting on {}", ":3000")?;
    bugfixes::warn!("slow request threshold set to {}ms", 250)?;
    bugfixes::error!("db error: {}", "timeout")?;

    Ok(())
}

Explicit logger instances

For library code or dependency injection, pass a logger in:

use bugfixes::BugfixesLogger;

fn handle_request(logger: &BugfixesLogger) -> Result<(), Box<dyn std::error::Error>> {
    logger.info("request started")?;
    logger.warn("upstream latency is elevated")?;
    Ok(())
}

let logger = BugfixesLogger::from_env()?;
handle_request(&logger)?;

Local-only logging

For operational noise that should never leave the machine:

use bugfixes::{BugfixesLogger, local_logger};

BugfixesLogger::local()?.info("warming cache")?;
local_logger().warn("retry loop is still booting")?;
bugfixes::local::info!("server started on {}", ":3000")?;