Skip to content

Commit 2c258ab

Browse files
committed
Remove (and fix) some clippy allows
1 parent 2ba5383 commit 2c258ab

File tree

15 files changed

+64
-61
lines changed

15 files changed

+64
-61
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this
66
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [unpublished]
9+
10+
Remove the RwLock around the color palette.
11+
812
## [0.29.3] - 2024-10-12
913

1014
Removed dependency to `glob` by implementing the necessary file searches explicitly,

examples/write_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(dead_code)]
21
use flexi_logger::writers::LogWriter;
32
use std::{
43
io::{Error, ErrorKind},
@@ -7,6 +6,7 @@ use std::{
76

87
fn main() {}
98

9+
#[allow(dead_code)]
1010
struct MyWriter<F> {
1111
file: Arc<Mutex<F>>,
1212
}

src/deferred_now.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ impl<'a> DeferredNow {
1919
Self(None)
2020
}
2121

22-
#[allow(dead_code)]
22+
#[cfg(test)]
2323
#[must_use]
24-
pub(crate) fn new_from_datetime(dt: DateTime<Local>) -> Self {
24+
fn new_from_datetime(dt: DateTime<Local>) -> Self {
2525
Self(Some(dt))
2626
}
2727

src/logger.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use crate::formats::AdaptiveFormat;
2+
#[cfg(feature = "colors")]
3+
use crate::set_palette;
24
use crate::{
35
filter::LogLineFilter,
46
flexi_logger::FlexiLogger,
@@ -672,7 +674,7 @@ impl Logger {
672674
/// Several variants of [`FlexiLoggerError`] can occur.
673675
pub fn build(mut self) -> Result<(Box<dyn log::Log>, LoggerHandle), FlexiLoggerError> {
674676
#[cfg(feature = "colors")]
675-
crate::formats::set_palette(self.o_palette.as_deref())?;
677+
set_palette(self.o_palette.as_deref())?;
676678

677679
if self.use_utc {
678680
self.flwb = self.flwb.use_utc();

src/logger_handle.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ impl LoggerHandle {
133133
}
134134

135135
/// Replaces the active `LogSpecification`.
136-
#[allow(clippy::missing_panics_doc)]
137136
pub fn set_new_spec(&self, new_spec: LogSpecification) {
138137
self.writers_handle
139138
.set_new_spec(new_spec)
@@ -151,7 +150,7 @@ impl LoggerHandle {
151150
Ok(())
152151
}
153152

154-
/// Replaces the active `LogSpecification` and pushes the previous one to a Stack.
153+
/// Replaces the active `LogSpecification` and pushes the previous one to a stack.
155154
#[allow(clippy::missing_panics_doc)]
156155
pub fn push_temp_spec(&mut self, new_spec: LogSpecification) {
157156
self.writers_handle

src/primary_writer/std_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl StdWriter {
9999
EffectiveWriteMode::BufferDontFlushWith(capacity) => {
100100
InnerStdWriter::Buffered(Mutex::new(BufWriter::with_capacity(capacity, stdstream)))
101101
}
102-
EffectiveWriteMode::BufferAndFlushWith(_, _) => {
102+
EffectiveWriteMode::BufferAndFlushWith(_) => {
103103
unreachable!("Sync InnerStdWriter with own flushing is not implemented")
104104
}
105105
#[cfg(feature = "async")]

src/threads.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ use {
2121
std::{sync::Mutex, thread::JoinHandle},
2222
};
2323

24-
// no clue why we get a warning if this allow is omitted; if we omit the use, we get an error
25-
#[allow(unused_imports)]
2624
#[cfg(feature = "async")]
25+
#[cfg(test)]
2726
use std::io::Write;
2827

2928
#[cfg(feature = "async")]

src/trc.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ impl LogSpecSubscriber for TraceLogSpecSubscriber {
138138
}
139139
}
140140

141-
#[allow(dead_code)] // not really appropriate, seems to be a bug in clippy
142141
/// Rereads the specfile if it was updated and forwards the update to `tracing`'s filter.
143-
pub struct SpecFileNotifier(Option<Debouncer<RecommendedWatcher>>);
142+
pub struct SpecFileNotifier {
143+
_watcher: Option<Debouncer<RecommendedWatcher>>,
144+
}
144145

145146
/// Set up tracing to write into the specified `FileLogWriter`,
146147
/// and to use the (optionally) specified specfile.
@@ -166,19 +167,21 @@ pub fn setup_tracing(
166167
.with_filter_reloading();
167168

168169
// Set up specfile watching
169-
let spec_file_notifier = SpecFileNotifier(match o_specfile {
170-
Some(specfile) => {
171-
let reload_handle = Box::new(subscriber_builder.reload_handle());
172-
subscribe_to_specfile(
173-
specfile,
174-
Box::new(move |logspec| {
175-
{ reload_handle.reload(LogSpecAsFilter(logspec)) }.unwrap(/* OK */);
176-
}),
177-
initial_logspec,
178-
)?
179-
}
180-
None => None,
181-
});
170+
let spec_file_notifier = SpecFileNotifier {
171+
_watcher: match o_specfile {
172+
Some(specfile) => {
173+
let reload_handle = Box::new(subscriber_builder.reload_handle());
174+
subscribe_to_specfile(
175+
specfile,
176+
Box::new(move |logspec| {
177+
{ reload_handle.reload(LogSpecAsFilter(logspec)) }.unwrap(/* OK */);
178+
}),
179+
initial_logspec,
180+
)?
181+
}
182+
None => None,
183+
},
184+
};
182185

183186
// Get ready to trace
184187
tracing::subscriber::set_global_default(subscriber_builder.finish())?;

src/write_mode.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,6 @@ pub enum WriteMode {
114114
flush_interval: Duration,
115115
},
116116
}
117-
118-
pub(crate) enum EffectiveWriteMode {
119-
Direct,
120-
#[allow(dead_code)] // introduced due to a bug in clippy, should be removed again
121-
BufferAndFlushWith(usize, Duration),
122-
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
123-
#[cfg(feature = "async")]
124-
AsyncWith {
125-
/// Capacity of the pool for the message buffers.
126-
pool_capa: usize,
127-
/// Capacity of an individual message buffer.
128-
message_capa: usize,
129-
/// The interval for flushing the output.
130-
///
131-
/// With `Duration::ZERO` flushing is suppressed.
132-
flush_interval: Duration,
133-
},
134-
BufferDontFlushWith(usize),
135-
}
136-
137117
impl WriteMode {
138118
pub(crate) fn inner(&self) -> EffectiveWriteMode {
139119
match *self {
@@ -144,12 +124,9 @@ impl WriteMode {
144124
Self::BufferDontFlushWith(duration) => {
145125
EffectiveWriteMode::BufferDontFlushWith(duration)
146126
}
147-
Self::BufferAndFlush => EffectiveWriteMode::BufferAndFlushWith(
148-
DEFAULT_BUFFER_CAPACITY,
149-
DEFAULT_FLUSH_INTERVAL,
150-
),
151-
Self::BufferAndFlushWith(bufsize, duration) => {
152-
EffectiveWriteMode::BufferAndFlushWith(bufsize, duration)
127+
Self::BufferAndFlush => EffectiveWriteMode::BufferAndFlushWith(DEFAULT_BUFFER_CAPACITY),
128+
Self::BufferAndFlushWith(bufsize, _duration) => {
129+
EffectiveWriteMode::BufferAndFlushWith(bufsize)
153130
}
154131
#[cfg(feature = "async")]
155132
Self::Async => EffectiveWriteMode::AsyncWith {
@@ -198,7 +175,7 @@ impl WriteMode {
198175
pub(crate) fn buffersize(&self) -> Option<usize> {
199176
match self.inner() {
200177
EffectiveWriteMode::Direct => None,
201-
EffectiveWriteMode::BufferAndFlushWith(bufsize, _)
178+
EffectiveWriteMode::BufferAndFlushWith(bufsize)
202179
| EffectiveWriteMode::BufferDontFlushWith(bufsize) => Some(bufsize),
203180
#[cfg(feature = "async")]
204181
EffectiveWriteMode::AsyncWith {
@@ -227,3 +204,21 @@ impl WriteMode {
227204
}
228205
}
229206
}
207+
208+
pub(crate) enum EffectiveWriteMode {
209+
Direct,
210+
BufferAndFlushWith(usize),
211+
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
212+
#[cfg(feature = "async")]
213+
AsyncWith {
214+
/// Capacity of the pool for the message buffers.
215+
pool_capa: usize,
216+
/// Capacity of an individual message buffer.
217+
message_capa: usize,
218+
/// The interval for flushing the output.
219+
///
220+
/// With `Duration::ZERO` flushing is suppressed.
221+
flush_interval: Duration,
222+
},
223+
BufferDontFlushWith(usize),
224+
}

src/writers/file_log_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl FileLogWriter {
3838
) -> FileLogWriter {
3939
let state_handle = match state.config().write_mode.inner() {
4040
EffectiveWriteMode::Direct
41-
| EffectiveWriteMode::BufferAndFlushWith(_, _)
41+
| EffectiveWriteMode::BufferAndFlushWith(_)
4242
| EffectiveWriteMode::BufferDontFlushWith(_) => {
4343
StateHandle::new_sync(state, format_function)
4444
}

0 commit comments

Comments
 (0)