Factor out log crate

This commit is contained in:
Dominik Werder
2025-06-18 13:09:50 +02:00
parent 6b9ebcece6
commit bcf6939046
13 changed files with 28 additions and 205 deletions

View File

@@ -1,5 +1,5 @@
[workspace]
members = ["log", "netfetch", "daqingest"]
members = ["netfetch", "daqingest"]
resolver = "2"
[profile.release]

View File

@@ -8,7 +8,7 @@ edition = "2021"
doctest = false
[dependencies]
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
err = { path = "../../daqbuf-err", package = "daqbuf-err" }
taskrun = { path = "../../daqbuffer/crates/taskrun" }
async-channel = "2.1.0"

View File

@@ -1,6 +1,6 @@
[package]
name = "daqingest"
version = "0.3.0-aa.6"
version = "0.3.0-aa.7"
authors = ["Dominik Werder <dominik.werder@gmail.com>"]
edition = "2024"
@@ -26,7 +26,7 @@ netpod = { path = "../../daqbuf-netpod", package = "daqbuf-netpod" }
taskrun = { path = "../../daqbuffer/crates/taskrun" }
series = { path = "../../daqbuf-series", package = "daqbuf-series" }
channeltools = { path = "../../daqbuf-channeltools", package = "daqbuf-channeltools" }
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
stats = { path = "../stats" }
scywr = { path = "../scywr" }
dbpg = { path = "../dbpg" }

View File

@@ -8,7 +8,7 @@ edition = "2024"
doctest = false
[dependencies]
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
err = { path = "../../daqbuf-err", package = "daqbuf-err" }
netpod = { path = "../../daqbuf-netpod", package = "daqbuf-netpod" }
taskrun = { path = "../../daqbuffer/crates/taskrun" }

View File

@@ -7,5 +7,5 @@ edition = "2024"
[dependencies]
libc = "0.2"
autoerr = "0.0"
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
taskrun = { path = "../../daqbuffer/crates/taskrun" }

View File

@@ -1,11 +0,0 @@
[package]
name = "log"
version = "0.0.2"
authors = ["Dominik Werder <dominik.werder@gmail.com>"]
edition = "2024"
[lib]
path = "src/log.rs"
[dependencies]
tracing = "0.1"

View File

@@ -1,167 +0,0 @@
#![allow(unused_imports)]
pub use branch_debug as debug;
pub use branch_error as error;
pub use branch_info as info;
pub use branch_trace as trace;
pub use branch_warn as warn;
use std::sync::LazyLock;
#[allow(unused)]
#[inline(always)]
pub fn is_log_direct() -> bool {
static ONCE: LazyLock<bool> =
LazyLock::new(|| std::env::var("LOG_DIRECT").map_or(false, |x| x.parse().unwrap_or(false)));
*ONCE
}
pub mod log_tracing {
pub use tracing::debug;
pub use tracing::error;
pub use tracing::info;
pub use tracing::trace;
pub use tracing::warn;
// pub use tracing::{self, event, span, Level};
}
pub mod log_direct {
#[allow(unused)]
#[macro_export]
macro_rules! direct_trace {
($fmt:expr) => {
eprintln!("TRACE {}", format_args!($fmt));
};
($fmt:expr, $($arg:tt)*) => {
eprintln!("TRACE {}", format_args!($fmt, $($arg)*));
};
}
#[allow(unused)]
#[macro_export]
macro_rules! direct_debug {
($fmt:expr) => {
// eprintln!(concat!("DEBUG ", $fmt));
// eprintln!("{}", format_args!(concat!("DEBUG ", $fmt)));
eprintln!("DEBUG {}", format_args!($fmt));
};
($fmt:expr, $($arg:expr),*) => {
// eprintln!(concat!("DEBUG ", $fmt), $($arg),*);
// eprintln!("{}", format_args!(concat!("DEBUG ", $fmt), $($arg),*));
eprintln!("DEBUG {}", format_args!($fmt, $($arg),*));
};
}
#[allow(unused)]
#[macro_export]
macro_rules! direct_info {
($fmt:expr) => {
eprintln!("INFO {}", format_args!($fmt));
};
($fmt:expr, $($arg:expr),*) => {
eprintln!("INFO {}", format_args!($fmt, $($arg),*));
};
}
#[allow(unused)]
#[macro_export]
macro_rules! direct_warn {
($fmt:expr) => {
eprintln!("WARN {}", format_args!($fmt));
};
($fmt:expr, $($arg:expr),*) => {
eprintln!("WARN {}", format_args!($fmt, $($arg),*));
};
}
#[allow(unused)]
#[macro_export]
macro_rules! direct_error {
($fmt:expr) => {
eprintln!("ERROR {}", format_args!($fmt));
};
($fmt:expr, $($arg:expr),*) => {
eprintln!("ERROR {}", format_args!($fmt, $($arg),*));
};
}
pub use crate::direct_debug as debug;
pub use crate::direct_error as error;
pub use crate::direct_info as info;
pub use crate::direct_trace as trace;
pub use crate::direct_warn as warn;
}
#[allow(unused)]
#[macro_export]
macro_rules! log_v2_trace {
// ($fmt:expr) => {
// let h = format_args!();
// eprintln!(concat!("TRACE V2 ", $fmt));
// };
($fmt:expr, $($arg:expr),*) => {
// let fmt2 = concat!("", $fmt);
// let fmt2 = concat!("TRACE V2 ", $fmt, $($arg),*);
// let h = format_args!($fmt, $($arg),*);
// eprintln!("h: {:?}", h);
};
}
pub mod log_macros_branch {
#[allow(unused)]
#[macro_export]
macro_rules! branch_trace {
($($arg:tt)*) => {
if $crate::is_log_direct() {
$crate::log_direct::trace!($($arg)*);
} else {
$crate::log_tracing::trace!($($arg)*);
}
};
}
#[allow(unused)]
#[macro_export]
macro_rules! branch_debug {
($($arg:tt)*) => {
if $crate::is_log_direct() {
$crate::log_direct::debug!($($arg)*);
} else {
$crate::log_tracing::debug!($($arg)*);
}
};
}
#[allow(unused)]
#[macro_export]
macro_rules! branch_info {
($($arg:tt)*) => {
if $crate::is_log_direct() {
$crate::log_direct::info!($($arg)*);
} else {
$crate::log_tracing::info!($($arg)*);
}
};
}
#[allow(unused)]
#[macro_export]
macro_rules! branch_warn {
($($arg:tt)*) => {
if $crate::is_log_direct() {
$crate::log_direct::warn!($($arg)*);
} else {
$crate::log_tracing::warn!($($arg)*);
}
};
}
#[allow(unused)]
#[macro_export]
macro_rules! branch_error {
($($arg:tt)*) => {
if $crate::is_log_direct() {
$crate::log_direct::error!($($arg)*);
} else {
$crate::log_tracing::error!($($arg)*);
}
};
}
pub use branch_debug as debug;
pub use branch_error as error;
pub use branch_info as info;
pub use branch_trace as trace;
pub use branch_warn as warn;
pub use tracing::{self, Level, event, span};
}

