Skip to content

Commit 653de06

Browse files
committed
feat(server): implement log rotation based on size and retention
- implemented log rotation based on size and retention as the title; - implemented configurable attributions and imported breaking changes; - added units and integration test in logger.rs and intergration mod; - added documentations and imported new dependencies, etc. Details can be looked up at Apache Iggy #2452
1 parent 86a10de commit 653de06

File tree

14 files changed

+1011
-199
lines changed

14 files changed

+1011
-199
lines changed

Cargo.lock

Lines changed: 164 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DEPENDENCIES.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ backon: 1.6.0, "Apache-2.0",
8484
base16ct: 0.2.0, "Apache-2.0 OR MIT",
8585
base64: 0.21.7, "Apache-2.0 OR MIT",
8686
base64: 0.22.1, "Apache-2.0 OR MIT",
87-
base64ct: 1.8.1, "Apache-2.0 OR MIT",
87+
base64ct: 1.8.2, "Apache-2.0 OR MIT",
8888
bdd: 0.0.1, "Apache-2.0",
8989
beef: 0.5.2, "Apache-2.0 OR MIT",
9090
bench-dashboard-frontend: 0.4.1, "Apache-2.0",
@@ -136,9 +136,9 @@ charming: 0.6.0, "Apache-2.0 OR MIT",
136136
charming_macros: 0.1.0, "Apache-2.0 OR MIT",
137137
chrono: 0.4.42, "Apache-2.0 OR MIT",
138138
cipher: 0.4.4, "Apache-2.0 OR MIT",
139-
clap: 4.5.53, "Apache-2.0 OR MIT",
140-
clap_builder: 4.5.53, "Apache-2.0 OR MIT",
141-
clap_complete: 4.5.63, "Apache-2.0 OR MIT",
139+
clap: 4.5.54, "Apache-2.0 OR MIT",
140+
clap_builder: 4.5.54, "Apache-2.0 OR MIT",
141+
clap_complete: 4.5.64, "Apache-2.0 OR MIT",
142142
clap_derive: 4.5.49, "Apache-2.0 OR MIT",
143143
clap_lex: 0.7.6, "Apache-2.0 OR MIT",
144144
clock: 0.1.0, "N/A",
@@ -280,12 +280,12 @@ extension-traits: 1.0.1, "Apache-2.0 OR MIT OR Zlib",
280280
fast-async-mutex: 0.6.7, "Apache-2.0 OR MIT",
281281
fastbloom: 0.14.0, "Apache-2.0 OR MIT",
282282
fastrand: 2.3.0, "Apache-2.0 OR MIT",
283-
ferroid: 0.8.8, "Apache-2.0 OR MIT",
283+
ferroid: 0.8.9, "Apache-2.0 OR MIT",
284284
ff: 0.13.1, "Apache-2.0 OR MIT",
285285
fiat-crypto: 0.2.9, "Apache-2.0 OR BSD-1-Clause OR MIT",
286286
figlet-rs: 0.1.5, "Apache-2.0",
287287
figment: 0.10.19, "Apache-2.0 OR MIT",
288-
file-operation: 0.8.8, "MIT",
288+
file-operation: 0.8.10, "MIT",
289289
filetime: 0.2.26, "Apache-2.0 OR MIT",
290290
find-msvc-tools: 0.1.6, "Apache-2.0 OR MIT",
291291
flatbuffers: 25.12.19, "Apache-2.0",
@@ -301,6 +301,7 @@ foreign-types-shared: 0.1.1, "Apache-2.0 OR MIT",
301301
form_urlencoded: 1.2.2, "Apache-2.0 OR MIT",
302302
fragile: 2.0.1, "Apache-2.0",
303303
fs-err: 3.2.2, "Apache-2.0 OR MIT",
304+
fs2: 0.4.3, "Apache-2.0 OR MIT",
304305
fs_extra: 1.3.0, "MIT",
305306
fsevent-sys: 4.1.0, "MIT",
306307
funty: 2.0.0, "MIT",
@@ -344,7 +345,7 @@ h2: 0.3.27, "MIT",
344345
h2: 0.4.12, "MIT",
345346
half: 2.7.1, "Apache-2.0 OR MIT",
346347
halfbrown: 0.4.0, "Apache-2.0 OR MIT",
347-
handlebars: 6.3.2, "MIT",
348+
handlebars: 6.4.0, "MIT",
348349
hash32: 0.2.1, "Apache-2.0 OR MIT",
349350
hash32: 1.0.0, "Apache-2.0 OR MIT",
350351
hashbrown: 0.12.3, "Apache-2.0 OR MIT",
@@ -455,7 +456,7 @@ lexical-util: 1.0.7, "Apache-2.0 OR MIT",
455456
lexical-write-float: 1.0.6, "Apache-2.0 OR MIT",
456457
lexical-write-integer: 1.0.6, "Apache-2.0 OR MIT",
457458
libbz2-rs-sys: 0.2.2, "bzip2-1.0.6",
458-
libc: 0.2.178, "Apache-2.0 OR MIT",
459+
libc: 0.2.179, "Apache-2.0 OR MIT",
459460
libdbus-sys: 0.2.7, "Apache-2.0 OR MIT",
460461
libflate: 2.2.1, "MIT",
461462
libflate_lz77: 2.2.0, "MIT",
@@ -533,7 +534,7 @@ objc2: 0.6.3, "MIT",
533534
objc2-core-foundation: 0.3.2, "Apache-2.0 OR MIT OR Zlib",
534535
objc2-encode: 4.1.0, "MIT",
535536
objc2-io-kit: 0.3.2, "Apache-2.0 OR MIT OR Zlib",
536-
octocrab: 0.49.4, "Apache-2.0 OR MIT",
537+
octocrab: 0.49.5, "Apache-2.0 OR MIT",
537538
oid-registry: 0.8.1, "Apache-2.0 OR MIT",
538539
once_cell: 1.21.3, "Apache-2.0 OR MIT",
539540
once_cell_polyfill: 1.70.2, "Apache-2.0 OR MIT",
@@ -579,10 +580,10 @@ peg-runtime: 0.6.3, "MIT",
579580
pem: 3.0.6, "MIT",
580581
pem-rfc7468: 0.7.0, "Apache-2.0 OR MIT",
581582
percent-encoding: 2.3.2, "Apache-2.0 OR MIT",
582-
pest: 2.8.4, "Apache-2.0 OR MIT",
583-
pest_derive: 2.8.4, "Apache-2.0 OR MIT",
584-
pest_generator: 2.8.4, "Apache-2.0 OR MIT",
585-
pest_meta: 2.8.4, "Apache-2.0 OR MIT",
583+
pest: 2.8.5, "Apache-2.0 OR MIT",
584+
pest_derive: 2.8.5, "Apache-2.0 OR MIT",
585+
pest_generator: 2.8.5, "Apache-2.0 OR MIT",
586+
pest_meta: 2.8.5, "Apache-2.0 OR MIT",
586587
pin-project: 1.1.10, "Apache-2.0 OR MIT",
587588
pin-project-internal: 1.1.10, "Apache-2.0 OR MIT",
588589
pin-project-lite: 0.2.16, "Apache-2.0 OR MIT",
@@ -670,6 +671,7 @@ rmcp-macros: 0.12.0, "MIT",
670671
rmp: 0.8.15, "MIT",
671672
rmp-serde: 1.3.1, "MIT",
672673
roaring: 0.10.12, "Apache-2.0 OR MIT",
674+
rolling-file: 0.2.0, "Apache-2.0 OR MIT",
673675
route-recognizer: 0.3.1, "MIT",
674676
rsa: 0.9.9, "Apache-2.0 OR MIT",
675677
rust-embed: 8.9.0, "MIT",
@@ -724,8 +726,8 @@ serde_urlencoded: 0.7.1, "Apache-2.0 OR MIT",
724726
serde_with: 3.16.1, "Apache-2.0 OR MIT",
725727
serde_with_macros: 3.16.1, "Apache-2.0 OR MIT",
726728
serde_yaml_ng: 0.10.0, "MIT",
727-
serial_test: 3.2.0, "MIT",
728-
serial_test_derive: 3.2.0, "MIT",
729+
serial_test: 3.3.1, "MIT",
730+
serial_test_derive: 3.3.1, "MIT",
729731
server: 0.6.1-edge.3, "Apache-2.0",
730732
sha1: 0.10.6, "Apache-2.0 OR MIT",
731733
sha2: 0.10.9, "Apache-2.0 OR MIT",
@@ -771,7 +773,7 @@ strum_macros: 0.26.4, "MIT",
771773
strum_macros: 0.27.2, "MIT",
772774
subtle: 2.6.1, "BSD-3-Clause",
773775
syn: 1.0.109, "Apache-2.0 OR MIT",
774-
syn: 2.0.111, "Apache-2.0 OR MIT",
776+
syn: 2.0.113, "Apache-2.0 OR MIT",
775777
sync_wrapper: 1.0.2, "Apache-2.0",
776778
synstructure: 0.13.2, "MIT",
777779
synthez: 0.4.0, "BlueOak-1.0.0",
@@ -805,12 +807,12 @@ tiny-keccak: 2.0.2, "CC0-1.0",
805807
tinystr: 0.8.2, "Unicode-3.0",
806808
tinyvec: 1.10.0, "Apache-2.0 OR MIT OR Zlib",
807809
tinyvec_macros: 0.1.1, "Apache-2.0 OR MIT OR Zlib",
808-
tokio: 1.48.0, "MIT",
810+
tokio: 1.49.0, "MIT",
809811
tokio-macros: 2.6.0, "MIT",
810812
tokio-rustls: 0.26.4, "Apache-2.0 OR MIT",
811-
tokio-stream: 0.1.17, "MIT",
813+
tokio-stream: 0.1.18, "MIT",
812814
tokio-tungstenite: 0.28.0, "MIT",
813-
tokio-util: 0.7.17, "MIT",
815+
tokio-util: 0.7.18, "MIT",
814816
tokise: 0.2.0, "Apache-2.0 OR MIT",
815817
toml: 0.8.23, "Apache-2.0 OR MIT",
816818
toml: 0.9.10+spec-1.1.0, "Apache-2.0 OR MIT",
@@ -896,9 +898,9 @@ wasm-streams: 0.4.2, "Apache-2.0 OR MIT",
896898
wasmtimer: 0.4.3, "MIT",
897899
web-sys: 0.3.83, "Apache-2.0 OR MIT",
898900
web-time: 1.1.0, "Apache-2.0 OR MIT",
899-
webpki-root-certs: 1.0.4, "CDLA-Permissive-2.0",
901+
webpki-root-certs: 1.0.5, "CDLA-Permissive-2.0",
900902
webpki-roots: 0.26.11, "CDLA-Permissive-2.0",
901-
webpki-roots: 1.0.4, "CDLA-Permissive-2.0",
903+
webpki-roots: 1.0.5, "CDLA-Permissive-2.0",
902904
whoami: 1.6.1, "Apache-2.0 OR BSL-1.0 OR MIT",
903905
widestring: 1.2.1, "Apache-2.0 OR MIT",
904906
winapi: 0.3.9, "Apache-2.0 OR MIT",
@@ -991,7 +993,7 @@ zerovec: 0.11.5, "Unicode-3.0",
991993
zerovec-derive: 0.11.2, "Unicode-3.0",
992994
zip: 7.0.0, "MIT",
993995
zlib-rs: 0.5.5, "Zlib",
994-
zmij: 1.0.3, "MIT",
996+
zmij: 1.0.10, "MIT",
995997
zopfli: 0.8.3, "Apache-2.0",
996998
zstd: 0.13.3, "MIT",
997999
zstd-safe: 7.2.4, "Apache-2.0 OR MIT",

