#local-time #logging-tracing #non-blocking #logging #tracing #temporary-files #date-format

clia-tracing-appender

A personal temporary tracing-appender, support symlinking latest log file and local offset time format

5 releases

0.2.5 Oct 23, 2022
0.2.4 Mar 23, 2022
0.2.3 Mar 12, 2022
0.2.2 Mar 9, 2022
0.2.0 Feb 21, 2022

#387 in Debugging

Download history 50/week @ 2024-03-11 41/week @ 2024-03-18 76/week @ 2024-03-25 81/week @ 2024-04-01 47/week @ 2024-04-08 72/week @ 2024-04-15 112/week @ 2024-04-22 82/week @ 2024-04-29 55/week @ 2024-05-06 56/week @ 2024-05-13 47/week @ 2024-05-20 42/week @ 2024-05-27 84/week @ 2024-06-03 36/week @ 2024-06-10 46/week @ 2024-06-17 49/week @ 2024-06-24

219 downloads per month
Used in 7 crates (via clia-tracing-config)

MIT license

82KB
1K SLoC

clia-tracing-appender

This is a personal temporary tracing-appender, support symlinking latest log file and local offset time format.

It has no relation to tracing-appender.

Usage example

Cargo.toml:

clia-local-offset = "0.1"
time = { version = "0.3", features = ["macros"] }
tracing-subscriber = { version = "0.3", features = ["time", "local-time"] }
tracing-appender = { package = "clia-tracing-appender", version = "0.2" }

Rust:

use time::macros::format_description;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::fmt;
use tracing_subscriber::fmt::time::OffsetTime;

let file_appender = tracing_appender::rolling::hourly(directory, file_name);
let (file_writer, guard) = tracing_appender::non_blocking(file_appender);

let offset = clia_local_offset::current_local_offset()
    .expect("Can not get local offset!");
let timer = OffsetTime::new(
    offset,
    format_description!("[year]-[month]-[day] [hour]:[minute]:[second].[subsecond digits:3]"),
);

tracing_subscriber::fmt()
    .with_timer(timer)
    .with_writer(file_writer)
    .init();

Changelog

Version 0.2.5

  • Merge tracing-appender v0.1.x branch date 2022-10-22.
  • Change usage of clia-time to clia-local-offset, simplify the example.

Dependencies

~2.4–8MB
~58K SLoC