comparison src/logging.rs @ 155:ab8020566cd9 default tip

Only use real PAM constants for logging within `nonstick/libpam`.
author Paul Fisher <paul@pfish.zone>
date Tue, 08 Jul 2025 00:49:38 -0400
parents efbc235f01d3
children
comparison
equal deleted inserted replaced
154:f71bfffb6de1 155:ab8020566cd9
13 //! 13 //!
14 //! A `PamShared` implementation may still use the `log` crate on the backend, 14 //! A `PamShared` implementation may still use the `log` crate on the backend,
15 //! and may even itself implement `log::Log`, but that interface is not exposed 15 //! and may even itself implement `log::Log`, but that interface is not exposed
16 //! to the generic PAM user. 16 //! to the generic PAM user.
17 17
18 #[cfg(pam_impl = "OpenPam")]
19 mod levels {
20 use libpam_sys_helpers::constants;
21
22 pub const ERROR: i32 = constants::PAM_LOG_ERROR;
23 pub const WARN: i32 = constants::PAM_LOG_NOTICE;
24 pub const INFO: i32 = constants::PAM_LOG_VERBOSE;
25 pub const DEBUG: i32 = constants::PAM_LOG_DEBUG;
26 }
27 #[cfg(not(pam_impl = "OpenPam"))]
28 mod levels {
29 pub const ERROR: i32 = libc::LOG_ERR;
30 pub const WARN: i32 = libc::LOG_WARNING;
31 pub const INFO: i32 = libc::LOG_INFO;
32 pub const DEBUG: i32 = libc::LOG_DEBUG;
33 }
34
35 /// An entry to be added to the log. 18 /// An entry to be added to the log.
36 /// 19 ///
37 /// The levels are in descending order of importance and correspond roughly 20 /// The levels are in descending order of importance and correspond roughly
38 /// to the similarly-named levels in the `log` crate. 21 /// to the similarly-named levels in the `log` crate.
39 /// 22 ///
40 /// Their values are ordered monotonically, either increasing or decreasing, 23 /// Their values are ordered monotonically, either increasing or decreasing,
41 /// depending upon the implementation. 24 /// depending upon the implementation.
42 #[derive(Clone, Copy, Debug, PartialEq, Eq)] 25 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
43 #[repr(i32)]
44 pub enum Level { 26 pub enum Level {
45 Error = levels::ERROR, 27 Error,
46 Warning = levels::WARN, 28 Warning,
47 Info = levels::INFO, 29 Info,
48 Debug = levels::DEBUG, 30 Debug,
49 } 31 }
50 32
51 /// The location of a log entry. Use [`location!`](crate::location!) to create this. 33 /// The location of a log entry. Use [`location!`](crate::location!) to create this.
52 #[derive(Clone, Copy, Debug, Default)] 34 #[derive(Clone, Copy, Debug, Default)]
53 #[non_exhaustive] 35 #[non_exhaustive]