Skip to content

Commit

Permalink
Fix wrong timestamp handling during rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
emabee committed Sep 27, 2023
1 parent e892b8f commit 2f1ab2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.27.1] - 2023-09-20
## [0.27.2] - 2023-09-27

Fix wrong timestamp handling for the second rotation (second part of issue #150).

## [0.27.1] - 2023-09-27

Fix issues with sub-second rotations and with cleanup when all logfiles should be compressed
(issue #150).
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flexi_logger"
version = "0.27.1"
version = "0.27.2"
authors = ["emabee <meinolf.block@sap.com>"]
categories = ["development-tools::debugging"]
description = """
Expand Down
10 changes: 4 additions & 6 deletions src/writers/file_log_writer/state/timestamps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,23 @@ pub(super) fn rcurrents_creation_date(
) -> Result<DateTime<Local>, std::io::Error> {
let current_path = config.file_spec.as_pathbuf(Some(CURRENT_INFIX));

Ok(if rotate_rcurrent {
if rotate_rcurrent {
let date_for_rotated_file = o_date_for_rotated_file
.copied()
.unwrap_or_else(|| get_creation_date(&current_path));
let rotated_path =
path_for_rotated_file(&config.file_spec, config.use_utc, &date_for_rotated_file);

match std::fs::rename(current_path, rotated_path.clone()) {
match std::fs::rename(current_path.clone(), rotated_path.clone()) {
Ok(()) => {}
Err(e) => {
if e.kind() != std::io::ErrorKind::NotFound {
return Err(e);
}
}
}
get_creation_date(&rotated_path)
} else {
get_creation_date(&current_path)
})
}
Ok(get_creation_date(&current_path))
}

// determine the timestamp to which we want to write (file needn't exist)
Expand Down

0 comments on commit 2f1ab2d

Please sign in to comment.