-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
When I use the trc function of flexi_logger to output logs to a file locally, ANSI codes are present. Here is my use case.
use flexi_logger::{
writers::FileLogWriter, Cleanup, Criterion,FileSpec, LogSpecification,Naming, WriteMode
};
use tracing::{error, info};
fn main() {
let _keep_alive_handles = flexi_logger::trc::setup_tracing(
LogSpecification::info(),
None,
FileLogWriter::builder(
FileSpec::default()
.directory("flexi_logger_example/logs")
.basename("mylog")
.use_timestamp(true),
)
.format(flexi_logger::default_format)
.rotate(
Criterion::Size(10_000_000),
Naming::Timestamps,
Cleanup::KeepLogFiles(7),
)
.write_mode(WriteMode::Async),
)
.unwrap();
info!("Application started");
error!("Something went wrong");
}
cargo.toml
flexi_logger = {version = "0.30.0", features = ["trc"]}
tracing = "0.1"
result:
�[2m2025-06-16T03:53:34.186399Z�[0m �[32m INFO�[0m �[2mflexi_logger_example�[0m�[2m:�[0m Application started �[2m2025-06-16T03:53:34.186429Z�[0m �[31mERROR�[0m �[2mflexi_logger_example�[0m�[2m:�[0m Something went wrong
expteced:
I hope that the flexi_logger trc input to the file does not contain ANSI. If there is any problem with my usage, please point it out. I would be extremely grateful.
Metadata
Metadata
Assignees
Labels
No labels