diff --git a/.gitignore b/.gitignore index 30094a80..ccddebfe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ Cargo.lock .idea/ *.iml .vscode/ +info.log log/ diff --git a/Cargo.toml b/Cargo.toml index 18b1a81d..a7e47f63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,3 +96,7 @@ required-features = ["console_appender", "file_appender", "rolling_file_appender [[example]] name = "compile_time_config" required-features = ["yaml_format", "config_parsing"] + +[[example]] +name = "multi_logger_config" +required-features = ["yaml_format", "config_parsing"] diff --git a/test/log.yml b/examples/multi_logger.yml similarity index 89% rename from test/log.yml rename to examples/multi_logger.yml index f51edcc1..3b989433 100644 --- a/test/log.yml +++ b/examples/multi_logger.yml @@ -10,17 +10,16 @@ appenders: level: error file: kind: file - path: error.log + path: info.log encoder: pattern: "{d} [{t}] {l} {M}:{m}{n}" root: - level: warn appenders: - console loggers: - test::a: + multi_logger_config::a: level: info appenders: - file diff --git a/examples/multi_logger_config.rs b/examples/multi_logger_config.rs new file mode 100644 index 00000000..70864e96 --- /dev/null +++ b/examples/multi_logger_config.rs @@ -0,0 +1,23 @@ +use std::{default::Default, thread, time::Duration}; + +use log::{error, warn}; +use log4rs; + +fn main() { + log4rs::init_file("examples/multi_logger.yml", Default::default()).unwrap(); + + loop { + thread::sleep(Duration::from_secs(1)); + warn!("main"); + error!("error main"); + a::foo(); + } +} + +mod a { + use log::info; + + pub fn foo() { + info!("module a"); + } +} diff --git a/src/config/raw.rs b/src/config/raw.rs index da17ad92..cd1d951f 100644 --- a/src/config/raw.rs +++ b/src/config/raw.rs @@ -84,8 +84,7 @@ //! //! # The additivity of the logger. If true, appenders attached to the logger's //! # parent will also be attached to this logger. -//! # -//! Default: true +//! # Default: true //! additive: false //! ``` #![allow(deprecated)] diff --git a/test/Cargo.toml b/test/Cargo.toml deleted file mode 100644 index 2e1b696c..00000000 --- a/test/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "test" -version = "0.0.1" -authors = ["Steven Fackler "] - -[dependencies] -log = "0.4.0" -log4rs = { path = ".." } diff --git a/test/src/main.rs b/test/src/main.rs deleted file mode 100644 index bc25c19a..00000000 --- a/test/src/main.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::default::Default; -use std::thread; -use std::time::Duration; - -use log::{error, info, warn}; -use log4rs; - -fn main() { - log4rs::init_file("log.yml", Default::default()).unwrap(); - - loop { - thread::sleep(Duration::from_secs(1)); - warn!("main"); - error!("error main"); - a::foo(); - } -} - -mod a { - pub fn foo() { - info!("a"); - } -}