Skip to content

Commit

Permalink
Code maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
emabee committed Oct 1, 2024
1 parent 673eb65 commit b8b0dc5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ nu-ansi-term = { version = "0.50", optional = true }
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
crossbeam-channel = { version = "0.5", optional = true }
crossbeam-queue = { version = "0.3", optional = true }
flate2 = { version = "1.0", optional = true }
flate2 = { version = "1.0", optional = true, features = ["rust_backend"] }
glob = "0.3"
hostname = { version = "0.4", optional = true }
log = { version = "0.4", features = ["std"] }
Expand Down
2 changes: 1 addition & 1 deletion src/parameters/age.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The age after which a log file rotation will be triggered,
/// when [`Criterion::Age`] is chosen.
/// when [Criterion::Age](crate::Criterion::Age) is chosen.
#[derive(Copy, Clone, Debug)]
pub enum Age {
/// Rotate the log file when the local clock has started a new day since the
Expand Down
1 change: 0 additions & 1 deletion src/writers/syslog/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl LineWriter {
format: FormatFunction,
) -> IoResult<LineWriter> {
const UNKNOWN_HOSTNAME: &str = "<unknown_hostname>";
// FIXME
Ok(LineWriter {
header,
hostname: hostname::get().map_or_else(
Expand Down
14 changes: 8 additions & 6 deletions tests/test_rotate_immediate_compression.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
mod test_utils;

#[cfg(feature = "compress")]
use chrono::Local;
#[cfg(feature = "compress")]
use flexi_logger::{Age, Cleanup, Criterion, Duplicate, FileSpec, Logger, Naming};
#[cfg(feature = "compress")]
Expand Down Expand Up @@ -47,6 +45,8 @@ fn work(value: u8) {

#[cfg(feature = "compress")]
fn test_variant(naming: Naming, criterion: Criterion, cleanup: Cleanup) {
use std::time::{Duration, Instant};

let directory = test_utils::dir();

test_utils::wait_for_start_of_second();
Expand All @@ -70,15 +70,17 @@ fn test_variant(naming: Naming, criterion: Criterion, cleanup: Cleanup) {
}
);
let mut written_lines = 1;
let start = Local::now();
let duration = chrono::Duration::from_std(std::time::Duration::from_millis(3200)).unwrap();
while Local::now() - start < duration {

let start = Instant::now();
let max_runtime = Duration::from_millis(3_200);
let sleep_time = Duration::from_millis(7);
while Instant::now() - start < max_runtime {
written_lines += 1;
if written_lines % 17 == 4 {
logger.trigger_rotation().unwrap();
}
trace!("line_count = {written_lines}");
std::thread::sleep(std::time::Duration::from_millis(7));
std::thread::sleep(sleep_time);
}

std::thread::sleep(std::time::Duration::from_millis(100));
Expand Down

0 comments on commit b8b0dc5

Please sign in to comment.