Skip to content

Commit

Permalink
fix: logger issues (#524)
Browse files Browse the repository at this point in the history
Signed-off-by: usamoi <[email protected]>
  • Loading branch information
usamoi authored Jul 11, 2024
1 parent 98a7b6e commit ba390a5
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 303 deletions.
121 changes: 0 additions & 121 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ arrayvec.workspace = true
bincode.workspace = true
byteorder.workspace = true
chrono = "0.4.38"
csv = "1.3.0"
env_logger = "0.11.2"
libc.workspace = true
log.workspace = true
memmap2.workspace = true
Expand Down Expand Up @@ -72,7 +70,7 @@ bincode = "1.3.3"
byteorder = "1.5.0"
half = { version = "2.4.0", features = ["num-traits", "rand_distr", "serde"] }
libc = "0.2.153"
log = "0.4.21"
log = { version = "0.4.21", features = ["std"] }
memmap2 = "0.9.4"
num-traits = "0.2.19"
parking_lot = "0.12.1"
Expand Down
2 changes: 0 additions & 2 deletions crates/detect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ version.workspace = true
edition.workspace = true

[dependencies]
rustix.workspace = true

detect_macros = { path = "../detect_macros" }

[lints]
Expand Down
2 changes: 0 additions & 2 deletions crates/memfd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ edition.workspace = true
rand.workspace = true
rustix.workspace = true

detect = { path = "../detect" }

[lints]
workspace = true
37 changes: 16 additions & 21 deletions src/bgworker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,23 @@ pub fn is_started() -> bool {
#[pgrx::pg_guard]
#[no_mangle]
extern "C" fn _vectors_main(_arg: pgrx::pg_sys::Datum) {
{
let mut builder = crate::logger::VectorLogger::build();
#[cfg(not(debug_assertions))]
{
builder.filter_level(log::LevelFilter::Info);
}
// #[cfg(debug_assertions)]
{
builder.filter_level(log::LevelFilter::Trace);
}
builder.init();
}
// for debugging, set `RUST_LOG=trace`
crate::logger::Logger::new(
match std::env::var("RUST_LOG").as_ref().map(|x| x.as_str()) {
Ok("off" | "Off" | "OFF") => log::LevelFilter::Off,
Ok("error" | "Error" | "ERROR") => log::LevelFilter::Error,
Ok("warn" | "Warn" | "WARN") => log::LevelFilter::Warn,
Ok("info" | "Info" | "INFO") => log::LevelFilter::Info,
Ok("debug" | "Debug" | "DEBUG") => log::LevelFilter::Debug,
Ok("trace" | "Trace" | "TRACE") => log::LevelFilter::Trace,
_ => log::LevelFilter::Info, // default level
},
)
.init()
.expect("failed to set logger");
std::panic::set_hook(Box::new(|info| {
let backtrace;
#[cfg(not(debug_assertions))]
{
backtrace = std::backtrace::Backtrace::capture();
}
#[cfg(debug_assertions)]
{
backtrace = std::backtrace::Backtrace::force_capture();
}
// for debugging, set `RUST_BACKTRACE=1`
let backtrace = std::backtrace::Backtrace::capture();
log::error!("Panickied. Info: {:?}. Backtrace: {}.", info, backtrace);
}));
use service::Version;
Expand Down
111 changes: 0 additions & 111 deletions src/logger/message.rs

This file was deleted.

Loading

0 comments on commit ba390a5

Please sign in to comment.