Skip to content
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

Update to edition 2018, deps and docs #108

Merged
merged 7 commits into from
Dec 17, 2019
Merged
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## [Unreleased]

### New

* More badges in the readme.

### Changed

* Use rust 2018 edition.
* Update `arcswap`, `serde-value` and `serde-xml-rs`.

### Fixed

* Deprecate len method on rolling_file.

## [0.9.0]

### New
Expand Down
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "MIT/Apache-2.0"
repository = "https://github.com/estk/log4rs"
readme = "README.md"
keywords = ["logger", "log", "logging"]
edition = '2018'

[features]
default = ["all_components", "gzip", "file", "yaml_format"]
Expand Down Expand Up @@ -48,7 +49,7 @@ gzip = ["flate2"]

[dependencies]
antidote = { version = "1.0", optional = true }
arc-swap = "0.3"
arc-swap = "0.4"
chrono = { version = "0.4", optional = true }
flate2 = { version = "1.0", optional = true }
fnv = "1.0"
Expand All @@ -57,13 +58,13 @@ log = { version = "0.4.0", features = ["std"] }
log-mdc = { version = "0.1", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde-value = { version = "0.5", optional = true }
serde-value = { version = "0.6", optional = true }
thread-id = { version = "3.3", optional = true }
typemap = { version = "0.3", optional = true }
serde_json = { version = "1.0", optional = true }
serde_yaml = { version = "0.8.4", optional = true }
toml = { version = "0.5", optional = true }
serde-xml-rs = { version = "0.2", optional = true }
serde-xml-rs = { version = "0.3", optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", optional = true, features = ["handleapi", "minwindef", "processenv", "winbase", "wincon"] }
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# log4rs

[![CircleCI](https://circleci.com/gh/estk/log4rs.svg?style=shield)](https://circleci.com/gh/estk/log4rs)
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)
[![crates.io](https://img.shields.io/crates/v/log4rs.svg)](https://crates.io/crates/log4rs)
[![downloads](https://img.shields.io/crates/d/shuteye.svg)](https://crates.io/crates/log4rs)
[![API](https://docs.rs/log4rs/badge.svg)](https://docs.rs/log4rs)

log4rs is a highly configurable logging framework modeled after Java's Logback
and log4j libraries.
Expand Down
16 changes: 8 additions & 8 deletions src/append/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ use std::error::Error;
use std::fmt;
use std::io::{self, Write};

use append::Append;
use encode::pattern::PatternEncoder;
use encode::writer::console::{ConsoleWriter, ConsoleWriterLock};
use encode::writer::simple::SimpleWriter;
use crate::append::Append;
use crate::encode::pattern::PatternEncoder;
use crate::encode::writer::console::{ConsoleWriter, ConsoleWriterLock};
use crate::encode::writer::simple::SimpleWriter;
#[cfg(feature = "file")]
use encode::EncoderConfig;
use encode::{self, Encode, Style};
use crate::encode::EncoderConfig;
use crate::encode::{self, Encode, Style};
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use priv_io::{StdWriter, StdWriterLock};
use crate::file::{Deserialize, Deserializers};
use crate::priv_io::{StdWriter, StdWriterLock};

/// The console appender's configuration.
#[cfg(feature = "file")]
Expand Down
12 changes: 6 additions & 6 deletions src/append/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ use std::fs::{self, File, OpenOptions};
use std::io::{self, BufWriter, Write};
use std::path::{Path, PathBuf};

use append::Append;
use encode::pattern::PatternEncoder;
use encode::writer::simple::SimpleWriter;
use encode::Encode;
use crate::append::Append;
use crate::encode::pattern::PatternEncoder;
use crate::encode::writer::simple::SimpleWriter;
use crate::encode::Encode;
#[cfg(feature = "file")]
use encode::EncoderConfig;
use crate::encode::EncoderConfig;
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

/// The file appender's configuration.
#[cfg(feature = "file")]
Expand Down
4 changes: 2 additions & 2 deletions src/append/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::error::Error;
use std::fmt;

#[cfg(feature = "file")]
use file::Deserializable;
use crate::file::Deserializable;
#[cfg(feature = "file")]
use filter::FilterConfig;
use crate::filter::FilterConfig;

#[cfg(feature = "console_appender")]
pub mod console;
Expand Down
25 changes: 18 additions & 7 deletions src/append/rolling_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ use std::fs::{self, File, OpenOptions};
use std::io::{self, BufWriter, Write};
use std::path::{Path, PathBuf};

use append::Append;
use encode::pattern::PatternEncoder;
use crate::append::Append;
use crate::encode::pattern::PatternEncoder;
#[cfg(feature = "file")]
use encode::EncoderConfig;
use encode::{self, Encode};
use crate::encode::EncoderConfig;
use crate::encode::{self, Encode};
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

pub mod policy;

Expand Down Expand Up @@ -116,10 +116,21 @@ impl<'a> LogFile<'a> {
/// and adding the number of bytes written. It may be inaccurate if any
/// writes have failed or if another process has modified the file
/// concurrently.
#[deprecated(since = "0.9.1", note = "Please use the len_estimate function instead")]
pub fn len(&self) -> u64 {
self.len
}

/// Returns an estimate of the log file's current size.
///
/// This is calculated by taking the size of the log file when it is opened
/// and adding the number of bytes written. It may be inaccurate if any
/// writes have failed or if another process has modified the file
/// concurrently.
pub fn len_estimate(&self) -> u64 {
estk marked this conversation as resolved.
Show resolved Hide resolved
self.len
}

/// Triggers the log file to roll over.
///
/// A policy must call this method when it wishes to roll the log. The
Expand Down Expand Up @@ -332,12 +343,12 @@ mod test {
use tempdir::TempDir;

use super::*;
use append::rolling_file::policy::Policy;
use crate::append::rolling_file::policy::Policy;

#[test]
#[cfg(feature = "yaml_format")]
fn deserialize() {
use file::{Deserializers, RawConfig};
use crate::file::{Deserializers, RawConfig};

let dir = TempDir::new("deserialize").unwrap();

Expand Down
8 changes: 4 additions & 4 deletions src/append/rolling_file/policy/compound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use serde_value::Value;
use std::collections::BTreeMap;
use std::error::Error;

use append::rolling_file::policy::compound::roll::Roll;
use append::rolling_file::policy::Policy;
use append::rolling_file::LogFile;
use crate::append::rolling_file::policy::compound::roll::Roll;
use crate::append::rolling_file::policy::Policy;
use crate::append::rolling_file::LogFile;
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

pub mod roll;
pub mod trigger;
Expand Down
4 changes: 2 additions & 2 deletions src/append/rolling_file/policy/compound/roll/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::error::Error;
use std::fs;
use std::path::Path;

use append::rolling_file::policy::compound::roll::Roll;
use crate::append::rolling_file::policy::compound::roll::Roll;
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

/// Configuration for the delete roller.
#[cfg(feature = "file")]
Expand Down
6 changes: 3 additions & 3 deletions src/append/rolling_file/policy/compound/roll/fixed_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::fs;
use std::io;
use std::path::Path;

use append::rolling_file::policy::compound::roll::Roll;
use crate::append::rolling_file::policy::compound::roll::Roll;
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

/// Configuration for the fixed window roller.
#[cfg(feature = "file")]
Expand Down Expand Up @@ -243,7 +243,7 @@ mod test {
use tempdir::TempDir;

use super::*;
use append::rolling_file::policy::compound::roll::Roll;
use crate::append::rolling_file::policy::compound::roll::Roll;

#[test]
fn rotation() {
Expand Down
2 changes: 1 addition & 1 deletion src/append/rolling_file/policy/compound/roll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt;
use std::path::Path;

#[cfg(feature = "file")]
use file::Deserializable;
use crate::file::Deserializable;

#[cfg(feature = "delete_roller")]
pub mod delete;
Expand Down
4 changes: 2 additions & 2 deletions src/append/rolling_file/policy/compound/trigger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use std::error::Error;
use std::fmt;

use append::rolling_file::LogFile;
use crate::append::rolling_file::LogFile;
#[cfg(feature = "file")]
use file::Deserializable;
use crate::file::Deserializable;

#[cfg(feature = "size_trigger")]
pub mod size;
Expand Down
8 changes: 4 additions & 4 deletions src/append/rolling_file/policy/compound/trigger/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::error::Error;
#[cfg(feature = "file")]
use std::fmt;

use append::rolling_file::policy::compound::trigger::Trigger;
use append::rolling_file::LogFile;
use crate::append::rolling_file::policy::compound::trigger::Trigger;
use crate::append::rolling_file::LogFile;
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

/// Configuration for the size trigger.
#[cfg(feature = "file")]
Expand Down Expand Up @@ -116,7 +116,7 @@ impl SizeTrigger {

impl Trigger for SizeTrigger {
fn trigger(&self, file: &LogFile) -> Result<bool, Box<dyn Error + Sync + Send>> {
Ok(file.len() > self.limit)
Ok(file.len_estimate() > self.limit)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/append/rolling_file/policy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use std::error::Error;
use std::fmt;

use append::rolling_file::LogFile;
use crate::append::rolling_file::LogFile;
#[cfg(feature = "file")]
use file::Deserializable;
use crate::file::Deserializable;

#[cfg(feature = "compound_policy")]
pub mod compound;
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::error;
use std::fmt;
use std::iter::IntoIterator;

use append::Append;
use filter::Filter;
use {ConfigPrivateExt, PrivateConfigAppenderExt};
use crate::append::Append;
use crate::filter::Filter;
use crate::{ConfigPrivateExt, PrivateConfigAppenderExt};

/// Configuration for the root logger.
#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/encode/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ use std::option;
use std::thread;
use thread_id;

use encode::{Encode, Write, NEWLINE};
use crate::encode::{Encode, Write, NEWLINE};
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

/// The JSON encoder's configuration
#[cfg(feature = "file")]
Expand Down Expand Up @@ -178,7 +178,7 @@ mod test {
use log_mdc;

use super::*;
use encode::writer::simple::SimpleWriter;
use crate::encode::writer::simple::SimpleWriter;

#[test]
fn default() {
Expand Down
2 changes: 1 addition & 1 deletion src/encode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::fmt;
use std::io;

#[cfg(feature = "file")]
use file::Deserializable;
use crate::file::Deserializable;

#[cfg(feature = "json_encoder")]
pub mod json;
Expand Down
12 changes: 6 additions & 6 deletions src/encode/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ use std::process;
use std::thread;
use thread_id;

use encode::pattern::parser::{Alignment, Parameters, Parser, Piece};
use encode::{self, Color, Encode, Style, NEWLINE};
use crate::encode::pattern::parser::{Alignment, Parameters, Parser, Piece};
use crate::encode::{self, Color, Encode, Style, NEWLINE};
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
use crate::file::{Deserialize, Deserializers};

mod parser;

Expand Down Expand Up @@ -692,9 +692,9 @@ mod tests {

use super::{Chunk, PatternEncoder};
#[cfg(feature = "simple_writer")]
use encode::writer::simple::SimpleWriter;
use crate::encode::writer::simple::SimpleWriter;
#[cfg(feature = "simple_writer")]
use encode::Encode;
use crate::encode::Encode;

fn error_free(encoder: &PatternEncoder) -> bool {
encoder.chunks.iter().all(|c| match *c {
Expand Down Expand Up @@ -766,7 +766,7 @@ mod tests {

#[test]
#[cfg(feature = "simple_writer")]
fn thread_id() {
fn thread_id_field() {
thread::spawn(|| {
let pw = PatternEncoder::new("{I}");
let mut buf = vec![];
Expand Down
6 changes: 3 additions & 3 deletions src/encode/writer/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Requires the `ansi_writer` feature.

use encode::{self, Color, Style};
use crate::encode::{self, Color, Style};
use std::fmt;
use std::io;

Expand Down Expand Up @@ -85,8 +85,8 @@ mod test {
use std::io::{self, Write};

use super::*;
use encode::Write as EncodeWrite;
use encode::{Color, Style};
use crate::encode::Write as EncodeWrite;
use crate::encode::{Color, Style};

#[test]
fn basic() {
Expand Down
Loading