Skip to content

Commit 7d98197

Browse files
committed
Merge branch 'main' into estk/remove_derive_more
2 parents 47a25f6 + 2e6dee8 commit 7d98197

File tree

29 files changed

+102
-100
lines changed

29 files changed

+102
-100
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
1010
repository = "https://github.com/estk/log4rs"
1111
readme = "README.md"
1212
keywords = ["log", "logger", "logging", "log4"]
13-
edition = "2018"
13+
edition = "2021"
1414
rust-version = "1.82"
1515

1616
[features]
@@ -112,7 +112,7 @@ libc = { version = "0.2", optional = true }
112112
[target.'cfg(not(target_family = "wasm"))'.dependencies]
113113
thread-id = { version = "5", optional = true }
114114

115-
[target.'cfg(all(target_family = "wasm", feature="time_trigger"))'.dependencies]
115+
[target.'cfg(all(target_family = "wasm"))'.dependencies]
116116
getrandom = { version = "0.3.3", features = ["wasm_js"], optional = true }
117117

118118

benches/rotation.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ fn mk_config(file_size: u64, file_count: u32) -> log4rs::config::Config {
100100
.unwrap()
101101
}
102102

103+
#[allow(dead_code)]
103104
#[derive(Debug)]
104105
struct Stats {
105106
min: Duration,
@@ -140,8 +141,8 @@ impl Stats {
140141
let mut anomalies = vec![];
141142
let thresh = self.mean_nanos + ((self.stddev_nanos * 50.0).round() as u128);
142143
for dur in measurements {
143-
if dur.as_nanos() as u128 > thresh {
144-
anomalies.push(dur.clone());
144+
if dur.as_nanos() > thresh {
145+
anomalies.push(*dur);
145146
}
146147
}
147148
anomalies

examples/compile_time_config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use log::{error, info, trace};
2-
use log4rs;
3-
use serde_yaml;
42

53
fn main() {
64
let config_str = include_str!("sample_config.yml");

examples/custom.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl MyFilter {
3636
}
3737

3838
impl Filter for MyFilter {
39-
fn filter(&self, record: &log::Record) -> Response {
39+
fn filter(&self, record: &log::Record<'_>) -> Response {
4040
// Exclude all log messages at the info level
4141
if record.level() == self.level {
4242
return Response::Reject;
@@ -63,7 +63,7 @@ impl Encode for MyEncoder {
6363
fn encode(
6464
&self,
6565
w: &mut dyn log4rs::encode::Write,
66-
record: &log::Record,
66+
record: &log::Record<'_>,
6767
) -> anyhow::Result<()> {
6868
// Write the prefix followed by the log message
6969
writeln!(
@@ -105,7 +105,7 @@ impl MyAppender {
105105
}
106106

107107
impl Append for MyAppender {
108-
fn append(&self, record: &log::Record) -> anyhow::Result<()> {
108+
fn append(&self, record: &log::Record<'_>) -> anyhow::Result<()> {
109109
match record.level() {
110110
log::Level::Trace | log::Level::Debug => {
111111
let mut writer = self.console_writer.lock();

examples/custom_config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl MyFilter {
3131
}
3232

3333
impl Filter for MyFilter {
34-
fn filter(&self, record: &log::Record) -> Response {
34+
fn filter(&self, record: &log::Record<'_>) -> Response {
3535
// Exclude all log messages at the info level
3636
if record.level() == self.level {
3737
return Response::Reject;
@@ -58,7 +58,7 @@ impl Encode for MyEncoder {
5858
fn encode(
5959
&self,
6060
w: &mut dyn log4rs::encode::Write,
61-
record: &log::Record,
61+
record: &log::Record<'_>,
6262
) -> anyhow::Result<()> {
6363
// Write the prefix followed by the log message
6464
writeln!(
@@ -100,7 +100,7 @@ impl MyAppender {
100100
}
101101

102102
impl Append for MyAppender {
103-
fn append(&self, record: &log::Record) -> anyhow::Result<()> {
103+
fn append(&self, record: &log::Record<'_>) -> anyhow::Result<()> {
104104
match record.level() {
105105
log::Level::Trace | log::Level::Debug => {
106106
let mut writer = self.console_writer.lock();

examples/multi_logger_config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{default::Default, thread, time::Duration};
22

33
use log::{error, warn};
4-
use log4rs;
54

65
fn main() {
76
log4rs::init_file("examples/multi_logger.yml", Default::default()).unwrap();

src/append/console.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'a> io::Write for WriterLock<'a> {
9696
}
9797
}
9898

99-
fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> {
99+
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
100100
match *self {
101101
WriterLock::Tty(ref mut w) => w.write_fmt(fmt),
102102
WriterLock::Raw(ref mut w) => w.write_fmt(fmt),
@@ -126,7 +126,7 @@ pub struct ConsoleAppender {
126126
}
127127

128128
impl Append for ConsoleAppender {
129-
fn append(&self, record: &Record) -> anyhow::Result<()> {
129+
fn append(&self, record: &Record<'_>) -> anyhow::Result<()> {
130130
if self.do_write {
131131
let mut writer = self.writer.lock();
132132
self.encoder.encode(&mut writer, record)?;

src/append/file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct FileAppender {
4949
}
5050

5151
impl Append for FileAppender {
52-
fn append(&self, record: &Record) -> anyhow::Result<()> {
52+
fn append(&self, record: &Record<'_>) -> anyhow::Result<()> {
5353
let mut file = self.file.lock();
5454
self.encoder.encode(&mut *file, record)?;
5555
file.flush()?;
@@ -327,7 +327,7 @@ mod test {
327327
.unwrap();
328328

329329
// Only MAX_REPLACEMENTS should be replaced, the rest should remain as $TIME{...}
330-
let mut expected_path = format!("foo/bar/logs/log");
330+
let mut expected_path = "foo/bar/logs/log".to_string();
331331
for i in 0..10 {
332332
if i < MAX_REPLACEMENTS {
333333
expected_path.push_str(&format!("-{}", current_time));

src/append/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mod env_util {
4545
where
4646
Str: Into<Cow<'str, str>>,
4747
{
48-
let mut outpath: Cow<str> = path.into();
48+
let mut outpath: Cow<'_, str> = path.into();
4949
let path = outpath.clone();
5050
for (match_start, _) in path.match_indices(ENV_PREFIX) {
5151
let env_name_start = match_start + ENV_PREFIX_LEN;
@@ -89,7 +89,7 @@ mod env_util {
8989
/// to a file or the console.
9090
pub trait Append: fmt::Debug + Send + Sync + 'static {
9191
/// Processes the provided `Record`.
92-
fn append(&self, record: &Record) -> anyhow::Result<()>;
92+
fn append(&self, record: &Record<'_>) -> anyhow::Result<()>;
9393

9494
/// Flushes all in-flight records.
9595
fn flush(&self);
@@ -103,7 +103,7 @@ impl Deserializable for dyn Append {
103103
}
104104

105105
impl<T: Log + fmt::Debug + 'static> Append for T {
106-
fn append(&self, record: &Record) -> anyhow::Result<()> {
106+
fn append(&self, record: &Record<'_>) -> anyhow::Result<()> {
107107
self.log(record);
108108
Ok(())
109109
}
@@ -159,7 +159,7 @@ mod test {
159159
#[test]
160160
#[cfg(any(feature = "file_appender", feature = "rolling_file_appender"))]
161161
fn expand_env_vars_tests() {
162-
set_var("HELLO_WORLD", "GOOD BYE");
162+
unsafe { set_var("HELLO_WORLD", "GOOD BYE") };
163163
#[cfg(not(target_os = "windows"))]
164164
let test_cases = vec![
165165
("$ENV{HOME}", var("HOME").unwrap()),

src/append/rolling_file/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub struct RollingFileAppender {
161161
}
162162

163163
impl Append for RollingFileAppender {
164-
fn append(&self, record: &Record) -> anyhow::Result<()> {
164+
fn append(&self, record: &Record<'_>) -> anyhow::Result<()> {
165165
// TODO(eas): Perhaps this is better as a concurrent queue?
166166
let mut writer = self.writer.lock();
167167

@@ -420,7 +420,7 @@ appenders:
420420
struct NopPolicy;
421421

422422
impl Policy for NopPolicy {
423-
fn process(&self, _: &mut LogFile) -> anyhow::Result<()> {
423+
fn process(&self, _: &mut LogFile<'_>) -> anyhow::Result<()> {
424424
Ok(())
425425
}
426426
fn is_pre_process(&self) -> bool {

0 commit comments

Comments
 (0)