Mercurial > crates > nonstick
diff 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 |
line wrap: on
line diff
--- a/src/handle.rs Tue Jul 08 01:04:30 2025 -0400 +++ b/src/handle.rs Wed Jul 09 16:59:30 2025 -0400 @@ -7,6 +7,7 @@ use crate::items::{getter, Items, ItemsMut}; use crate::logging::{Level, Location}; use std::ffi::{OsStr, OsString}; +use std::fmt; /// Functionality for both PAM applications and PAM modules. /// @@ -44,12 +45,12 @@ /// nonstick::info!(pam_hdl, "using network backend"); /// nonstick::debug!(pam_hdl, "sending GET request to {url}"); /// // But if you really want to, you can call this yourself: - /// pam_hdl.log(Level::Warning, location!(), "this is unnecessarily verbose"); + /// pam_hdl.log(Level::Warn, location!(), format_args!("this is unnecessarily verbose")); /// # } /// ``` #[doc = man7!(3 pam_syslog)] #[doc = manbsd!(3 openpam_log)] - fn log(&self, level: Level, loc: Location<'_>, entry: &str); + fn log(&self, level: Level, loc: Location<'_>, entry: fmt::Arguments); /// Retrieves the name of the user who is authenticating or logging in. ///