summaryrefslogtreecommitdiffstats
path: root/vendor/env_logger/src/fmt/humantime
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/env_logger/src/fmt/humantime
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/env_logger/src/fmt/humantime')
-rw-r--r--vendor/env_logger/src/fmt/humantime/extern_impl.rs118
-rw-r--r--vendor/env_logger/src/fmt/humantime/mod.rs11
-rw-r--r--vendor/env_logger/src/fmt/humantime/shim_impl.rs5
3 files changed, 0 insertions, 134 deletions
diff --git a/vendor/env_logger/src/fmt/humantime/extern_impl.rs b/vendor/env_logger/src/fmt/humantime/extern_impl.rs
deleted file mode 100644
index 19dec1b65..000000000
--- a/vendor/env_logger/src/fmt/humantime/extern_impl.rs
+++ /dev/null
@@ -1,118 +0,0 @@
-use std::fmt;
-use std::time::SystemTime;
-
-use humantime::{
- format_rfc3339_micros, format_rfc3339_millis, format_rfc3339_nanos, format_rfc3339_seconds,
-};
-
-use crate::fmt::{Formatter, TimestampPrecision};
-
-pub(in crate::fmt) mod glob {
- pub use super::*;
-}
-
-impl Formatter {
- /// Get a [`Timestamp`] for the current date and time in UTC.
- ///
- /// # Examples
- ///
- /// Include the current timestamp with the log record:
- ///
- /// ```
- /// use std::io::Write;
- ///
- /// let mut builder = env_logger::Builder::new();
- ///
- /// builder.format(|buf, record| {
- /// let ts = buf.timestamp();
- ///
- /// writeln!(buf, "{}: {}: {}", ts, record.level(), record.args())
- /// });
- /// ```
- ///
- /// [`Timestamp`]: struct.Timestamp.html
- pub fn timestamp(&self) -> Timestamp {
- Timestamp {
- time: SystemTime::now(),
- precision: TimestampPrecision::Seconds,
- }
- }
-
- /// Get a [`Timestamp`] for the current date and time in UTC with full
- /// second precision.
- pub fn timestamp_seconds(&self) -> Timestamp {
- Timestamp {
- time: SystemTime::now(),
- precision: TimestampPrecision::Seconds,
- }
- }
-
- /// Get a [`Timestamp`] for the current date and time in UTC with
- /// millisecond precision.
- pub fn timestamp_millis(&self) -> Timestamp {
- Timestamp {
- time: SystemTime::now(),
- precision: TimestampPrecision::Millis,
- }
- }
-
- /// Get a [`Timestamp`] for the current date and time in UTC with
- /// microsecond precision.
- pub fn timestamp_micros(&self) -> Timestamp {
- Timestamp {
- time: SystemTime::now(),
- precision: TimestampPrecision::Micros,
- }
- }
-
- /// Get a [`Timestamp`] for the current date and time in UTC with
- /// nanosecond precision.
- pub fn timestamp_nanos(&self) -> Timestamp {
- Timestamp {
- time: SystemTime::now(),
- precision: TimestampPrecision::Nanos,
- }
- }
-}
-
-/// An [RFC3339] formatted timestamp.
-///
-/// The timestamp implements [`Display`] and can be written to a [`Formatter`].
-///
-/// [RFC3339]: https://www.ietf.org/rfc/rfc3339.txt
-/// [`Display`]: https://doc.rust-lang.org/stable/std/fmt/trait.Display.html
-/// [`Formatter`]: struct.Formatter.html
-pub struct Timestamp {
- time: SystemTime,
- precision: TimestampPrecision,
-}
-
-impl fmt::Debug for Timestamp {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- /// A `Debug` wrapper for `Timestamp` that uses the `Display` implementation.
- struct TimestampValue<'a>(&'a Timestamp);
-
- impl<'a> fmt::Debug for TimestampValue<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(&self.0, f)
- }
- }
-
- f.debug_tuple("Timestamp")
- .field(&TimestampValue(&self))
- .finish()
- }
-}
-
-impl fmt::Display for Timestamp {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let formatter = match self.precision {
- TimestampPrecision::Seconds => format_rfc3339_seconds,
- TimestampPrecision::Millis => format_rfc3339_millis,
- TimestampPrecision::Micros => format_rfc3339_micros,
- TimestampPrecision::Nanos => format_rfc3339_nanos,
- };
-
- formatter(self.time).fmt(f)
- }
-}
diff --git a/vendor/env_logger/src/fmt/humantime/mod.rs b/vendor/env_logger/src/fmt/humantime/mod.rs
deleted file mode 100644
index ac23ae249..000000000
--- a/vendor/env_logger/src/fmt/humantime/mod.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-This internal module contains the timestamp implementation.
-
-Its public API is available when the `humantime` crate is available.
-*/
-
-#[cfg_attr(feature = "humantime", path = "extern_impl.rs")]
-#[cfg_attr(not(feature = "humantime"), path = "shim_impl.rs")]
-mod imp;
-
-pub(in crate::fmt) use self::imp::*;
diff --git a/vendor/env_logger/src/fmt/humantime/shim_impl.rs b/vendor/env_logger/src/fmt/humantime/shim_impl.rs
deleted file mode 100644
index 906bf9e4c..000000000
--- a/vendor/env_logger/src/fmt/humantime/shim_impl.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
-Timestamps aren't available when we don't have a `humantime` dependency.
-*/
-
-pub(in crate::fmt) mod glob {}