8000 removed outdated dependency `derivative` by xNxExOx · Pull Request #351 · estk/log4rs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

removed outdated dependency derivative #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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,10 +2,10 @@
//!
//! Requires the `file_appender` feature.

use derivative::Derivative;
use log::Record;
use parking_lot::Mutex;
use std::{
fmt::{Debug, Formatter},
fs::{self, File, OpenOptions},
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,10 +16,10 @@
//!
//! Requires the `rolling_file_appender` feature.

use derivative::Derivative;
use log::Record;
use parking_lot::Mutex;
use std::{
fmt::{Debug, Formatter},
fs::{self, File, OpenOptions},
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 @@ -92,7 +92,6 @@
use std::{collections::HashMap, fmt, marker::PhantomData, sync::Arc, time::Duration};

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 @@ -438,17 +437,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
18 changes: 13 additions & 5 deletions src/encode/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@
//! [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,
fmt::{Debug, Formatter},
io, process, thread,
};

use crate::encode::{
self,
Expand Down Expand Up @@ -671,14 +674,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