mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
Add feature for enabling json logging (#3462)
This commit is contained in:
parent
85dab149a9
commit
ff47d97bd3
2 changed files with 9 additions and 1 deletions
|
@ -27,6 +27,7 @@ lto = "thin"
|
||||||
[features]
|
[features]
|
||||||
embed-pictrs = ["pict-rs"]
|
embed-pictrs = ["pict-rs"]
|
||||||
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"]
|
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"]
|
||||||
|
json-log = ["tracing-subscriber/json"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
|
@ -185,7 +185,14 @@ pub fn init_logging(opentelemetry_url: &Option<Url>) -> Result<(), LemmyError> {
|
||||||
.trim_matches('"')
|
.trim_matches('"')
|
||||||
.parse::<Targets>()?;
|
.parse::<Targets>()?;
|
||||||
|
|
||||||
let format_layer = tracing_subscriber::fmt::layer().with_filter(targets.clone());
|
let format_layer = {
|
||||||
|
#[cfg(feature = "json-log")]
|
||||||
|
let layer = tracing_subscriber::fmt::layer().json();
|
||||||
|
#[cfg(not(feature = "json-log"))]
|
||||||
|
let layer = tracing_subscriber::fmt::layer();
|
||||||
|
|
||||||
|
layer.with_filter(targets.clone())
|
||||||
|
};
|
||||||
|
|
||||||
let subscriber = Registry::default()
|
let subscriber = Registry::default()
|
||||||
.with(format_layer)
|
.with(format_layer)
|
||||||
|
|
Loading…
Reference in a new issue