Skip to content

Commit ca6b17a

Browse files
committed
msrv 1.75, update deps
1 parent d4e6cbe commit ca6b17a

File tree

6 files changed

+65
-33
lines changed

6 files changed

+65
-33
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
20-
rust_versions: ["stable", "1.69"]
20+
rust_versions: ["stable", "1.75"]
2121
os: [ubuntu-latest, windows-latest]
2222
steps:
2323
- name: Checkout the source code
@@ -63,7 +63,7 @@ jobs:
6363
runs-on: ubuntu-latest
6464
strategy:
6565
matrix:
66-
rust_versions: ["stable", "1.69"]
66+
rust_versions: ["stable", "1.75"]
6767
steps:
6868
- name: Checkout the source code
6969
uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [Unreleased]
4+
5+
### Changed
6+
7+
* MSRV to 1.75
8+
39
## [1.3.0]
410

511
### New

Cargo.toml

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
[package]
22
name = "log4rs"
33
version = "1.3.0"
4-
authors = ["Steven Fackler <sfackler@gmail.com>", "Evan Simmons <esims89@gmail.com>"]
4+
authors = [
5+
"Steven Fackler <sfackler@gmail.com>",
6+
"Evan Simmons <esims89@gmail.com>",
7+
]
58
description = "A highly configurable multi-output logging implementation for the `log` facade"
69
license = "MIT OR Apache-2.0"
710
repository = "https://github.com/estk/log4rs"
811
readme = "README.md"
912
keywords = ["log", "logger", "logging", "log4"]
1013
edition = "2018"
11-
rust-version = "1.69"
14+
rust-version = "1.75"
1215

1316
[features]
1417
default = ["all_components", "config_parsing", "yaml_format"]
1518

16-
config_parsing = ["humantime", "serde", "serde-value", "typemap-ors", "log/serde"]
19+
config_parsing = [
20+
"humantime",
21+
"serde",
22+
"serde-value",
23+
"typemap-ors",
24+
"log/serde",
25+
]
1726
yaml_format = ["serde_yaml"]
1827
json_format = ["serde_json"]
1928
toml_format = ["toml"]
@@ -26,7 +35,14 @@ delete_roller = []
2635
fixed_window_roller = []
2736
size_trigger = []
2837
time_trigger = ["rand"]
29-
json_encoder = ["serde", "serde_json", "chrono", "log-mdc", "log/serde", "thread-id"]
38+
json_encoder = [
39+
"serde",
40+
"serde_json",
41+
"chrono",
42+
"log-mdc",
43+
"log/serde",
44+
"thread-id",
45+
]
3046
pattern_encoder = ["chrono", "log-mdc", "thread-id"]
3147
ansi_writer = []
3248
console_writer = ["ansi_writer", "libc", "winapi"]
@@ -45,7 +61,7 @@ all_components = [
4561
"time_trigger",
4662
"json_encoder",
4763
"pattern_encoder",
48-
"threshold_filter"
64+
"threshold_filter",
4965
]
5066

5167
gzip = ["flate2"]
@@ -56,28 +72,37 @@ harness = false
5672

5773
[dependencies]
5874
arc-swap = "1.6"
59-
chrono = { version = "0.4", optional = true, features = ["clock"], default-features = false }
75+
chrono = { version = "0.4.23", optional = true, features = [
76+
"clock",
77+
], default-features = false }
6078
flate2 = { version = "1.0", optional = true }
6179
fnv = "1.0"
6280
humantime = { version = "2.1", optional = true }
6381
log = { version = "0.4.20", features = ["std"] }
6482
log-mdc = { version = "0.1", optional = true }
6583
serde = { version = "1.0", optional = true, features = ["derive"] }
6684
serde-value = { version = "0.7", optional = true }
67-
thread-id = { version = "4", optional = true }
85+
thread-id = { version = "5", optional = true }
6886
typemap-ors = { version = "1.0.0", optional = true }
6987
serde_json = { version = "1.0", optional = true }
7088
serde_yaml = { version = "0.9", optional = true }
7189
toml = { version = "0.8", optional = true }
7290
parking_lot = { version = "0.12.0", optional = true }
73-
rand = { version = "0.8", optional = true}
74-
thiserror = "1.0.15"
91+
rand = { version = "0.9", optional = true }
92+
thiserror = "2.0.12"
7593
anyhow = "1.0.28"
7694
derivative = "2.2"
7795
once_cell = "1.17.1"
96+
mock_instant = "0.5"
7897

7998
[target.'cfg(windows)'.dependencies]
80-
winapi = { version = "0.3", optional = true, features = ["handleapi", "minwindef", "processenv", "winbase", "wincon"] }
99+
winapi = { version = "0.3", optional = true, features = [
100+
"handleapi",
101+
"minwindef",
102+
"processenv",
103+
"winbase",
104+
"wincon",
105+
] }
81106

82107
[target.'cfg(not(windows))'.dependencies]
83108
libc = { version = "0.2", optional = true }
@@ -87,15 +112,18 @@ lazy_static = "1.4"
87112
streaming-stats = "0.2.3"
88113
humantime = "2.1"
89114
tempfile = "3.8"
90-
mock_instant = "0.3"
91115

