diff src/logging.rs @ 98:b87100c5eed4

Start on environment variables, and make pointers nicer. This starts work on the PAM environment handling, and in so doing, introduces the CHeapBox and CHeapString structs. These are analogous to Box and CString, but they're located on the C heap rather than being Rust-managed memory. This is because environment variables deal with even more pointers and it turns out we can lose a lot of manual freeing using homemade smart pointers.
author Paul Fisher <paul@pfish.zone>
date Tue, 24 Jun 2025 04:25:25 -0400
parents 5ddbcada30f2
children dfcd96a74ac4
line wrap: on
line diff
--- a/src/logging.rs	Mon Jun 23 19:10:34 2025 -0400
+++ b/src/logging.rs	Tue Jun 24 04:25:25 2025 -0400
@@ -76,11 +76,12 @@
 /// # Example
 ///
 /// ```no_run
-/// # let pam_handle: Box<dyn nonstick::PamShared> = unimplemented!();
+/// # fn _test(pam_handle: impl nonstick::PamShared) {
 /// # let load_error = "xxx";
 /// nonstick::error!(pam_handle, "error loading data from data source: {load_error}");
 /// // Will log a message like "error loading data from data source: timed out"
 /// // at ERROR level on syslog.
+/// # }
 /// ```
 #[macro_export]
 macro_rules! error { ($handle:expr, $($arg:tt)+) => { $crate::__log_internal!($handle, Error, $($arg)+);}}
@@ -92,11 +93,12 @@
 /// # Example
 ///
 /// ```no_run
-/// # let pam_handle: Box<dyn nonstick::PamShared> = unimplemented!();
+/// # fn _test(pam_handle: impl nonstick::PamShared) {
 /// # let latency_ms = "xxx";
 /// nonstick::warn!(pam_handle, "loading took too long: {latency_ms} ms");
 /// // Will log a message like "loading took too long: 495 ms"
 /// // at WARN level on syslog.
+/// # }
 /// ```
 #[macro_export]
 macro_rules! warn { ($handle:expr, $($arg:tt)+) => { $crate::__log_internal!($handle, Warning, $($arg)+);}}
@@ -108,10 +110,11 @@
 /// # Example
 ///
 /// ```no_run
-/// # let pam_handle: Box<dyn nonstick::PamShared> = unimplemented!();
+/// # fn _test(pam_handle: impl nonstick::PamShared) {
 /// nonstick::info!(pam_handle, "using remote backend to load user data");
 /// // Will log a message like "using remote backend to load user data"
 /// // at INFO level on syslog.
+/// # }
 /// ```
 #[macro_export]
 macro_rules! info { ($handle:expr, $($arg:tt)+) => { $crate::__log_internal!($handle, Info, $($arg)+);}}
@@ -124,12 +127,13 @@
 /// # Example
 ///
 /// ```no_run
-/// # let pam_handle: Box<dyn nonstick::PamShared> = unimplemented!();
+/// # fn _test(pam_handle: impl nonstick::PamShared) {
 /// # let userinfo_url = "https://zombo.com/";
 /// nonstick::debug!(pam_handle, "making HTTP GET request to {userinfo_url}");
 /// // Will log a message like
 /// // "pam_http/lib.rs:39:14: making HTTP GET request to https://zombo.com/"
 /// // at DEBUG level on syslog.
+/// # }
 /// ```
 #[macro_export]
 macro_rules! debug {($handle:expr, $($arg:tt)+) => {