Skip to content

Commit

Permalink
[0.29.7] Fix issue 184
Browse files Browse the repository at this point in the history
  • Loading branch information
emabee committed Dec 10, 2024
1 parent 2d04ec4 commit 871d1e5
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
rust: [ stable, 1.70.0 ]
rust: [ stable, 1.72.0 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ 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.25.7] - 2024-12-10

Fix issue #184.

Update dependencies.

Bump minimal supported rust version to 1.72.0.

## [0.25.6] - 2024-11-02

Allow for custom process names when using the syslog writer (PR #182, kudos to
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flexi_logger"
version = "0.29.6"
version = "0.29.7"
authors = ["emabee <[email protected]>"]
categories = ["development-tools::debugging"]
description = """
Expand All @@ -14,7 +14,7 @@ keywords = ["file", "logger"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/emabee/flexi_logger"
rust-version = "1.70.0"
rust-version = "1.72.0"

[lib]
doctest = false
Expand Down Expand Up @@ -48,12 +48,12 @@ crossbeam-queue = { version = "0.3", optional = true }
flate2 = { version = "1.0", optional = true, features = ["rust_backend"] }
hostname = { version = "0.4", optional = true }
log = { version = "0.4", features = ["std"] }
notify-debouncer-mini = { version = "0.4.1", optional = true, default-features = false }
notify-debouncer-mini = { version = "0.5", optional = true, default-features = false }
regex = { version = "1.1", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
thiserror = "1.0"
thiserror = "2.0"
toml = { version = "0.8", optional = true }
tracing = { version = "0.1.36", optional = true }
tracing-subscriber = { version = "0.3", optional = true, features = [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ See

## Minimal rust version

The minimal supported rust version is currently "1.70.0".
The minimal supported rust version is currently "1.72.0".

## Crate Features

Expand Down
6 changes: 3 additions & 3 deletions scripts/qualify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ fn main() {

// Build in important variants
std::fs::remove_file("Cargo.lock").ok();
run_command!("cargo +1.70.0 build --no-default-features");
run_command!("cargo +1.70.0 build --all-features");
run_command!("cargo +1.72.0 build --no-default-features");
run_command!("cargo +1.72.0 build --all-features");

std::fs::remove_file("Cargo.lock").ok();
run_command!("cargo build");
Expand All @@ -69,7 +69,7 @@ fn main() {
run_command!("cargo +nightly clippy --all-targets --all-features -- -D warnings");

// Run tests in important variants
run_command!("cargo +1.70.0 test --all-features");
run_command!("cargo +1.72.0 test --all-features");
run_command!("cargo test --release --all-features");
run_command!("cargo test --no-default-features");
run_command!("cargo test --release");
Expand Down
32 changes: 20 additions & 12 deletions src/parameters/file_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,35 +243,30 @@ impl FileSpec {
self.o_suffix.clone()
}

// basename + o_discriminant + o_timestamp
pub(crate) fn fixed_name_part(&self) -> String {
let mut fixed_name_part = self.basename.clone();
fixed_name_part.reserve(50);

if let Some(discriminant) = &self.o_discriminant {
FileSpec::separate_with_underscore(&mut fixed_name_part);
append_underscore_if_not_empty(&mut fixed_name_part);
fixed_name_part.push_str(discriminant);
}
if let Some(timestamp) = &self.timestamp_cfg.get_timestamp() {
FileSpec::separate_with_underscore(&mut fixed_name_part);
append_underscore_if_not_empty(&mut fixed_name_part);
fixed_name_part.push_str(timestamp);
}
fixed_name_part
}

fn separate_with_underscore(filename: &mut String) {
if !filename.is_empty() {
filename.push('_');
}
}

/// Derives a `PathBuf` from the spec and the given infix.
#[must_use]
pub fn as_pathbuf(&self, o_infix: Option<&str>) -> PathBuf {
let mut filename = self.fixed_name_part();

if let Some(infix) = o_infix {
if !infix.is_empty() {
FileSpec::separate_with_underscore(&mut filename);
append_underscore_if_not_empty(&mut filename);
filename.push_str(infix);
}
};
Expand All @@ -287,9 +282,16 @@ impl FileSpec {

// handles collisions by appending ".restart-<number>" to the infix, if necessary
pub(crate) fn collision_free_infix_for_rotated_file(&self, infix: &str) -> String {
let mut restart_siblings = self
.read_dir_related_files()
let uncompressed_files = self.list_of_files(
&InfixFilter::Equls(infix.to_string()),
self.o_suffix.as_deref(),
);
let compressed_files =
self.list_of_files(&InfixFilter::Equls(infix.to_string()), Some("gz"));

let mut restart_siblings = uncompressed_files
.into_iter()
.chain(compressed_files)
.filter(|pb| {
// ignore .gz suffix
let mut pb2 = PathBuf::from(pb);
Expand Down Expand Up @@ -418,6 +420,12 @@ impl FileSpec {
}
}

fn append_underscore_if_not_empty(filename: &mut String) {
if !filename.is_empty() {
filename.push('_');
}
}

const TS_USCORE_DASHES_USCORE_DASHES: &str = "%Y-%m-%d_%H-%M-%S";

#[derive(Debug, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -501,7 +509,7 @@ mod test {
);
} else {
assert_eq!(
stem.as_bytes().len(),
stem.len(),
progname.len(),
"stem: {stem:?}, progname: {progname:?}",
);
Expand Down
3 changes: 1 addition & 2 deletions src/writers/file_log_writer/infix_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ impl InfixFilter {
pub(crate) fn filter_infix(&self, infix: &str) -> bool {
match self {
InfixFilter::Timstmps(infix_format) => {
let tmp = timestamp_from_ts_infix(infix, infix_format);
tmp.is_ok()
timestamp_from_ts_infix(infix, infix_format).is_ok()
}
InfixFilter::Numbrs => {
if infix.len() > 2 {
Expand Down
7 changes: 4 additions & 3 deletions src/writers/file_log_writer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,11 @@ impl Inner {
}
fn infix_filter(&self) -> InfixFilter {
match self {
Inner::Initial(_o_r, _) => None,
Inner::Active(o_r, _, _) => o_r.as_ref().map(|rs| rs.naming_state.infix_filter()),
Inner::Initial(_o_r, _) => InfixFilter::None,
Inner::Active(o_r, _, _) => o_r
.as_ref()
.map_or(InfixFilter::None, |rs| rs.naming_state.infix_filter()),
}
.unwrap_or(InfixFilter::None)
}
}
impl std::fmt::Debug for Inner {
Expand Down

0 comments on commit 871d1e5

Please sign in to comment.