#![allow(unused_parens)]
use std::fs;
use Htrace::components::context::Context;
use Htrace::components::level::Level;
use Htrace::crates::bridge::HtraceBridge;
use Htrace::htracer::HTracer;
use Htrace::modules::{command_line, file};
use Htrace::modules::command_line_config::CommandLineConfig;
use Htrace::modules::file_config::FileConfig;
#[test]
fn trace_from_tracing_crate()
{
let _ = fs::remove_dir_all("./traces");
let mut global_context = Context::default();
global_context.module_add(
"cmd",
command_line::CommandLine::new(CommandLineConfig::default()),
);
global_context.module_add("file", file::File::new(FileConfig::default()));
global_context.level_setMin(Some(Level::DEBUG));
HTracer::globalContext_set(global_context, HtraceBridge::default());
tracing::trace!("test trace! from tracing crate"); tracing::debug!("test debug! from tracing crate"); tracing::info!("test info! from tracing crate");
tracing::warn!("test warn! from tracing crate");
tracing::error!("test error! from tracing crate");
let method = "POST";
let user_id: u64 = 42;
let path = "/api/items";
let request = tracing::info_span!("request", method = %method, user_id = user_id, path = %path);
request.in_scope(|| {
tracing::info!("span withing tracing crate: start handling");
let route = tracing::info_span!("route", name = "create_item");
route.in_scope(|| {
tracing::info!(count = 3, "span withing tracing crate: db query done"); });
tracing::warn!("span withing tracing crate: handler a bit slow"); });
HTracer::drop();
}