Skip to content

Commit

Permalink
removed outdated dependency derivative
Browse files Browse the repository at this point in the history
  • Loading branch information
xNxExOx committed Feb 22, 2024
1 parent c981ca4 commit 8cc6a9f
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## next

### Fixed

* removed outdated dependency `derivative`

## [1.3.0]

### New
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ parking_lot = { version = "0.12.0", optional = true }
rand = { version = "0.8", optional = true}
thiserror = "1.0.15"
anyhow = "1.0.28"
derivative = "2.2"
once_cell = "1.17.1"

[target.'cfg(windows)'.dependencies]
Expand Down
15 changes: 11 additions & 4 deletions src/append/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//!
//! Requires the `console_appender` feature.
use derivative::Derivative;
use log::Record;
use std::{
fmt,
Expand Down Expand Up @@ -51,6 +50,16 @@ enum Writer {
Raw(StdWriter),
}

impl fmt::Debug for Writer {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let str = match self {
Writer::Tty(_) => "TTY",
Writer::Raw(_) => "Raw",
};
f.write_str(str)
}
}

impl Writer {
fn lock(&self) -> WriterLock {
match *self {
Expand Down Expand Up @@ -117,10 +126,8 @@ impl<'a> encode::Write for WriterLock<'a> {
///
/// It supports output styling if standard out is a console buffer on Windows
/// or is a TTY on Unix.
#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Debug)]
pub struct ConsoleAppender {
#[derivative(Debug = "ignore")]
writer: Writer,
encoder: Box<dyn Encode>,
do_write: bool,
Expand Down
15 changes: 11 additions & 4 deletions src/append/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
//!
//! Requires the `file_appender` feature.
use derivative::Derivative;
use log::Record;
use parking_lot::Mutex;
use std::{
fs::{self, File, OpenOptions},
fmt::{Debug, Formatter},
io::{self, BufWriter, Write},
path::{Path, PathBuf},
};
Expand All @@ -32,15 +32,22 @@ pub struct FileAppenderConfig {
}

/// An appender which logs to a file.
#[derive(Derivative)]
#[derivative(Debug)]
pub struct FileAppender {
path: PathBuf,
#[derivative(Debug = "ignore")]
file: Mutex<SimpleWriter<BufWriter<File>>>,
encoder: Box<dyn Encode>,
}

impl Debug for FileAppender {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct(stringify!(FileAppender))
.field("path", &self.path)
// ignore file
.field("encoder", &self.encoder)
.finish()
}
}

impl Append for FileAppender {
fn append(&self, record: &Record) -> anyhow::Result<()> {
let mut file = self.file.lock();
Expand Down
17 changes: 13 additions & 4 deletions src/append/rolling_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
//!
//! Requires the `rolling_file_appender` feature.
use derivative::Derivative;
use log::Record;
use parking_lot::Mutex;
use std::{
fs::{self, File, OpenOptions},
fmt::{Debug, Formatter},
io::{self, BufWriter, Write},
path::{Path, PathBuf},
};
Expand Down Expand Up @@ -151,17 +151,26 @@ impl<'a> LogFile<'a> {
}

/// An appender which archives log files in a configurable strategy.
#[derive(Derivative)]
#[derivative(Debug)]
pub struct RollingFileAppender {
#[derivative(Debug = "ignore")]
writer: Mutex<Option<LogWriter>>,
path: PathBuf,
append: bool,
encoder: Box<dyn Encode>,
policy: Box<dyn policy::Policy>,
}

impl Debug for RollingFileAppender {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct(stringify!(RollingFileAppender))
// ignore writer
.field("path", &self.path)
.field("append", &self.append)
.field("encoder", &self.encoder)
.field("policy", &self.policy)
.finish()
}
}

impl Append for RollingFileAppender {
fn append(&self, record: &Record) -> anyhow::Result<()> {
// TODO(eas): Perhaps this is better as a concurrent queue?
Expand Down
14 changes: 10 additions & 4 deletions src/config/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ use std::{
};

use anyhow::anyhow;
use derivative::Derivative;
use log::LevelFilter;
use serde::de::{self, Deserialize as SerdeDeserialize, DeserializeOwned};
use serde_value::Value;
Expand Down Expand Up @@ -432,17 +431,24 @@ where
Option::<S>::deserialize(d).map(|r| r.map(|s| s.0))
}

#[derive(Clone, Debug, Derivative, serde::Deserialize)]
#[derivative(Default)]
#[derive(Clone, Debug, serde::Deserialize)]
#[serde(deny_unknown_fields)]
struct Root {
#[serde(default = "root_level_default")]
#[derivative(Default(value = "root_level_default()"))]
level: LevelFilter,
#[serde(default)]
appenders: Vec<String>,
}

impl Default for Root {
fn default() -> Self {
Self{
level: root_level_default(),
appenders: vec![],
}
}
}

fn root_level_default() -> LevelFilter {
LevelFilter::Debug
}
Expand Down
14 changes: 10 additions & 4 deletions src/encode/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Encoders
use derivative::Derivative;
use log::Record;
use std::{fmt, io};

Expand Down Expand Up @@ -94,8 +93,6 @@ pub enum Color {
///
/// Any fields set to `None` will be set to their default format, as defined
/// by the `Write`r.
#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Clone, Eq, PartialEq, Hash, Default)]
pub struct Style {
/// The text (or foreground) color.
Expand All @@ -104,9 +101,18 @@ pub struct Style {
pub background: Option<Color>,
/// True if the text should have increased intensity.
pub intense: Option<bool>,
#[derivative(Debug = "ignore")]
_p: (),
}
impl fmt::Debug for Style {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct(stringify!(Style))
.field("text", &self.text)
.field("background", &self.background)
.field("intense", &self.intense)
// ignore _p
.finish()
}
}

impl Style {
/// Returns a `Style` with all fields set to their defaults.
Expand Down
14 changes: 9 additions & 5 deletions src/encode/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@
//! [MDC]: https://crates.io/crates/log-mdc
use chrono::{Local, Utc};
use derivative::Derivative;
use log::{Level, Record};
use std::{default::Default, io, process, thread};
use std::{default::Default, io, process, thread, fmt::{Debug, Formatter}};

use crate::encode::{
self,
Expand Down Expand Up @@ -671,14 +670,19 @@ impl FormattedChunk {
}

/// An `Encode`r configured via a format string.
#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Clone, Eq, PartialEq, Hash)]
pub struct PatternEncoder {
#[derivative(Debug = "ignore")]
chunks: Vec<Chunk>,
pattern: String,
}
impl Debug for PatternEncoder {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct(stringify!(PatternEncoder))
// ignore chunks
.field("pattern", &self.pattern)
.finish()
}
}

/// Returns a `PatternEncoder` using the default pattern of `{d} {l} {t} - {m}{n}`.
impl Default for PatternEncoder {
Expand Down

0 comments on commit 8cc6a9f

Please sign in to comment.