diff --git a/src/logging.rs b/src/logging.rs index f34150b6d2a9c0162b270993db43bc594aae9815..2d6c3550b0b03c3e821740ebb53f507b77033f4f 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -1,4 +1,5 @@ -/* 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); }