logger-nx 0.2.0

A high-performance hourly-rotating file logger implementing the `log` facade, with TTL-based cleanup. Behaviorally equivalent to @imcooder/node-logger.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use chrono::Local;
use log::Record;

/// Format a log record.
///
/// Output format (matches `@imcooder/node-logger`):
///
/// ```text
/// [2026-04-21 10:28:35.123] [INFO] my-app - message
/// ```
pub fn format_record(record: &Record, app_name: &str) -> String {
    let now = Local::now();
    let ts = now.format("%Y-%m-%d %H:%M:%S%.3f");
    let level = record.level();
    let msg = record.args();
    format!("[{ts}] [{level}] {app_name} - {msg}\n")
}