core/common/src/utils/duration.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,35 @@ use std::{
2929

3030
pub const SEC_IN_MICRO: u64 = 1_000_000;
3131

32+
/// A struct for representing time durations with various utility functions.
33+
///
34+
/// This struct wraps `std::time::Duration` and uses the `humantime` crate for parsing and formatting
35+
/// human-readable duration strings. It also implements serialization and deserialization via the `serde` crate.
36+
///
37+
/// # Example
38+
///
39+
/// ```
40+
/// use iggy_common::IggyDuration;
41+
/// use std::str::FromStr;
42+
///
43+
/// let duration = IggyDuration::from(3661_000_000_u64); // 3661 seconds in microseconds
44+
/// assert_eq!(3661, duration.as_secs());
45+
/// assert_eq!("1h 1m 1s", duration.as_human_time_string());
46+
/// assert_eq!("1h 1m 1s", format!("{}", duration));
47+
///
48+
/// let duration = IggyDuration::from(0_u64);
49+
/// assert_eq!(0, duration.as_secs());
50+
/// assert_eq!("0s", duration.as_human_time_string());
51+
/// assert_eq!("0s", format!("{}", duration));
52+
///
53+
/// let duration = IggyDuration::from_str("1h 1m 1s").unwrap();
54+
/// assert_eq!(3661, duration.as_secs());
55+
/// assert_eq!("1h 1m 1s", duration.as_human_time_string());
56+
/// assert_eq!("1h 1m 1s", format!("{}", duration));
57+
///
58+
/// let duration = IggyDuration::from_str("unlimited").unwrap();
59+
/// assert_eq!(0, duration.as_secs());
60+
/// ```
3261
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
3362
pub struct IggyDuration {
3463
duration: Duration,

core/configs/server.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,17 @@ level = "info"
363363
# When enabled, logs are stored in {system.path}/{system.logging.path} (default: local_data/logs).
364364
file_enabled = true
365365

366-
# Maximum size of the log files before rotation.
367-
max_size = "512 MB"
366+
# Maximum size of a single log file before rotation occurs.
367+
# When a log file reaches this size, it will be rotated (closed and a new file created).
368+
# This setting works together with max_total_size to control log storage.
369+
max_file_size = "512 MB"
370+
371+
# Maximum total size of all log files combined.
372+
# When this size is reached, oldest files will be deleted.
373+
max_total_size = "4 GB"
374+
375+
# Time interval for checking log file size and rotation.
376+
rotation_check_interval = "1 h"
368377

369378
# Time to retain log files before deletion.
370379
retention = "7 days"

0 commit comments

Comments
 (0)