1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/")] #![warn(missing_docs)] //! A logger that can write the log to standard error or to a fresh file in a configurable folder //! and allows custom logline formats. //! //! It had started as an extended copy of [env_logger](http://crates.io/crates/env_logger/). //! //! # Usage //! //! Add `flexi_logger` to the dependencies in your project's `Cargo.toml`. //! //! ```toml //! [dependencies] //! flexi_logger = "0.6" //! log = "*" //! ``` //! //! and this to your crate root: //! //! ```text //! extern crate flexi_logger; //! #[macro_use] //! extern crate log; //! ``` //! //! The latter is needed because flexi_logger plugs into the standard Rust logging facade given //! by the [log crate](https://crates.io/crates/log), //! and you use the ```log``` macros to write log lines from your code. //! //! Early in the start-up of your program, call something like //! //! ```text //! use flexi_logger::Logger; //! //! Logger::with_str("modx::mody = info") //! // ... your configuration options go here ... //! .start() //! .unwrap_or_else(|e| panic!("Logger initialization failed with {}", e)); //! ``` //! //! The configuration options allow e.g. to //! //! * decide whether you want to write your logs to stderr or to a file, //! * configure the filenames and the folder in which the log files are created, //! * specify the line format for the log lines //! //! See [Logger](struct.Logger.html) for a full description of all configuration options. //! extern crate chrono; extern crate glob; extern crate log; extern crate regex; macro_rules! print_err { ($($arg:tt)*) => ( { use std::io::prelude::*; if let Err(e) = write!(&mut ::std::io::stderr(), "{}\n", format_args!($($arg)*)) { panic!("Failed to write to stderr.\ \nOriginal error output: {}\ \nSecondary error writing to stderr: {}", format!($($arg)*), e); } } ) } mod deprecated; mod flexi_error; mod flexi_logger; mod flexi_writer; mod formats; mod logger; mod log_config; mod log_specification; pub use log::{LogLevel, LogLevelFilter, LogRecord}; #[allow(deprecated)] pub use deprecated::{init, LogOptions}; pub use formats::*; pub use log_specification::{LogSpecification, LogSpecBuilder}; pub use log_config::LogConfig; pub use logger::Logger; pub use flexi_logger::FlexiLogger; pub use flexi_error::FlexiLoggerError;