implement tracing

This commit is contained in:
mbecker20
2024-01-15 01:29:26 -08:00
parent f97e48e886
commit 2b4ebd6e10
26 changed files with 163 additions and 153 deletions

View File

@@ -14,4 +14,4 @@ mungos.workspace = true
mongo_indexed.workspace = true
#
anyhow.workspace = true
log.workspace = true
tracing.workspace = true

View File

@@ -1,5 +1,5 @@
#[macro_use]
extern crate log;
extern crate tracing;
use mongo_indexed::{create_index, create_unique_index, Indexed};
use monitor_client::entities::{

View File

@@ -8,6 +8,6 @@ license.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
log.workspace = true
simple_logger.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
anyhow.workspace = true

View File

@@ -1,13 +1,9 @@
use anyhow::Context;
use log::LevelFilter;
use simple_logger::SimpleLogger;
use tracing::level_filters::LevelFilter;
pub fn init(log_level: LevelFilter) -> anyhow::Result<()> {
SimpleLogger::new()
.with_level(log_level)
.env()
.with_colors(true)
.with_utc_timestamps()
pub fn init(log_level: tracing::Level) {
tracing_subscriber::fmt()
.with_level(true)
.with_line_number(true)
.with_max_level(LevelFilter::from(log_level))
.init()
.context("failed to configure logger")
}

View File

@@ -13,6 +13,6 @@ monitor_periphery.workspace = true
reqwest.workspace = true
anyhow.workspace = true
serde_json.workspace = true
log.workspace = true
tracing.workspace = true
resolver_api.workspace = true
serror.workspace = true

View File

@@ -1,5 +1,5 @@
#[macro_use]
extern crate log;
extern crate tracing;
use std::time::Duration;