From b262c52e5dacb749f628537dd9b6b96929ad3639 Mon Sep 17 00:00:00 2001 From: Dominik George <nik@naturalnet.de> Date: Wed, 5 May 2021 23:53:59 +0200 Subject: [PATCH] [Logging] Log correct PID in syslog --- src/logging.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/logging.rs b/src/logging.rs index f34150b..2d6c355 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); } -- GitLab