Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Optimize the Zoned::now().with_time_zone #52

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/layout/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::fmt::Arguments;

use jiff::tz::TimeZone;
use jiff::Timestamp;
use jiff::Zoned;
use log::Record;
use serde::Serialize;
Expand Down Expand Up @@ -97,7 +98,7 @@ impl JsonLayout {

let record_line = RecordLine {
timestamp: match self.tz.clone() {
Some(tz) => Zoned::now().with_time_zone(tz),
Some(tz) => Timestamp::now().to_zoned(tz),
None => Zoned::now(),
},
level: record.level().as_str(),
Expand Down
3 changes: 2 additions & 1 deletion src/layout/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use colored::Color;
use colored::ColoredString;
use colored::Colorize;
use jiff::tz::TimeZone;
use jiff::Timestamp;
use jiff::Zoned;
use log::Level;

Expand Down Expand Up @@ -135,7 +136,7 @@ impl TextLayout {
F: Fn(Arguments) -> anyhow::Result<()>,
{
let time = match self.tz.clone() {
Some(tz) => Zoned::now().with_time_zone(tz),
Some(tz) => Timestamp::now().to_zoned(tz),
None => Zoned::now(),
}
.strftime("%Y-%m-%dT%H:%M:%S.%6f%:z");
Expand Down