smart-house-web: в работе
This commit is contained in:
@@ -5,19 +5,28 @@ const CODE_STARTIG_SERVER_ERROR: i32 = 4;
|
||||
const CODE_CTRL_C_SIGNAL_INSTALL_ERROR: i32 = 5;
|
||||
|
||||
pub fn init_logger() {
|
||||
use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use std::process::exit;
|
||||
use tracing::{Level, trace};
|
||||
use tracing_subscriber::{
|
||||
Layer, filter::Targets, fmt::layer, layer::SubscriberExt, registry, util::SubscriberInitExt,
|
||||
};
|
||||
|
||||
let layer = tracing_subscriber::fmt::layer()
|
||||
let layer = layer()
|
||||
.compact()
|
||||
.with_thread_names(true)
|
||||
.with_file(false)
|
||||
.with_line_number(false)
|
||||
.compact()
|
||||
.with_filter(
|
||||
Targets::new()
|
||||
.with_target("axum::serve", Level::INFO)
|
||||
.with_default(Level::TRACE),
|
||||
)
|
||||
.boxed();
|
||||
if let Err(e) = tracing_subscriber::registry().with(vec![layer]).try_init() {
|
||||
if let Err(e) = registry().with(vec![layer]).try_init() {
|
||||
eprintln!("Logger initialization failed: {:?}", e);
|
||||
std::process::exit(CODE_LOGGER_INITIALIZATION_ERROR);
|
||||
exit(CODE_LOGGER_INITIALIZATION_ERROR);
|
||||
} else {
|
||||
tracing::trace!("Logger succesfully initialized");
|
||||
trace!("Logger succesfully initialized");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user