@@ -269,11 +269,9 @@ pub mod fmt;
269
269
pub use self :: fmt:: glob:: * ;
270
270
271
271
use self :: filter:: Filter ;
272
- use self :: fmt:: Formatter ;
272
+ use self :: fmt:: { Formatter , TimestampPrecision } ;
273
273
use self :: fmt:: writer:: { self , Writer } ;
274
274
275
- pub use self :: fmt:: TimestampPrecision as Timestamp ;
276
-
277
275
/// The default name for the environment variable to read filters from.
278
276
pub const DEFAULT_FILTER_ENV : & ' static str = "RUST_LOG" ;
279
277
@@ -519,28 +517,6 @@ impl Builder {
519
517
self
520
518
}
521
519
522
- /// Whether or not to write the timestamp in the default format.
523
- #[ deprecated = "Use format_timestamp() instead" ]
524
- pub fn default_format_timestamp ( & mut self , write : bool ) -> & mut Self {
525
- if write {
526
- self . format_timestamp ( Some ( Timestamp :: Seconds ) ) ;
527
- } else {
528
- self . format_timestamp ( None ) ;
529
- }
530
- self
531
- }
532
-
533
- /// Whether or not to write the timestamp with nanosecond precision.
534
- #[ deprecated = "Use format_timestamp() instead" ]
535
- pub fn default_format_timestamp_nanos ( & mut self , write : bool ) -> & mut Self {
536
- // The old logic included two booleans: One for timestamp on/off and one
537
- // for nanosecond precision. Mimic it here for compatibility.
538
- if write && self . format . default_format_timestamp . is_some ( ) {
539
- self . format . default_format_timestamp = Some ( fmt:: TimestampPrecision :: Nanos ) ;
540
- }
541
- self
542
- }
543
-
544
520
/// Configures the amount of spaces to use to indent multiline log records.
545
521
/// A value of `None` disables any kind of indentation.
546
522
pub fn default_format_indent ( & mut self , indent : Option < usize > ) -> & mut Self {
@@ -549,11 +525,31 @@ impl Builder {
549
525
}
550
526
551
527
/// Configures if timestamp should be included and in what precision.
552
- pub fn format_timestamp ( & mut self , timestamp : Option < Timestamp > ) -> & mut Self {
528
+ pub fn default_format_timestamp ( & mut self , timestamp : Option < TimestampPrecision > ) -> & mut Self {
553
529
self . format . default_format_timestamp = timestamp;
554
530
self
555
531
}
556
532
533
+ /// Configures the timestamp to use second precision.
534
+ pub fn default_format_timestamp_secs ( & mut self ) -> & mut Self {
535
+ self . default_format_timestamp ( Some ( TimestampPrecision :: Seconds ) )
536
+ }
537
+
538
+ /// Configures the timestamp to use millisecond precision.
539
+ pub fn default_format_timestamp_millis ( & mut self ) -> & mut Self {
540
+ self . default_format_timestamp ( Some ( TimestampPrecision :: Millis ) )
541
+ }
542
+
543
+ /// Configures the timestamp to use microsecond precision.
544
+ pub fn default_format_timestamp_micros ( & mut self ) -> & mut Self {
545
+ self . default_format_timestamp ( Some ( TimestampPrecision :: Micros ) )
546
+ }
547
+
548
+ /// Configures the timestamp to use nanosecond precision.
549
+ pub fn default_format_timestamp_nanos ( & mut self ) -> & mut Self {
550
+ self . default_format_timestamp ( Some ( TimestampPrecision :: Nanos ) )
551
+ }
552
+
557
553
/// Adds a directive to the filter for a specific module.
558
554
///
559
555
/// # Examples
0 commit comments