Sweep every first-party crate source (1956 .rs files) to the project comment guidelines: delete redundant restatements, decorative banners, change narration, and end-of-line comments; keep and tighten the crucial ones (invariants, bug rationale, SAFETY blocks, ported-source attribution). No functional code changed. Every edit is proven comment-only against the prior tree by a comment-stripping lexer (string/char/raw-string aware) plus a separate doctest-fence check. Where removing a comment made rustfmt or clippy want to re-lay-out adjacent code, the minimal triggering comment is restored so code tokens stay byte-identical. Gates green: cargo fmt --all --check (0 diffs), cargo check and cargo clippy --workspace --all-targets (0 warnings). Adds scripts/check_codegen_comment_guidelines.py — the enforcement gate for these guidelines (flags banners, end-of-line comments, change narration, and commented-out code).
67 lines
1.8 KiB
Rust
67 lines
1.8 KiB
Rust
//! Macros for printing messages with Unix timestamps.
|
|
//!
|
|
//! Output goes through tracing rather than stdout/stderr so these are safe in
|
|
//! headless mode (no terminal attached).
|
|
|
|
/// Prints a message via tracing::info with a Unix timestamp prefix.
|
|
///
|
|
/// The format is: `{unix_timestamp}::{message}`
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// ```ignore
|
|
/// tprintln!("Hello, world!");
|
|
/// // Logs: 1234567890::Hello, world!
|
|
///
|
|
/// tprintln!("Value: {}", 42);
|
|
/// // Logs: 1234567890::Value: 42
|
|
/// ```
|
|
#[macro_export]
|
|
macro_rules! tprintln {
|
|
() => {{
|
|
let ts = ::std::time::SystemTime::now()
|
|
.duration_since(::std::time::UNIX_EPOCH)
|
|
.map(|d| d.as_secs())
|
|
.unwrap_or(0);
|
|
::tracing::info!("{}::", ts)
|
|
}};
|
|
($($arg:tt)*) => {{
|
|
let ts = ::std::time::SystemTime::now()
|
|
.duration_since(::std::time::UNIX_EPOCH)
|
|
.map(|d| d.as_secs())
|
|
.unwrap_or(0);
|
|
::tracing::info!("{}::{}", ts, ::std::format_args!($($arg)*))
|
|
}};
|
|
}
|
|
|
|
/// Prints a message via tracing::warn with a Unix timestamp prefix.
|
|
///
|
|
/// The format is: `{unix_timestamp}::{message}`
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// ```ignore
|
|
/// teprintln!("Error occurred!");
|
|
/// // Logs: 1234567890::Error occurred!
|
|
///
|
|
/// teprintln!("Error code: {}", 500);
|
|
/// // Logs: 1234567890::Error code: 500
|
|
/// ```
|
|
#[macro_export]
|
|
macro_rules! teprintln {
|
|
() => {{
|
|
let ts = ::std::time::SystemTime::now()
|
|
.duration_since(::std::time::UNIX_EPOCH)
|
|
.map(|d| d.as_secs())
|
|
.unwrap_or(0);
|
|
::tracing::warn!("{}::", ts)
|
|
}};
|
|
($($arg:tt)*) => {{
|
|
let ts = ::std::time::SystemTime::now()
|
|
.duration_since(::std::time::UNIX_EPOCH)
|
|
.map(|d| d.as_secs())
|
|
.unwrap_or(0);
|
|
::tracing::warn!("{}::{}", ts, ::std::format_args!($($arg)*))
|
|
}};
|
|
}
|