Skip to content

Commit

Permalink
[0.28.3] Add special handling for empty current infix to `Naming::Tim…
Browse files Browse the repository at this point in the history
…estampsCustomFormat`
  • Loading branch information
emabee committed Jun 10, 2024
1 parent 7426938 commit 9fc7e94
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
18 changes: 12 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ 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.28.2] - 2024-06-01
## [0.28.3] - 2024-06-10

Add special handling for empty current infix to `Naming::TimestampsCustomFormat`
([issue #161](https://github.com/emabee/flexi_logger/issues/161)).

## [0.28.2] - 2024-06-09

Add variant `Naming::TimestampsCustomFormat`, kudos to [jb-alvarado](https://github.com/jb-alvarado).

Expand Down Expand Up @@ -44,12 +49,13 @@ Fix [issue #152](https://github.com/emabee/flexi_logger/issues/152).

## [0.27.2] - 2023-09-27

Fix wrong timestamp handling for the second rotation (second part of issue #150).
Fix wrong timestamp handling for the second rotation (second part of
[issue #150](https://github.com/emabee/flexi_logger/issues/150)).

## [0.27.1] - 2023-09-27

Fix issues with sub-second rotations and with cleanup when all logfiles should be compressed
(issue #150).
([issue #150](https://github.com/emabee/flexi_logger/issues/150)).

## [0.27.0] - 2023-09-20

Expand All @@ -62,15 +68,15 @@ Extend impact of `LoggerHande::trigger_rotation()` to all configured writers.
## [0.26.1] - 2023-09-19

Introduce new naming variants that work without `_rCURRENT` files: `Naming::TimestampsDirect`
and `Naming::NumbersDirect` (fixes #127).
and `Naming::NumbersDirect` (delivers #127).

Improve documentation of filename handling.

Introduce `LoggerHandle.trigger_rotation()` (fixes #147).
Introduce `LoggerHandle.trigger_rotation()` (delivers #147).

## [0.26.0] - 2023-08-30

Re-open output also for other writers (fixes #143).
Re-open output also for other writers (delivers #143).

Rename method to re-open output from LoggerHandle (leads to version bump).

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.28.2"
version = "0.28.3"
authors = ["emabee <meinolf.block@sap.com>"]
categories = ["development-tools::debugging"]
description = """
Expand Down
4 changes: 3 additions & 1 deletion src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ pub enum Naming {
/// See <https://docs.rs/chrono/latest/chrono/format/strftime/index.html> for a list of
/// supported specifiers.
///
/// Make sure you use a format that is compatible to your file system(s).
///
/// Examples:
///
/// `"%Y-%m-%d"` produces timestamp infixes like `"2024-06-09"`.
///
/// `"%Y-%m-%d_%H:%M:%S"` produces timestamp infixes like `"2024-06-09_13:24:35"`.
/// `"%Y-%m-%d_%H-%M-%S"` produces timestamp infixes like `"2024-06-09_13-24-35"`.
format: &'static str,
},

Expand Down
10 changes: 7 additions & 3 deletions src/writers/file_log_writer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,13 @@ impl State {
}

fn prepend_underscore(infix: &str) -> String {
let mut infix_with_underscore = "_".to_string();
infix_with_underscore.push_str(infix);
infix_with_underscore
if infix.is_empty() {
infix.to_string()
} else {
let mut infix_with_underscore = "_".to_string();
infix_with_underscore.push_str(infix);
infix_with_underscore
}
}

fn validate_logs_in_file(
Expand Down
15 changes: 11 additions & 4 deletions tests/test_rotate_naming_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use flexi_logger::{Age, Cleanup, Criterion, Duplicate, FileSpec, Logger, Naming}
use glob::glob;
use log::*;

const COUNT: u8 = 9;
const COUNT: u8 = 10;

#[test]
fn test_rotate_naming_variants() {
Expand Down Expand Up @@ -44,9 +44,16 @@ fn work(value: u8) {
},
Criterion::Age(Age::Second),
),
7 => test_variant(Naming::Numbers, Criterion::Age(Age::Second)),
8 => test_variant(Naming::NumbersDirect, Criterion::Age(Age::Second)),
COUNT..=u8::MAX => unreachable!("asAS"),
7 => test_variant(
Naming::TimestampsCustomFormat {
current_infix: Some(""),
format: "%Y-%m-%d_%H-%M-%S",
},
Criterion::Age(Age::Second),
),
8 => test_variant(Naming::Numbers, Criterion::Age(Age::Second)),
9 => test_variant(Naming::NumbersDirect, Criterion::Age(Age::Second)),
COUNT..=u8::MAX => unreachable!("Wrong dispatch"),
}
}

Expand Down

0 comments on commit 9fc7e94

Please sign in to comment.