chore: update log

This commit is contained in:
nathan 2024-04-19 21:32:36 +08:00
parent 7745e54221
commit 9b4fd3bf57

View File

@ -8,6 +8,7 @@ use tracing_appender::rolling::Rotation;
use tracing_appender::{non_blocking::WorkerGuard, rolling::RollingFileAppender};
use tracing_bunyan_formatter::JsonStorageLayer;
use tracing_subscriber::fmt::format::Writer;
use tracing_subscriber::fmt::MakeWriter;
use tracing_subscriber::{layer::SubscriberExt, EnvFilter};
use crate::layer::FlowyFormattingLayer;
@ -87,6 +88,7 @@ impl Builder {
.pretty()
.with_env_filter(env_filter)
.finish()
.with(FlowyFormattingLayer::new(StdoutWriter))
.with(JsonStorageLayer)
.with(file_layer);
set_global_default(subscriber).map_err(|e| format!("{:?}", e))?;
@ -103,3 +105,13 @@ impl tracing_subscriber::fmt::time::FormatTime for CustomTime {
write!(w, "{}", Local::now().format("%Y-%m-%d %H:%M:%S"))
}
}
pub struct StdoutWriter;
impl<'a> MakeWriter<'a> for StdoutWriter {
type Writer = std::io::Stdout;
fn make_writer(&'a self) -> Self::Writer {
std::io::stdout()
}
}