pub fn init_tracing_with_file(app_name: &str, dir: &str, level: &str) -> Vec<WorkerGuard> {
    let mut guards = vec![];

    let (stdout_writer, stdout_guard) = tracing_appender::non_blocking(std::io::stdout());
    let stdout_logging_layer = Layer::new().with_writer(stdout_writer);
    guards.push(stdout_guard);

    let file_appender = RollingFileAppender::new(Rotation::HOURLY, dir, app_name);
    let (file_writer, file_guard) = tracing_appender::non_blocking(file_appender);
    let file_logging_layer = BunyanFormattingLayer::new(app_name.to_string(), file_writer);
    guards.push(file_guard);

    let subscriber = Registry::default()
        .with(EnvFilter::new(level))
        .with(stdout_logging_layer)
        .with(JsonStorageLayer)
        .with(file_logging_layer)
        .with(jaeger_layer());

    tracing::subscriber::set_global_default(subscriber)
        .expect("error setting global tracing subscriber");

    guards
}
/// Write logs to file and rotation by HOUR.
Write logs to file and rotation by HOUR.
Write logs to file and rotation by HOUR .
pub fn init_tracing_with_file(app_name: &str, dir: &str, level: &str) -> Vec<WorkerGuard> {
    let mut guards = vec![];
    let (stdout_writer, stdout_guard) = tracing_appender::non_blocking(std::io::stdout());
    let stdout_logging_layer = Layer::new().with_writer(stdout_writer);
    guards.push(stdout_guard);
    let file_appender = RollingFileAppender::new(Rotation::HOURLY, dir, app_name);
    let (file_writer, file_guard) = tracing_appender::non_blocking(file_appender);
    let file_logging_layer = BunyanFormattingLayer::new(app_name.to_string(), file_writer);
    guards.push(file_guard);
    let subscriber = Registry::default()
        .with(EnvFilter::new(level))
        .with(stdout_logging_layer)
        .with(JsonStorageLayer)
        .with(file_logging_layer)
        .with(jaeger_layer());
    tracing::subscriber::set_global_default(subscriber)
        .expect("error setting global tracing subscriber");
    guards
}
pub fn init_tracing_with_file ( app_name : & str , dir : & str , level : & str ) -> Vec < WorkerGuard > { let mut guards = vec ! [ ] ; let ( stdout_writer , stdout_guard ) = tracing_appender :: non_blocking ( std :: io :: stdout ( ) ) ; let stdout_logging_layer = Layer :: new ( ) . with_writer ( stdout_writer ) ; guards . push ( stdout_guard ) ; let file_appender = RollingFileAppender :: new ( Rotation :: HOURLY , dir , app_name ) ; let ( file_writer , file_guard ) = tracing_appender :: non_blocking ( file_appender ) ; let file_logging_layer = BunyanFormattingLayer :: new ( app_name . to_string ( ) , file_writer ) ; guards . push ( file_guard ) ; let subscriber = Registry :: default ( ) . with ( EnvFilter :: new ( level ) ) . with ( stdout_logging_layer ) . with ( JsonStorageLayer ) . with ( file_logging_layer ) . with ( jaeger_layer ( ) ) ; tracing :: subscriber :: set_global_default ( subscriber ) . expect ( " " ) ; guards }
Write logs to file and rotation by HOUR.
Write logs to file and rotation by HOUR .
app_name
&str
dir
&str
level
&str
app_name
&str
dir
&str
level
&str