Skip to content
Snippets Groups Projects
Verified Commit b262c52e authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[Logging] Log correct PID in syslog

parent f054151e
No related branches found
No related tags found
No related merge requests found
/* Copyright 2021 Nicolas Goy
/* Copyright 2020 Nicolas Goy
* Copyright 2021 Dominik George <nik@naturalnet.de>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,6 +14,9 @@
* limitations under the License.
*/
use std::process;
use std::convert::TryInto;
use log::{LevelFilter};
use syslog::{BasicLogger, Facility, Formatter3164};
......@@ -21,10 +25,9 @@ pub fn setup_log(log_level: LevelFilter) {
facility: Facility::LOG_AUTHPRIV,
hostname: None,
process: "nss_pam_oidc".into(),
pid: 0,
pid: process::id().try_into().unwrap_or_default(),
};
let logger = syslog::unix(formatter).expect("could not connect to syslog");
log::set_boxed_logger(Box::new(BasicLogger::new(logger)))
.map(|()| log::set_max_level(LevelFilter::Debug));
log::set_boxed_logger(Box::new(BasicLogger::new(logger))).ok();
log::set_max_level(log_level);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment