Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
needs: msrv
strategy:
matrix:
os: [ ubuntu-24.04, macos-14, windows-2022 ]
os: [ ubuntu-24.04, macos-15, windows-2022 ]
rust-version: ${{ fromJson(needs.msrv.outputs.rust-versions) }}
runs-on: ${{ matrix.os }}
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.

* Bump minimum supported Rust version (MSRV) to 1.91.0.
* `logforth-append-opentelemetry` upgrades `opentelemetry`, `opentelemetry-otlp` and `opentelemetry_sdk` to 0.33.1.
* Upgrade `jiff` to 1.0.

## [0.30.1] 2026-06-03

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ctor = { version = "1.0.6" }
fastrace = { version = "0.7" }
fasyslog = { version = "1.0.0" }
insta = { version = "1.43.2" }
jiff = { version = "0.2" }
jiff = { version = "1.0" }
libc = { version = "0.2.162" }
log = { version = "0.4.31", default-features = false }
oneshot = { version = "0.2.1", default-features = false, features = ["std"] }
Expand Down
7 changes: 5 additions & 2 deletions appenders/fastrace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use std::borrow::Cow;

use jiff::Zoned;
use jiff::ZonedDateTime;
use logforth_core::Diagnostic;
use logforth_core::Error;
use logforth_core::append::Append;
Expand Down Expand Up @@ -65,7 +65,10 @@ impl Append for FastraceEvent {
|| {
[
(Cow::from("level"), Cow::from(record.level().name())),
(Cow::from("timestamp"), Cow::from(Zoned::now().to_string())),
(
Cow::from("timestamp"),
Cow::from(ZonedDateTime::now().to_string()),
),
]
.into_iter()
.chain(collector.kv)
Expand Down
20 changes: 10 additions & 10 deletions appenders/file/src/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use jiff::Zoned;
use jiff::ZonedDateTime;

#[derive(Debug)]
pub enum Clock {
Expand All @@ -22,16 +22,16 @@ pub enum Clock {
}

impl Clock {
pub fn now(&self) -> Zoned {
pub fn now(&self) -> ZonedDateTime {
match self {
Clock::DefaultClock => Zoned::now(),
Clock::DefaultClock => ZonedDateTime::now(),
#[cfg(test)]
Clock::ManualClock(clock) => clock.now(),
}
}

#[cfg(test)]
pub fn set_now(&mut self, now: Zoned) {
pub fn set_now(&mut self, now: ZonedDateTime) {
if let Clock::ManualClock(clock) = self {
clock.set_now(now);
}
Expand All @@ -42,20 +42,20 @@ impl Clock {
#[derive(Debug)]
#[cfg(test)]
pub struct ManualClock {
now: Zoned,
now: ZonedDateTime,
}

#[cfg(test)]
impl ManualClock {
pub fn new(now: Zoned) -> ManualClock {
pub fn new(now: ZonedDateTime) -> ManualClock {
ManualClock { now }
}

fn now(&self) -> Zoned {
fn now(&self) -> ZonedDateTime {
self.now.clone()
}

pub fn set_now(&mut self, now: Zoned) {
pub fn set_now(&mut self, now: ZonedDateTime) {
self.now = now;
}
}
Expand All @@ -68,11 +68,11 @@ mod tests {

#[test]
fn test_manual_clock_adjusting() {
let now = Zoned::from_str("2024-08-10T17:12:52+08[+08]").unwrap();
let now = ZonedDateTime::from_str("2024-08-10T17:12:52+08[+08]").unwrap();
let mut clock = ManualClock { now: now.clone() };
assert_eq!(clock.now(), now);

let now = Zoned::from_str("2024-01-01T12:00:00+08[+08]").unwrap();
let now = ZonedDateTime::from_str("2024-01-01T12:00:00+08[+08]").unwrap();
clock.set_now(now.clone());
assert_eq!(clock.now(), now);
}
Expand Down
20 changes: 10 additions & 10 deletions appenders/file/src/rolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;

use jiff::Zoned;
use jiff::ZonedDateTime;
use jiff::civil::DateTime;
use logforth_core::Error;
use logforth_core::Trap;
Expand Down Expand Up @@ -214,7 +214,7 @@ struct State {
date_format: &'static str,
rotation: Rotation,
current_filesize: usize,
this_date_timestamp: Zoned,
this_date_timestamp: ZonedDateTime,
next_date_timestamp: Option<usize>,
max_size: Option<NonZeroUsize>,
max_files: Option<NonZeroUsize>,
Expand Down Expand Up @@ -274,7 +274,7 @@ impl State {
state.current_filesize = last.metadata.len() as usize;

if let Ok(mtime) = last.metadata.modified()
&& let Ok(mtime) = Zoned::try_from(mtime)
&& let Ok(mtime) = ZonedDateTime::try_from(mtime)
{
state.next_date_timestamp = state.rotation.next_date_timestamp(&mtime);
state.this_date_timestamp = mtime;
Expand Down Expand Up @@ -309,7 +309,7 @@ impl State {
.map_err(|err| Error::new("failed to create log file").with_source(err))
}

fn join_date(&self, date: &Zoned, cnt: usize) -> PathBuf {
fn join_date(&self, date: &ZonedDateTime, cnt: usize) -> PathBuf {
let date = date.strftime(self.date_format);
let filename = match (
&self.rotation,
Expand Down Expand Up @@ -420,7 +420,7 @@ impl State {
Ok(())
}

fn rotate_log_writer(&self, now: &Zoned) -> Result<File, Error> {
fn rotate_log_writer(&self, now: &ZonedDateTime) -> Result<File, Error> {
let mut renames = vec![];
for i in 1..self.max_files.map_or(usize::MAX, |n| n.get()) {
let filepath = self.join_date(now, i);
Expand Down Expand Up @@ -458,7 +458,7 @@ impl State {
self.create_log_writer()
}

fn refresh_writer(&self, now: &Zoned, file: &mut File) {
fn refresh_writer(&self, now: &ZonedDateTime, file: &mut File) {
match self.rotate_log_writer(now) {
Ok(new_file) => {
if let Err(err) = file.flush() {
Expand All @@ -474,7 +474,7 @@ impl State {
}
}

fn should_rollover_on_date(&self, date: &Zoned) -> bool {
fn should_rollover_on_date(&self, date: &ZonedDateTime) -> bool {
self.next_date_timestamp
.is_some_and(|ts| date.timestamp().as_millisecond() as usize >= ts)
}
Expand All @@ -495,7 +495,7 @@ mod tests {
use std::str::FromStr;

use jiff::Span;
use jiff::Zoned;
use jiff::ZonedDateTime;
use rand::RngExt;
use rand::distr::Alphanumeric;
use tempfile::TempDir;
Expand Down Expand Up @@ -572,7 +572,7 @@ mod tests {
let max_files = NonZeroUsize::new(10).unwrap();
let temp_dir = TempDir::new().unwrap();

let start_time = Zoned::from_str("2024-08-10T00:00:00[UTC]").unwrap();
let start_time = ZonedDateTime::from_str("2024-08-10T00:00:00[UTC]").unwrap();
let mut writer = RollingFileWriterBuilder::new(temp_dir.as_ref(), "test_file")
.rotation(rotation)
.filename_suffix("log")
Expand Down Expand Up @@ -637,7 +637,7 @@ mod tests {
let total_files = 100;
let temp_dir = TempDir::new().unwrap();

let start_time = Zoned::from_str("2024-08-10T00:00:00[UTC]").unwrap();
let start_time = ZonedDateTime::from_str("2024-08-10T00:00:00[UTC]").unwrap();
let mut writer = RollingFileWriterBuilder::new(temp_dir.as_ref(), "test_file")
.rotation(rotation)
.filename_suffix("log")
Expand Down
12 changes: 6 additions & 6 deletions appenders/file/src/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use jiff::RoundMode;
use jiff::ToSpan;
use jiff::Unit;
use jiff::Zoned;
use jiff::ZonedRound;
use jiff::ZonedDateTime;
use jiff::ZonedDateTimeRound;

/// Rotation policies for rolling files.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand All @@ -33,8 +33,8 @@ pub enum Rotation {

impl Rotation {
/// Get the next date timestamp based on the current date and rotation policy.
pub fn next_date_timestamp(&self, current_date: &Zoned) -> Option<usize> {
let round = ZonedRound::new().mode(RoundMode::Trunc);
pub fn next_date_timestamp(&self, current_date: &ZonedDateTime) -> Option<usize> {
let round = ZonedDateTimeRound::new().mode(RoundMode::Trunc);
let next_date = match *self {
Rotation::Never => return None,
Rotation::Minutely => (current_date + 1.minute()).round(round.smallest(Unit::Minute)),
Expand Down Expand Up @@ -62,13 +62,13 @@ mod tests {
use std::str::FromStr;

use jiff::Timestamp;
use jiff::Zoned;
use jiff::ZonedDateTime;

use super::Rotation;

#[test]
fn test_next_date_timestamp() {
let current_date = Zoned::from_str("2024-08-10T17:12:52+08[+08]").unwrap();
let current_date = ZonedDateTime::from_str("2024-08-10T17:12:52+08[+08]").unwrap();

assert_eq!(Rotation::Never.next_date_timestamp(&current_date), None);

Expand Down
Loading