refactor: change logging level for mysql error log (#1938)

* refactor: change logging level for mysql error log

* Update src/common/telemetry/Cargo.toml

Co-authored-by: LFC <bayinamine@gmail.com>

---------

Co-authored-by: LFC <bayinamine@gmail.com>
This commit is contained in:
Ning Sun
2023-07-11 20:49:05 +08:00
committed by GitHub
parent e1ca454992
commit 41e856eb9e
4 changed files with 57 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ opentelemetry-jaeger = { version = "0.16", features = ["rt-tokio"] }
parking_lot = { version = "0.12", features = [
"deadlock_detection",
], optional = true }
serde = "1.0"
serde.workspace = true
tokio.workspace = true
tracing = "0.1"
tracing-appender = "0.2"

View File

@@ -140,6 +140,50 @@ macro_rules! warn {
$crate::log!(target: $target, $crate::logging::Level::WARN, $($arg)+)
};
// warn!(e; "a {} event", "log")
($e:expr; $($arg:tt)+) => ({
use std::error::Error;
use $crate::common_error::ext::ErrorExt;
match ($e.source(), $e.location_opt()) {
(Some(source), Some(location)) => {
$crate::log!(
$crate::logging::Level::WARN,
err.msg = %$e,
err.code = %$e.status_code(),
err.source = source,
err.location = %location,
$($arg)+
)
},
(Some(source), None) => {
$crate::log!(
$crate::logging::Level::WARN,
err.msg = %$e,
err.code = %$e.status_code(),
err.source = source,
$($arg)+
)
},
(None, Some(location)) => {
$crate::log!(
$crate::logging::Level::WARN,
err.msg = %$e,
err.code = %$e.status_code(),
err.location = %location,
$($arg)+
)
},
(None, None) => {
$crate::log!(
$crate::logging::Level::WARN,
err.msg = %$e,
err.code = %$e.status_code(),
$($arg)+
)
}
}
});
// warn!("a {} event", "log")
($($arg:tt)+) => {
$crate::log!($crate::logging::Level::WARN, $($arg)+)