pub fn try_init(self, filter: LogFilter) -> Result<(), LogInitError> {
        use tracing_subscriber::prelude::*;

        let registry = tracing_subscriber::registry().with(filter);

        match self {
            LogFormat::Plain => registry.with(tracing_subscriber::fmt::layer()).try_init()?,

            LogFormat::Json => {
                let event_fmt = tracing_subscriber::fmt::format()
                    // Configure the formatter to output JSON logs.
                    .json()
                    // Output the current span context as a JSON list.
                    .with_span_list(true)
                    // Don't output a field for the current span, since this
                    // would duplicate information already in the span list.
                    .with_current_span(false);

                // Use the JSON event formatter and the JSON field formatter.
                let fmt = tracing_subscriber::fmt::layer()
                    .event_format(event_fmt)
                    .fmt_fields(tracing_subscriber::fmt::format::JsonFields::default());

                registry.with(fmt).try_init()?
            }
        };

        Ok(())
    }
/// Attempts to configure the global default tracing subscriber in the current scope, returning
/// an error if one is already set
///
/// This method returns an error if a global default subscriber has already been set, or if a
/// `log` logger has already been set.
Attempts to configure the global default tracing subscriber in the current scope, returning
an error if one is already set

This method returns an error if a global default subscriber has already been set, or if a
`log` logger has already been set.
Attempts to configure the global default tracing subscriber in the current scope returning an error if one is already set This method returns an error if a global default subscriber has already been set or if a ` log ` logger has already been set .
pub fn try_init(self, filter: LogFilter) -> Result<(), LogInitError> {
        use tracing_subscriber::prelude::*;
        let registry = tracing_subscriber::registry().with(filter);
        match self {
            LogFormat::Plain => registry.with(tracing_subscriber::fmt::layer()).try_init()?,
            LogFormat::Json => {
                let event_fmt = tracing_subscriber::fmt::format()
                    // Configure the formatter to output JSON logs.
                    .json()
                    // Output the current span context as a JSON list.
                    .with_span_list(true)
                    // Don't output a field for the current span, since this
                    // would duplicate information already in the span list.
                    .with_current_span(false);
                // Use the JSON event formatter and the JSON field formatter.
                let fmt = tracing_subscriber::fmt::layer()
                    .event_format(event_fmt)
                    .fmt_fields(tracing_subscriber::fmt::format::JsonFields::default());
                registry.with(fmt).try_init()?
            }
        };
        Ok(())
    }
pub fn try_init ( self , filter : LogFilter ) -> Result < ( ) , LogInitError > { use tracing_subscriber :: prelude :: * ; let registry = tracing_subscriber :: registry ( ) . with ( filter ) ; match self { LogFormat :: Plain => registry . with ( tracing_subscriber :: fmt :: layer ( ) ) . try_init ( ) ? , LogFormat :: Json => { let event_fmt = tracing_subscriber :: fmt :: format ( ) // Configure the formatter to output JSON logs. . json ( ) // Output the current span context as a JSON list. . with_span_list ( true ) // Don't output a field for the current span, since this // would duplicate information already in the span list. . with_current_span ( false ) ; // Use the JSON event formatter and the JSON field formatter. let fmt = tracing_subscriber :: fmt :: layer ( ) . event_format ( event_fmt ) . fmt_fields ( tracing_subscriber :: fmt :: format :: JsonFields :: default ( ) ) ; registry . with ( fmt ) . try_init ( ) ? } } ; Ok ( ( ) ) }
Attempts to configure the global default tracing subscriber in the current scope, returning
an error if one is already set
Attempts to configure the global default tracing subscriber in the current scope returning an error if one is already set
self
filter
LogFilter
self
filter
LogFilter