mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-11 17:31:46 +00:00
log: set up custom priority mapping for tracing-journald
By default, the mapping between tracing/log error levels to syslog priorities is as follows: error! -> Error warn! -> Warning info! -> Notice debug! -> Informational trace! -> Debug Before using tracing-journald, we used `syslog` to write log messages to the journal. That one has the following mapping: error! -> Error warn! -> Warning info! -> Informational debug! -> Debug trace! -> Debug The changed mapping of info! log messages led to many messages being written with the Notice priority, which are formatted bold when running journalctl to view log messages. This commit changes the mapping so that it is the same as with the syslog crate. Support for custom priority mappings was only introduced in tracing-journald 0.3.1, so we have to bump the dependency to that version. Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
parent
179a413fe8
commit
b01036f5cd
@ -111,7 +111,7 @@ tokio-openssl = "0.6.1"
|
|||||||
tokio-stream = "0.1.0"
|
tokio-stream = "0.1.0"
|
||||||
tower-service = "0.3.0"
|
tower-service = "0.3.0"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-journald = "0.3.0"
|
tracing-journald = "0.3.1"
|
||||||
tracing-log = { version = "0.2", default-features = false }
|
tracing-log = { version = "0.2", default-features = false }
|
||||||
tracing-subscriber = "0.3.16"
|
tracing-subscriber = "0.3.16"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
@ -13,7 +13,7 @@ Build-Depends-Arch: cargo:native <!nocheck>,
|
|||||||
librust-tokio-1+default-dev (>= 1.6-~~) <!nocheck>,
|
librust-tokio-1+default-dev (>= 1.6-~~) <!nocheck>,
|
||||||
librust-tokio-1+rt-multi-thread-dev (>= 1.6-~~) <!nocheck>,
|
librust-tokio-1+rt-multi-thread-dev (>= 1.6-~~) <!nocheck>,
|
||||||
librust-tracing-0.1+default-dev <!nocheck>,
|
librust-tracing-0.1+default-dev <!nocheck>,
|
||||||
librust-tracing-journald-0.3+default-dev <!nocheck>,
|
librust-tracing-journald-0.3+default-dev (>= 0.3.1-~~) <!nocheck>,
|
||||||
librust-tracing-log-0.2+std-dev <!nocheck>,
|
librust-tracing-log-0.2+std-dev <!nocheck>,
|
||||||
librust-tracing-subscriber-0.3+default-dev (>= 0.3.16-~~) <!nocheck>
|
librust-tracing-subscriber-0.3+default-dev (>= 0.3.16-~~) <!nocheck>
|
||||||
Maintainer: Proxmox Support Team <support@proxmox.com>
|
Maintainer: Proxmox Support Team <support@proxmox.com>
|
||||||
@ -36,7 +36,7 @@ Depends:
|
|||||||
librust-tokio-1+default-dev (>= 1.6-~~),
|
librust-tokio-1+default-dev (>= 1.6-~~),
|
||||||
librust-tokio-1+rt-multi-thread-dev (>= 1.6-~~),
|
librust-tokio-1+rt-multi-thread-dev (>= 1.6-~~),
|
||||||
librust-tracing-0.1+default-dev,
|
librust-tracing-0.1+default-dev,
|
||||||
librust-tracing-journald-0.3+default-dev,
|
librust-tracing-journald-0.3+default-dev (>= 0.3.1-~~),
|
||||||
librust-tracing-log-0.2+std-dev,
|
librust-tracing-log-0.2+std-dev,
|
||||||
librust-tracing-subscriber-0.3+default-dev (>= 0.3.16-~~)
|
librust-tracing-subscriber-0.3+default-dev (>= 0.3.16-~~)
|
||||||
Provides:
|
Provides:
|
||||||
|
@ -6,6 +6,7 @@ use std::future::Future;
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use tokio::task::futures::TaskLocalFuture;
|
use tokio::task::futures::TaskLocalFuture;
|
||||||
|
use tracing_journald::{Priority, PriorityMappings};
|
||||||
use tracing_subscriber::prelude::*;
|
use tracing_subscriber::prelude::*;
|
||||||
|
|
||||||
mod file_logger;
|
mod file_logger;
|
||||||
@ -115,7 +116,15 @@ where
|
|||||||
S: for<'a> tracing_subscriber::registry::LookupSpan<'a>,
|
S: for<'a> tracing_subscriber::registry::LookupSpan<'a>,
|
||||||
{
|
{
|
||||||
match tracing_journald::layer() {
|
match tracing_journald::layer() {
|
||||||
Ok(layer) => layer.boxed(),
|
Ok(layer) => layer
|
||||||
|
.with_priority_mappings(PriorityMappings {
|
||||||
|
error: Priority::Error,
|
||||||
|
warn: Priority::Warning,
|
||||||
|
info: Priority::Informational,
|
||||||
|
debug: Priority::Debug,
|
||||||
|
trace: Priority::Debug,
|
||||||
|
})
|
||||||
|
.boxed(),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Unable to open syslog: {err:?}");
|
eprintln!("Unable to open syslog: {err:?}");
|
||||||
plain_stderr_layer().boxed()
|
plain_stderr_layer().boxed()
|
||||||
|
Loading…
Reference in New Issue
Block a user