pub fn init_file_subscriber(app_name: &str, dir: &str) -> (WorkerGuard, impl Subscriber) {
    let path_str = dir.to_string() + "/" + app_name;
    let path: &Path = path_str.as_ref();

    // open log file

    let mut open_options = OpenOptions::new();
    open_options.append(true).create(true);

    let mut open_res = open_options.open(path);
    if open_res.is_err() {
        if let Some(parent) = path.parent() {
            std::fs::create_dir_all(parent).unwrap();
            open_res = open_options.open(path);
        }
    }

    let f = open_res.unwrap();

    // build subscriber

    let (writer, writer_guard) = tracing_appender::non_blocking(f);

    let f_layer = Layer::new()
        .with_writer(writer)
        .with_thread_ids(true)
        .with_thread_names(false)
        .with_ansi(false)
        .with_span_events(fmt::format::FmtSpan::FULL);

    let subscriber = Registry::default()
        .with(EnvFilter::from_default_env())
        .with(f_layer)
        .with(jaeger_layer());

    (writer_guard, subscriber)
}
/// Create a file based tracing/logging subscriber.
/// A guard must be held during using the logging.
/// The format layer logging span/event in plain text, without color, one event per line.
/// Optionally it adds a layer to send to opentelemetry if env var `DATABEND_JAEGER` is present.
Create a file based tracing/logging subscriber.
A guard must be held during using the logging.
The format layer logging span/event in plain text, without color, one event per line.
Optionally it adds a layer to send to opentelemetry if env var `DATABEND_JAEGER` is present.
Create a file based tracing / logging subscriber . A guard must be held during using the logging . The format layer logging span / event in plain text without color one event per line . Optionally it adds a layer to send to opentelemetry if env var ` DATABEND_JAEGER ` is present .
pub fn init_file_subscriber(app_name: &str, dir: &str) -> (WorkerGuard, impl Subscriber) {
    let path_str = dir.to_string() + "/" + app_name;
    let path: &Path = path_str.as_ref();
    // open log file
    let mut open_options = OpenOptions::new();
    open_options.append(true).create(true);
    let mut open_res = open_options.open(path);
    if open_res.is_err() {
        if let Some(parent) = path.parent() {
            std::fs::create_dir_all(parent).unwrap();
            open_res = open_options.open(path);
        }
    }
    let f = open_res.unwrap();
    // build subscriber
    let (writer, writer_guard) = tracing_appender::non_blocking(f);
    let f_layer = Layer::new()
        .with_writer(writer)
        .with_thread_ids(true)
        .with_thread_names(false)
        .with_ansi(false)
        .with_span_events(fmt::format::FmtSpan::FULL);
    let subscriber = Registry::default()
        .with(EnvFilter::from_default_env())
        .with(f_layer)
        .with(jaeger_layer());
    (writer_guard, subscriber)
}
pub fn init_file_subscriber ( app_name : & str , dir : & str ) -> ( WorkerGuard , impl Subscriber ) { let path_str = dir . to_string ( ) + " " + app_name ; let path : & Path = path_str . as_ref ( ) ; // open log file let mut open_options = OpenOptions :: new ( ) ; open_options . append ( true ) . create ( true ) ; let mut open_res = open_options . open ( path ) ; if open_res . is_err ( ) { if let Some ( parent ) = path . parent ( ) { std :: fs :: create_dir_all ( parent ) . unwrap ( ) ; open_res = open_options . open ( path ) ; } } let f = open_res . unwrap ( ) ; // build subscriber let ( writer , writer_guard ) = tracing_appender :: non_blocking ( f ) ; let f_layer = Layer :: new ( ) . with_writer ( writer ) . with_thread_ids ( true ) . with_thread_names ( false ) . with_ansi ( false ) . with_span_events ( fmt :: format :: FmtSpan :: FULL ) ; let subscriber = Registry :: default ( ) . with ( EnvFilter :: from_default_env ( ) ) . with ( f_layer ) . with ( jaeger_layer ( ) ) ; ( writer_guard , subscriber ) }
Create a file based tracing/logging subscriber.
Create a file based tracing / logging subscriber .
app_name
&str
dir
&str
app_name
&str
dir
&str