92116
[[example]]
93117
name = "json_logger"
94118
required-features = ["json_encoder", "console_appender"]
95119

96120
[[example]]
97121
name = "log_to_file"
98-
required-features = ["console_appender", "file_appender", "rolling_file_appender"]
122+
required-features = [
123+
"console_appender",
124+
"file_appender",
125+
"rolling_file_appender",
126+
]
99127

100128
[[example]]
101129
name = "compile_time_config"
@@ -108,3 +136,6 @@ required-features = ["file_appender", "rolling_file_appender", "size_trigger"]
108136
[[example]]
109137
name = "multi_logger_config"
110138
required-features = ["yaml_format", "config_parsing"]
139+
140+
[lints.rust]
141+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mock_time)'] }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![crates.io](https://img.shields.io/crates/v/log4rs.svg)](https://crates.io/crates/log4rs)
55
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)
66
![CI](https://github.com/estk/log4rs/workflows/CI/badge.svg)
7-
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.69+-green.svg)](https://github.com/estk/log4rs#rust-version-requirements)
7+
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.75+-green.svg)](https://github.com/estk/log4rs#rust-version-requirements)
88

99
log4rs is a highly configurable logging framework modeled after Java's Logback
1010
and log4j libraries.
@@ -71,7 +71,7 @@ fn main() {
7171

7272
## Rust Version Requirements
7373

74-
1.69
74+
1.75
7575

7676
## Building for Dev
7777

src/append/rolling_file/policy/compound/trigger/time.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
//!
33
//! Requires the `time_trigger` feature.
44
5-
#[cfg(test)]
6-
use chrono::NaiveDateTime;
75
use chrono::{DateTime, Datelike, Duration, Local, TimeZone, Timelike};
8-
#[cfg(test)]
9-
use mock_instant::{SystemTime, UNIX_EPOCH};
6+
107
use rand::Rng;
118
#[cfg(feature = "config_parsing")]
129
use serde::de;
@@ -176,22 +173,24 @@ impl TimeTrigger {
176173
/// Returns a new trigger which rolls the log once it has passed the
177174
/// specified time.
178175
pub fn new(config: TimeTriggerConfig) -> TimeTrigger {
179-
#[cfg(test)]
176+
#[cfg(mock_time)]
180177
let current = {
178+
use chrono::Local;
179+
use mock_instant::{SystemTime, UNIX_EPOCH};
180+
181181
let now: std::time::Duration = SystemTime::now()
182182
.duration_since(UNIX_EPOCH)
183183
.expect("system time before Unix epoch");
184-
NaiveDateTime::from_timestamp_opt(now.as_secs() as i64, now.subsec_nanos())
185-
.unwrap()
186-
.and_local_timezone(Local)
184+
DateTime::from_timestamp(now.as_secs() as i64, now.subsec_nanos())
187185
.unwrap()
186+
.with_timezone(&Local)
188187
};
189188

190-
#[cfg(not(test))]
189+
#[cfg(not(mock_time))]
191190
let current = Local::now();
192191
let next_time = TimeTrigger::get_next_time(current, config.interval, config.modulate);
193192
let next_roll_time = if config.max_random_delay > 0 {
194-
let random_delay = rand::thread_rng().gen_range(0..config.max_random_delay);
193+
let random_delay = rand::rng().random_range(0..config.max_random_delay);
195194
next_time + Duration::seconds(random_delay as i64)
196195
} else {
197196
next_time
@@ -278,7 +277,7 @@ impl TimeTrigger {
278277

279278
impl Trigger for TimeTrigger {
280279
fn trigger(&self, _file: &LogFile) -> anyhow::Result<bool> {
281-
#[cfg(test)]
280+
#[cfg(mock_time)]
282281
let current = {
283282
let now = SystemTime::now()
284283
.duration_since(UNIX_EPOCH)
@@ -289,7 +288,7 @@ impl Trigger for TimeTrigger {
289288
.unwrap()
290289
};
291290

292-
#[cfg(not(test))]
291+
#[cfg(not(mock_time))]
293292
let current: DateTime<Local> = Local::now();
294293
let mut next_roll_time = self.next_roll_time.write().unwrap();
295294
let is_trigger = current >= *next_roll_time;

src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
//! For more examples see the [examples](https://github.com/estk/log4rs/tree/main/examples).
177177
//!
178178
179-
#![allow(where_clauses_object_safety, clippy::manual_non_exhaustive)]
179+
#![allow(clippy::manual_non_exhaustive)]
180180
#![warn(missing_docs)]
181181

182182
use std::{
@@ -463,10 +463,6 @@ impl Handle {
463463
}
464464
}
465465

466-
trait ErrorInternals {
467-
fn new(message: String) -> Self;
468-
}
469-
470466
#[cfg(test)]
471467
mod test {
472468
use log::{Level, LevelFilter, Log};

0 commit comments

Comments
 (0)