Mercurial > crates > nonstick
comparison src/handle.rs @ 157:0099f2f79f86
Switch logging interface to accept fmt::Arguments.
This means that we don't have to format arguments eagerly when logging;
an implementation could choose to discard them if it wanted to, avoiding
allocations and expensive format calls.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Wed, 09 Jul 2025 16:59:30 -0400 |
parents | 3036f2e6a022 |
children | 634cd5f2ac8b |
comparison
equal
deleted
inserted
replaced
156:66e662cde087 | 157:0099f2f79f86 |
---|---|
5 use crate::conv::Conversation; | 5 use crate::conv::Conversation; |
6 use crate::environ::{EnvironMap, EnvironMapMut}; | 6 use crate::environ::{EnvironMap, EnvironMapMut}; |
7 use crate::items::{getter, Items, ItemsMut}; | 7 use crate::items::{getter, Items, ItemsMut}; |
8 use crate::logging::{Level, Location}; | 8 use crate::logging::{Level, Location}; |
9 use std::ffi::{OsStr, OsString}; | 9 use std::ffi::{OsStr, OsString}; |
10 use std::fmt; | |
10 | 11 |
11 /// Functionality for both PAM applications and PAM modules. | 12 /// Functionality for both PAM applications and PAM modules. |
12 /// | 13 /// |
13 /// This base trait includes features of a PAM handle that are available | 14 /// This base trait includes features of a PAM handle that are available |
14 /// to both applications and modules. | 15 /// to both applications and modules. |
42 /// nonstick::error!(pam_hdl, "something bad happened!"); | 43 /// nonstick::error!(pam_hdl, "something bad happened!"); |
43 /// nonstick::warn!(pam_hdl, "loading information took {delay_ms} ms"); | 44 /// nonstick::warn!(pam_hdl, "loading information took {delay_ms} ms"); |
44 /// nonstick::info!(pam_hdl, "using network backend"); | 45 /// nonstick::info!(pam_hdl, "using network backend"); |
45 /// nonstick::debug!(pam_hdl, "sending GET request to {url}"); | 46 /// nonstick::debug!(pam_hdl, "sending GET request to {url}"); |
46 /// // But if you really want to, you can call this yourself: | 47 /// // But if you really want to, you can call this yourself: |
47 /// pam_hdl.log(Level::Warning, location!(), "this is unnecessarily verbose"); | 48 /// pam_hdl.log(Level::Warn, location!(), format_args!("this is unnecessarily verbose")); |
48 /// # } | 49 /// # } |
49 /// ``` | 50 /// ``` |
50 #[doc = man7!(3 pam_syslog)] | 51 #[doc = man7!(3 pam_syslog)] |
51 #[doc = manbsd!(3 openpam_log)] | 52 #[doc = manbsd!(3 openpam_log)] |
52 fn log(&self, level: Level, loc: Location<'_>, entry: &str); | 53 fn log(&self, level: Level, loc: Location<'_>, entry: fmt::Arguments); |
53 | 54 |
54 /// Retrieves the name of the user who is authenticating or logging in. | 55 /// Retrieves the name of the user who is authenticating or logging in. |
55 /// | 56 /// |
56 /// If the username has previously been obtained, this uses that username; | 57 /// If the username has previously been obtained, this uses that username; |
57 /// otherwise it prompts the user with the first of these that is present: | 58 /// otherwise it prompts the user with the first of these that is present: |