View File

@@ -6,4 +6,4 @@ authors = ["Dominik Werder <dominik.werder@gmail.com>"]
[dependencies]
hashbrown = "0.15.2"
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }

View File

@@ -38,7 +38,7 @@ dashmap = "6.0.1"
hashbrown = "0.15.2"
smallvec = "1.13.2"
autoerr = "0.0"
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
series = { path = "../../daqbuf-series", package = "daqbuf-series" }
serieswriter = { path = "../serieswriter" }
stats = { path = "../stats" }

View File

@@ -2394,23 +2394,24 @@ impl CaConn {
Self::check_ev_value_data(&value.data, &writer.scalar_type())?;
crst.muted_before = 0;
crst.insert_item_ivl_ema.tick(tsnow);
if binwriter_enable {
binwriter.ingest(tsev, value.f32_for_binning(), iqdqs)?;
let val_for_agg = value.f32_for_binning();
let wres = writer.write(CaWriterValue::new(value, crst), tscaproto, tsev, iqdqs)?;
crst.status_emit_count += wres.nstatus() as u64;
if wres.st.accept {
crst.dw_st_last = stnow;
crst.acc_st.push_written(payload_len);
}
{
let wres = writer.write(CaWriterValue::new(value, crst), tscaproto, tsev, iqdqs)?;
crst.status_emit_count += wres.nstatus() as u64;
if wres.st.accept {
crst.dw_st_last = stnow;
crst.acc_st.push_written(payload_len);
}
if wres.mt.accept {
crst.dw_mt_last = stnow;
crst.acc_mt.push_written(payload_len);
}
if wres.lt.accept {
crst.dw_lt_last = stnow;
crst.acc_lt.push_written(payload_len);
if wres.mt.accept {
crst.dw_mt_last = stnow;
crst.acc_mt.push_written(payload_len);
}
if wres.lt.accept {
crst.dw_lt_last = stnow;
crst.acc_lt.push_written(payload_len);
}
if binwriter_enable {
if true || wres.accept_any() {
binwriter.ingest(tsev, val_for_agg, iqdqs)?;
}
}
}

View File

@@ -13,7 +13,7 @@ pin-project = "1.1.5"
bytes = "1.10.0"
autoerr = "0.0"
serde = { version = "1", features = ["derive"] }
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
stats = { path = "../stats" }
series = { path = "../../daqbuf-series", package = "daqbuf-series" }
netpod = { path = "../../daqbuf-netpod", package = "daqbuf-netpod" }

View File

@@ -11,7 +11,7 @@ futures-util = "0.3.30"
smallvec = "1.13.2"
autoerr = "0.0"
itertools = "0.14"
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
netpod = { path = "../../daqbuf-netpod", package = "daqbuf-netpod" }
items_0 = { path = "../../daqbuf-items-0", package = "daqbuf-items-0" }
items_2 = { path = "../../daqbuf-items-2", package = "daqbuf-items-2" }

View File

@@ -12,6 +12,6 @@ serde = { version = "1", features = ["derive"] }
rand_xoshiro = "0.7.0"
stats_types = { path = "../stats_types" }
stats_proc = { path = "../stats_proc" }
log = { path = "../log" }
log = { path = "../../daqbuf-log", package = "log" }
mettrics = { version = "0.0.7", path = "../../mettrics" }
ca_proto = { path = "../../daqbuf-ca-proto", package = "daqbuf-ca-proto" }