Skip to content

Commit

Permalink
Fix #178
Browse files Browse the repository at this point in the history
  • Loading branch information
emabee committed Oct 7, 2024
1 parent fea2430 commit b4c434e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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.29.2] - 2024-10-07

Fix a regression ([issue #178](https://github.com/emabee/flexi_logger/issues/178))
introduced with [0.29.1].

Fix error with rotation & append & explicit directory & Naming::Timestamps.

## [0.29.1] - 2024-10-02

Fix [issue #176](https://github.com/emabee/flexi_logger/issues/176):
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.29.1"
version = "0.29.2"
authors = ["emabee <meinolf.block@sap.com>"]
categories = ["development-tools::debugging"]
description = """
Expand Down
25 changes: 23 additions & 2 deletions src/parameters/file_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ impl FileSpec {
filename.push_str(timestamp);
}
if let Some(infix) = o_infix {
FileSpec::separate_with_underscore(&mut filename);
filename.push_str(infix);
if !infix.is_empty() {
FileSpec::separate_with_underscore(&mut filename);
filename.push_str(infix);
}
};
if let Some(suffix) = &self.o_suffix {
filename.push('.');
Expand Down Expand Up @@ -541,4 +543,23 @@ mod test {
.as_pathbuf(None);
assert!(path.file_name().is_none());
}

#[test]
fn issue_178() {
let path = FileSpec::default()
.basename("BASENAME")
.suppress_timestamp()
.as_pathbuf(Some(""));
assert_eq!(path.file_name().unwrap().to_string_lossy(), "BASENAME.log");

let path = FileSpec::default()
.basename("BASENAME")
.discriminant("1")
.suppress_timestamp()
.as_pathbuf(Some(""));
assert_eq!(
path.file_name().unwrap().to_string_lossy(),
"BASENAME_1.log"
);
}
}
7 changes: 4 additions & 3 deletions src/writers/file_log_writer/state/list_and_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ pub(super) fn list_of_log_and_compressed_files(file_spec: &FileSpec) -> Vec<Path
)
}

pub(super) fn list_of_infix_files() -> Vec<PathBuf> {
list_of_files(INFIX_PATTERN)
pub(super) fn list_of_infix_files(file_spec: &FileSpec) -> Vec<PathBuf> {
let pattern = file_spec.as_glob_pattern(INFIX_PATTERN, file_spec.get_suffix().as_deref());
list_of_files(&pattern)
}
fn list_of_files(pattern: &str) -> Vec<PathBuf> {
let mut log_files: Vec<PathBuf> = glob::glob(pattern)
Expand All @@ -60,7 +61,7 @@ fn list_of_files(pattern: &str) -> Vec<PathBuf> {
}

pub(super) fn remove_or_compress_too_old_logfiles(
o_cleanup_thread_handle: &Option<CleanupThreadHandle>,
o_cleanup_thread_handle: Option<&CleanupThreadHandle>,
cleanup_config: &Cleanup,
file_spec: &FileSpec,
writes_direct: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/writers/file_log_writer/state/timestamps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub(super) fn latest_timestamp_file(
Local::now()
} else {
// find all file paths that fit the pattern
list_of_infix_files()
list_of_infix_files(&config.file_spec)
.into_iter()
// retrieve the infix
.map(|path| ts_infix_from_path(&path, &config.file_spec))
Expand Down

0 comments on commit b4c434e

Please sign in to comment.