simplelog-0.7.4/CHANGELOG.md010060000017500001750000000062471355034067700135620ustar0000000000000000## v0.7.4 - Fixed time formats with ## v0.7.3 - Fixed `test` feature ## v0.7.2 - Allow Level Padding to be configured ## v0.7.1 - Fix `LevelFilter:Off` not turning off parts of the log messages ## v0.7.0 - Add local time zone option - Change config to builder pattern avoiding future major version bumps - Add further documentation about dealing with `TermLogger` failing - `term` 0.6.* is now also supported ## v0.6.0 - Add time offset parameter (defaults to UTC) - Add thread_id output (credits to @kurtlawrence) - Pad log level - Add TestLogger (credits to @AlexW-GH) - Add stream configuration to TermLogger - Implement allow- and ignore-filtering (credits to @ryankurte) ## v0.5.3 - Fix minimal chrono version / update to chrono v0.4.1 (PR #27, credits to @samueltardieu) ## v0.5.2 - Don't interleave stdout and stderr (PR #23, credits to @hansjorg) ## v0.5.1 - Updated `simplelog` to `log` 0.4.1 - Updated `simplelog` to `term` 0.5.1 - Fixed compiler warning about unused `#[macro_use]` ## v0.5.0 - Update `simplelog` to `log` 0.4 ## v0.4.4 - Fixed building non-default feature sets ## v0.4.3 - Publically export TermLogger Error type ## v0.4.2 - Removed a debug println! statement ## v0.4.1 - Fix `None` config value ## v0.4.0 - `Config` is not using `LogLevelFilter` anymore but `Option` - `None` represents no logging of the `Config` parameter at all - `LogLevelFilter::Off` was supposed to provide this feature, but is actually ordered higher then `LogLevelFilter::Error`, and presents *no filtering* instead of the incorrectly assumed *filter everything*. ## v0.3.0 - Merged PullRequest by *Antoni Boucher* - Avoid unwrapping in `TermLogger`: - `TermLogger::new` now returns an Option - `TermLogger::init` now has its own ErrorType - Move FileLogger to WriteLogger - More generic, accepts not only `File`, but everything that implements `Write` - Loggers now initialize with a `Config` struct, that list, what parts of the typical log message shall be printed, at which levels - Migrate from `::init(level, ...)` to `::init(level, Config::default(), ...)` - Migrate from `::new(level, ...)` or `::new(level, Config::default(), ...)` - Exception: `CombinedLogger` has no use for its own `Config` and does not take the new argument - Optionally use rust's `Default` syntax to override some settings - E.g. always print location: `Config { location: LogLevelFilter::Error, ..Default::default() }` - E.g. never print the target: `Config { target: LogLevelFilter::Off, ..Default::default() }` - Target does now by default only log for Debug and lower - Added CHANGELOG - Removed some internal code duplication ## v0.2.0 - Local changes that (accidentially) made it to crates.io, but not git - Basically a worse version of *Antoni Boucher* 0.3.0 changes - Got noticed, when he made a Pull Request Sorry, what a mess. If you still have that version, here are the docs: https://docs.rs/simplelog/0.2.0/ ## v0.1.0 - Initial Release simplelog-0.7.4/Cargo.toml.orig010060000017500001750000000012711355034047600146250ustar0000000000000000[package] name = "simplelog" version = "0.7.4" edition = "2018" authors = ["Drakulix "] description = "A simple and easy-to-use logging facility for Rust's log crate" documentation = "https://docs.rs/simplelog/" repository = "https://github.com/drakulix/simplelog.rs" readme = "README.md" keywords = ["log", "simplelog", "filelog", "logging"] license = "MIT OR Apache-2.0" include = [ "**/*.rs", "Cargo.toml", "CHANGELOG.md", "README.md", "LICENSE.APACHE2", "LICENSE.MIT", ] [features] test = [] default = ["term"] [dependencies] log = { version = "0.4.*", features = ["std"] } term = { version = ">=0.5.1, <0.7.0", optional = true } chrono = "0.4.*" simplelog-0.7.4/Cargo.toml0000644000000023040000000000000110730ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "simplelog" version = "0.7.4" authors = ["Drakulix "] include = ["**/*.rs", "Cargo.toml", "CHANGELOG.md", "README.md", "LICENSE.APACHE2", "LICENSE.MIT"] description = "A simple and easy-to-use logging facility for Rust's log crate" documentation = "https://docs.rs/simplelog/" readme = "README.md" keywords = ["log", "simplelog", "filelog", "logging"] license = "MIT OR Apache-2.0" repository = "https://github.com/drakulix/simplelog.rs" [dependencies.chrono] version = "0.4.*" [dependencies.log] version = "0.4.*" features = ["std"] [dependencies.term] version = ">=0.5.1, <0.7.0" optional = true [features] default = ["term"] test = [] simplelog-0.7.4/LICENSE.APACHE2010064400017500001750000000240171335204230400137450ustar0000000000000000Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. simplelog-0.7.4/LICENSE.MIT010064400017500001750000000020741335204230400133720ustar0000000000000000The MIT License (MIT) Copyright (c) 2015 Victor Brekenfeld Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. simplelog-0.7.4/README.md010060000017500001750000000055571355034075000132230ustar0000000000000000# simplelog [![Build Status](https://travis-ci.org/Drakulix/simplelog.rs.svg?branch=master)](https://travis-ci.org/Drakulix/simplelog.rs) [![Coverage Status](https://coveralls.io/repos/github/Drakulix/simplelog.rs/badge.svg?branch=master)](https://coveralls.io/github/Drakulix/simplelog.rs?branch=master) [![Crates.io](https://img.shields.io/crates/v/simplelog.svg)](https://crates.io/crates/simplelog) [![Crates.io](https://img.shields.io/crates/l/simplelog.svg)](https://crates.io/crates/simplelog) ## A simple and easy-to-use logging facility for Rust's [log](https://crates.io/crates/log) crate `simplelog` does not aim to provide a rich set of features, nor to provide the best logging solution. It aims to be a maintainable, easy to integrate facility for small to medium sized projects, that find [env_logger](https://crates.io/crates/env_logger) to be somewhat lacking in features. In those cases `simplelog` should provide an easy alternative. ## Concept `simplelog` provides a series of logging facilities, that can be easily combined. - `SimpleLogger` (very basic logger that logs to stderr/out, should never fail) - `TermLogger` (advanced terminal logger, that splits to stderr/out and has color support) (can be excluded on unsupported platforms) - `WriteLogger` (logs to a given struct implementing `Write`. e.g. a file) - `CombinedLogger` (can be used to form combinations of the above loggers) ## Usage ```rust #[macro_use] extern crate log; extern crate simplelog; use simplelog::*; use std::fs::File; fn main() { CombinedLogger::init( vec![ TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed).unwrap(), WriteLogger::new(LevelFilter::Info, Config::default(), File::create("my_rust_binary.log").unwrap()), ] ).unwrap(); error!("Bright red error"); info!("This only appears in the log file"); debug!("This level is currently not enabled for any logger"); } ``` ### Results in ``` $ cargo run --example usage Compiling simplelog v0.7.4 (file:///home/drakulix/Projects/simplelog) Running `target/debug/examples/usage` [ERROR] Bright red error ``` and my_rust_binary.log ``` 11:13:03 [ERROR] usage: Bright red error 11:13:03 [ INFO] usage: This only appears in the log file ``` ## Getting Started Just add ``` [dependencies] simplelog = "^0.7.4" ``` to your `Cargo.toml` ## [Documentation](https://docs.rs/simplelog/) ## Contributing If you wish to contribute your own logger to `simplelog` or advance/extend existing loggers, feel free to create a pull request. Just don't blindly assume, that your logger will be accepted. The rational about this library is, that it is simple to use. This mostly comes down to a small and easy API, but also includes things like the amount of added dependencies. If you feel unsure about your plans, feel free to create an issue to talk about your ideas. ### Happy Coding! simplelog-0.7.4/examples/usage.rs010060000017500001750000000012121353772366100152270ustar0000000000000000use log::*; use simplelog::*; use std::fs::File; fn main() { CombinedLogger::init(vec![ #[cfg(feature = "term")] TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed).unwrap(), #[cfg(not(feature = "term"))] SimpleLogger::new(LevelFilter::Warn, Config::default()), WriteLogger::new( LevelFilter::Info, Config::default(), File::create("my_rust_binary.log").unwrap(), ), ]) .unwrap(); error!("Bright red error"); info!("This only appears in the log file"); debug!("This level is currently not enabled for any logger"); } simplelog-0.7.4/src/config.rs010060000017500001750000000174141353644200600143420ustar0000000000000000use log::LevelFilter; pub use chrono::offset::{FixedOffset, Local, Offset, TimeZone, Utc}; use std::borrow::Cow; #[derive(Debug, Clone, Copy)] /// Padding to be used for logging the level pub enum LevelPadding { /// Add spaces on the left side Left, /// Add spaces on the right side Right, /// Do not pad the level Off, } /// Configuration for the Loggers /// /// All loggers print the message in the following form: /// `00:00:00 [LEVEL] crate::module: [lib.rs::100] your_message` /// Every space delimited part except the actual message is optional. /// /// Pass this struct to your logger to change when these information shall /// be logged. /// /// Construct using `Default` or using `ConfigBuilder` #[derive(Debug, Clone)] pub struct Config { pub(crate) time: LevelFilter, pub(crate) level: LevelFilter, pub(crate) level_padding: LevelPadding, pub(crate) thread: LevelFilter, pub(crate) target: LevelFilter, pub(crate) location: LevelFilter, pub(crate) time_format: Cow<'static, str>, pub(crate) time_offset: FixedOffset, pub(crate) time_local: bool, pub(crate) filter_allow: Cow<'static, [Cow<'static, str>]>, pub(crate) filter_ignore: Cow<'static, [Cow<'static, str>]>, } /// Builder for the Logger Confogurations (`Config`) /// /// All loggers print the message in the following form: /// `00:00:00 [LEVEL] crate::module: [lib.rs::100] your_message` /// Every space delimited part except the actual message is optional. /// /// Use this struct to create a custom `Config` changing when these information shall /// be logged. Every part can be enabled for a specific Level and is then /// automatically enable for all lower levels as well. /// /// The Result is that the logging gets more detailed the more verbose it gets. /// E.g. to have one part shown always use `Level::Error`. But if you /// want to show the source line only on `Trace` use that. #[derive(Debug, Clone)] pub struct ConfigBuilder(Config); impl ConfigBuilder { /// Create a new default ConfigBuilder pub fn new() -> ConfigBuilder { ConfigBuilder(Config::default()) } /// Set at which level and below the level itself shall be logged (default is Error) pub fn set_max_level<'a>(&'a mut self, level: LevelFilter) -> &'a mut ConfigBuilder { self.0.level = level; self } /// Set at which level and below the current time shall be logged (default is Error) pub fn set_time_level<'a>(&'a mut self, time: LevelFilter) -> &'a mut ConfigBuilder { self.0.time = time; self } /// Set at which level and below the thread id shall be logged. (default is Debug) pub fn set_thread_level<'a>(&'a mut self, thread: LevelFilter) -> &'a mut ConfigBuilder { self.0.thread = thread; self } /// Set at which level and below the target shall be logged. (default is Debug) pub fn set_target_level<'a>(&'a mut self, target: LevelFilter) -> &'a mut ConfigBuilder { self.0.target = target; self } /// Set at which level and below a source code reference shall be logged (default is Trace) pub fn set_location_level<'a>(&'a mut self, location: LevelFilter) -> &'a mut ConfigBuilder { self.0.location = location; self } /// Set how the levels should be padded, when logging (default is Left) pub fn set_level_padding<'a>(&'a mut self, padding: LevelPadding) -> &'a mut ConfigBuilder { self.0.level_padding = padding; self } /// Set time chrono strftime format string. See: https://docs.rs/chrono/0.4.0/chrono/format/strftime/index.html#specifiers pub fn set_time_format_str<'a>( &'a mut self, time_format: &'static str, ) -> &'a mut ConfigBuilder { self.0.time_format = Cow::Borrowed(time_format); self } /// Set time chrono strftime format string. See: https://docs.rs/chrono/0.4.0/chrono/format/strftime/index.html#specifiers pub fn set_time_format<'a>(&'a mut self, time_format: String) -> &'a mut ConfigBuilder { self.0.time_format = Cow::Owned(time_format); self } /// Set offset used for logging time (default is 0) pub fn set_time_offset<'a>(&'a mut self, time_offset: FixedOffset) -> &'a mut ConfigBuilder { self.0.time_offset = time_offset; self } /// set if you log in local timezone or UTC (default is UTC) pub fn set_time_to_local<'a>(&'a mut self, local: bool) -> &'a mut ConfigBuilder { self.0.time_local = local; self } /// Add allowed module filters. /// If any are specified, only records from modules starting with one of these entries will be printed /// /// For example, `add_filter_allow_str("tokio::uds")` would allow only logging from the `tokio` crates `uds` module. pub fn add_filter_allow_str<'a>( &'a mut self, time_format: &'static str, ) -> &'a mut ConfigBuilder { let mut list = Vec::from(&*self.0.filter_allow); list.push(Cow::Borrowed(time_format)); self.0.filter_allow = Cow::Owned(list); self } /// Add allowed module filters. /// If any are specified, only records from modules starting with one of these entries will be printed /// /// For example, `add_filter_allow(format!("{}{}","tokio", "uds"))` would allow only logging from the `tokio` crates `uds` module. pub fn add_filter_allow<'a>(&'a mut self, time_format: String) -> &'a mut ConfigBuilder { let mut list = Vec::from(&*self.0.filter_allow); list.push(Cow::Owned(time_format)); self.0.filter_allow = Cow::Owned(list); self } /// Clear allowed module filters. /// If none are specified, nothing is filtered out pub fn clear_filter_allow<'a>(&'a mut self) -> &'a mut ConfigBuilder { self.0.filter_allow = Cow::Borrowed(&[]); self } /// Add denied module filters. /// If any are specified, records from modules starting with one of these entries will be ignored /// /// For example, `add_filter_ignore_str("tokio::uds")` would deny logging from the `tokio` crates `uds` module. pub fn add_filter_ignore_str<'a>( &'a mut self, time_format: &'static str, ) -> &'a mut ConfigBuilder { let mut list = Vec::from(&*self.0.filter_ignore); list.push(Cow::Borrowed(time_format)); self.0.filter_ignore = Cow::Owned(list); self } /// Add denied module filters. /// If any are specified, records from modules starting with one of these entries will be ignored /// /// For example, `add_filter_ignore(format!("{}{}","tokio", "uds"))` would deny logging from the `tokio` crates `uds` module. pub fn add_filter_ignore<'a>(&'a mut self, time_format: String) -> &'a mut ConfigBuilder { let mut list = Vec::from(&*self.0.filter_ignore); list.push(Cow::Owned(time_format)); self.0.filter_ignore = Cow::Owned(list); self } /// Clear ignore module filters. /// If none are specified, nothing is filtered pub fn clear_filter_ignore<'a>(&'a mut self) -> &'a mut ConfigBuilder { self.0.filter_ignore = Cow::Borrowed(&[]); self } /// Build new `Config` pub fn build(&mut self) -> Config { self.0.clone() } } impl Default for Config { fn default() -> Config { Config { time: LevelFilter::Error, level: LevelFilter::Error, level_padding: LevelPadding::Left, thread: LevelFilter::Debug, target: LevelFilter::Debug, location: LevelFilter::Trace, time_format: Cow::Borrowed("%H:%M:%S"), time_offset: FixedOffset::east(0), time_local: false, filter_allow: Cow::Borrowed(&[]), filter_ignore: Cow::Borrowed(&[]), } } } simplelog-0.7.4/src/lib.rs010060000017500001750000000230231353772366100136460ustar0000000000000000// Copyright 2016 Victor Brekenfeld // // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. //! //! `simplelog` provides a series of logging facilities, that can be easily combined. //! //! - `SimpleLogger` (very basic logger that logs to stdout) //! - `TermLogger` (advanced terminal logger, that splits to stdout/err and has color support) (can be excluded on unsupported platforms) //! - `WriteLogger` (logs to a given struct implementing `Write`, e.g. a file) //! - `CombinedLogger` (can be used to form combinations of the above loggers) //! - `TestLogger` (specialized logger for tests. Uses print!() / println!() for tests to be able to capture the output) //! //! Only one Logger should be initialized of the start of your program //! through the `Logger::init(...)` method. For the actual calling syntax //! take a look at the documentation of the specific implementation(s) you wanna use. //! #![deny(missing_docs, rust_2018_idioms)] mod config; mod loggers; pub use self::config::{Config, ConfigBuilder, LevelPadding}; #[cfg(feature = "test")] pub use self::loggers::TestLogger; pub use self::loggers::{CombinedLogger, SimpleLogger, WriteLogger}; #[cfg(feature = "term")] pub use self::loggers::{TermLogError, TermLogger, TerminalMode}; pub use log::{Level, LevelFilter}; use log::Log; #[cfg(test)] use log::*; /// Trait to have a common interface to obtain the Level of Loggers /// /// Necessary for CombinedLogger to calculate /// the lowest used Level. /// pub trait SharedLogger: Log { /// Returns the set Level for this Logger /// /// # Examples /// /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// let logger = SimpleLogger::new(LevelFilter::Info, Config::default()); /// println!("{}", logger.level()); /// # } /// ``` fn level(&self) -> LevelFilter; /// Inspect the config of a running Logger /// /// An Option is returned, because some Logger may not contain a Config /// /// # Examples /// /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// let logger = SimpleLogger::new(LevelFilter::Info, Config::default()); /// println!("{:?}", logger.config()); /// # } /// ``` fn config(&self) -> Option<&Config>; /// Returns the logger as a Log trait object fn as_log(self: Box) -> Box; } #[cfg(test)] mod tests { use std::fs::File; use std::io::Read; use super::*; #[test] fn test() { let mut i = 0; CombinedLogger::init({ let mut vec = Vec::new(); let mut conf_builder = ConfigBuilder::new(); for elem in vec![ LevelFilter::Off, LevelFilter::Trace, LevelFilter::Debug, LevelFilter::Info, LevelFilter::Warn, LevelFilter::Error, ] { let conf = conf_builder .set_location_level(elem) .set_target_level(elem) .set_max_level(elem) .set_time_level(elem) .build(); i += 1; //error vec.push( SimpleLogger::new(LevelFilter::Error, conf.clone()) as Box ); #[cfg(feature = "term")] vec.push( TermLogger::new(LevelFilter::Error, conf.clone(), TerminalMode::Mixed).unwrap() as Box, ); vec.push(WriteLogger::new( LevelFilter::Error, conf.clone(), File::create(&format!("error_{}.log", i)).unwrap(), ) as Box); #[cfg(feature = "test")] vec.push(TestLogger::new(LevelFilter::Error, conf.clone())); //warn vec.push( SimpleLogger::new(LevelFilter::Warn, conf.clone()) as Box ); #[cfg(feature = "term")] vec.push( TermLogger::new(LevelFilter::Warn, conf.clone(), TerminalMode::Mixed).unwrap() as Box, ); vec.push(WriteLogger::new( LevelFilter::Warn, conf.clone(), File::create(&format!("warn_{}.log", i)).unwrap(), ) as Box); #[cfg(feature = "test")] vec.push(TestLogger::new(LevelFilter::Warn, conf.clone())); //info vec.push( SimpleLogger::new(LevelFilter::Info, conf.clone()) as Box ); #[cfg(feature = "term")] vec.push( TermLogger::new(LevelFilter::Info, conf.clone(), TerminalMode::Mixed).unwrap() as Box, ); vec.push(WriteLogger::new( LevelFilter::Info, conf.clone(), File::create(&format!("info_{}.log", i)).unwrap(), ) as Box); #[cfg(feature = "test")] vec.push(TestLogger::new(LevelFilter::Info, conf.clone())); //debug vec.push( SimpleLogger::new(LevelFilter::Debug, conf.clone()) as Box ); #[cfg(feature = "term")] vec.push( TermLogger::new(LevelFilter::Debug, conf.clone(), TerminalMode::Mixed).unwrap() as Box, ); vec.push(WriteLogger::new( LevelFilter::Debug, conf.clone(), File::create(&format!("debug_{}.log", i)).unwrap(), ) as Box); #[cfg(feature = "test")] vec.push(TestLogger::new(LevelFilter::Debug, conf.clone())); //trace vec.push( SimpleLogger::new(LevelFilter::Trace, conf.clone()) as Box ); #[cfg(feature = "term")] vec.push( TermLogger::new(LevelFilter::Trace, conf.clone(), TerminalMode::Mixed).unwrap() as Box, ); vec.push(WriteLogger::new( LevelFilter::Trace, conf.clone(), File::create(&format!("trace_{}.log", i)).unwrap(), ) as Box); #[cfg(feature = "test")] vec.push(TestLogger::new(LevelFilter::Trace, conf.clone())); } vec }) .unwrap(); error!("Test Error"); warn!("Test Warning"); info!("Test Information"); debug!("Test Debug"); trace!("Test Trace"); for j in 1..i { let mut error = String::new(); File::open(&format!("error_{}.log", j)) .unwrap() .read_to_string(&mut error) .unwrap(); let mut warn = String::new(); File::open(&format!("warn_{}.log", j)) .unwrap() .read_to_string(&mut warn) .unwrap(); let mut info = String::new(); File::open(&format!("info_{}.log", j)) .unwrap() .read_to_string(&mut info) .unwrap(); let mut debug = String::new(); File::open(&format!("debug_{}.log", j)) .unwrap() .read_to_string(&mut debug) .unwrap(); let mut trace = String::new(); File::open(&format!("trace_{}.log", j)) .unwrap() .read_to_string(&mut trace) .unwrap(); assert!(error.contains("Test Error")); assert!(!error.contains("Test Warning")); assert!(!error.contains("Test Information")); assert!(!error.contains("Test Debug")); assert!(!error.contains("Test Trace")); assert!(warn.contains("Test Error")); assert!(warn.contains("Test Warning")); assert!(!warn.contains("Test Information")); assert!(!warn.contains("Test Debug")); assert!(!warn.contains("Test Trace")); assert!(info.contains("Test Error")); assert!(info.contains("Test Warning")); assert!(info.contains("Test Information")); assert!(!info.contains("Test Debug")); assert!(!info.contains("Test Trace")); assert!(debug.contains("Test Error")); assert!(debug.contains("Test Warning")); assert!(debug.contains("Test Information")); assert!(debug.contains("Test Debug")); assert!(!debug.contains("Test Trace")); assert!(trace.contains("Test Error")); assert!(trace.contains("Test Warning")); assert!(trace.contains("Test Information")); assert!(trace.contains("Test Debug")); assert!(trace.contains("Test Trace")); } } } simplelog-0.7.4/src/loggers/comblog.rs010060000017500001750000000101561353772366100161670ustar0000000000000000// Copyright 2016 Victor Brekenfeld // // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. //! Module providing the CombinedLogger Implementation use crate::{Config, SharedLogger}; use log::{set_boxed_logger, set_max_level, LevelFilter, Log, Metadata, Record, SetLoggerError}; /// The CombinedLogger struct. Provides a Logger implementation that proxies multiple Loggers as one. /// /// The purpose is to allow multiple Loggers to be set globally pub struct CombinedLogger { level: LevelFilter, logger: Vec>, } impl CombinedLogger { /// init function. Globally initializes the CombinedLogger as the one and only used log facility. /// /// Takes all used Loggers as a Vector argument. None of those Loggers should already be set globally. /// /// All loggers need to implement `log::Log` and `logger::SharedLogger` and need to provide a way to be /// initialized without calling `set_logger`. All loggers of this library provide a `new(..)`` method /// for that purpose. /// Fails if another logger is already set globally. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # use std::fs::File; /// # fn main() { /// let _ = CombinedLogger::init( /// vec![ /// # #[cfg(feature = "term")] /// TermLogger::new(LevelFilter::Info, Config::default(), TerminalMode::Mixed).unwrap(), /// WriteLogger::new(LevelFilter::Info, Config::default(), File::create("my_rust_bin.log").unwrap()) /// ] /// ); /// # } /// ``` pub fn init(logger: Vec>) -> Result<(), SetLoggerError> { let comblog = CombinedLogger::new(logger); set_max_level(comblog.level()); set_boxed_logger(comblog) } /// allows to create a new logger, that can be independently used, no matter whats globally set. /// /// no macros are provided for this case and you probably /// dont want to use this function, but `init()`, if you dont want to build a `CombinedLogger`. /// /// Takes all used loggers as a Vector argument. The log level is automatically determined by the /// lowest log level used by the given loggers. /// /// All loggers need to implement log::Log. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # use std::fs::File; /// # fn main() { /// let combined_logger = CombinedLogger::new( /// vec![ /// # #[cfg(feature = "term")] /// TermLogger::new(LevelFilter::Debug, Config::default(), TerminalMode::Mixed).unwrap(), /// WriteLogger::new(LevelFilter::Info, Config::default(), File::create("my_rust_bin.log").unwrap()) /// ] /// ); /// # } /// ``` pub fn new(logger: Vec>) -> Box { let mut log_level = LevelFilter::Off; for log in &logger { if log_level < log.level() { log_level = log.level(); } } Box::new(CombinedLogger { level: log_level, logger: logger, }) } } impl Log for CombinedLogger { fn enabled(&self, metadata: &Metadata<'_>) -> bool { metadata.level() <= self.level } fn log(&self, record: &Record<'_>) { if self.enabled(record.metadata()) { for log in &self.logger { log.log(record); } } } fn flush(&self) { for log in &self.logger { log.flush(); } } } impl SharedLogger for CombinedLogger { fn level(&self) -> LevelFilter { self.level } fn config(&self) -> Option<&Config> { None } fn as_log(self: Box) -> Box { Box::new(*self) } } simplelog-0.7.4/src/loggers/logging.rs010060000017500001750000000073211355033320400161540ustar0000000000000000use crate::{Config, LevelPadding}; use chrono; use log::{LevelFilter, Record}; use std::io::{Error, Write}; use std::thread; #[inline(always)] pub fn try_log(config: &Config, record: &Record<'_>, write: &mut W) -> Result<(), Error> where W: Write + Sized, { if should_skip(config, record) { return Ok(()); } if config.time <= record.level() && config.time != LevelFilter::Off { write_time(write, config)?; } if config.level <= record.level() && config.level != LevelFilter::Off { write_level(record, write, config)?; } if config.thread <= record.level() && config.thread != LevelFilter::Off { write_thread_id(write)?; } if config.target <= record.level() && config.target != LevelFilter::Off { write_target(record, write)?; } if config.location <= record.level() && config.location != LevelFilter::Off { write_location(record, write)?; } write_args(record, write) } #[inline(always)] pub fn write_time(write: &mut W, config: &Config) -> Result<(), Error> where W: Write + Sized, { let cur_time = if config.time_local { (chrono::Local::now() + config.time_offset).format(&*config.time_format) } else { (chrono::Utc::now() + config.time_offset).format(&*config.time_format) }; write!(write, "{} ", cur_time)?; Ok(()) } #[inline(always)] pub fn write_level(record: &Record<'_>, write: &mut W, config: &Config) -> Result<(), Error> where W: Write + Sized, { match config.level_padding { LevelPadding::Left => write!(write, "[{: >5}] ", record.level())?, LevelPadding::Right => write!(write, "[{: <5}] ", record.level())?, LevelPadding::Off => write!(write, "[{}] ", record.level())?, }; Ok(()) } #[inline(always)] pub fn write_target(record: &Record<'_>, write: &mut W) -> Result<(), Error> where W: Write + Sized, { write!(write, "{}: ", record.target())?; Ok(()) } #[inline(always)] pub fn write_location(record: &Record<'_>, write: &mut W) -> Result<(), Error> where W: Write + Sized, { let file = record.file().unwrap_or(""); if let Some(line) = record.line() { write!(write, "[{}:{}] ", file, line)?; } else { write!(write, "[{}:] ", file)?; } Ok(()) } pub fn write_thread_id(write: &mut W) -> Result<(), Error> where W: Write + Sized, { let id = format!("{:?}", thread::current().id()); let id = id.replace("ThreadId(", ""); let id = id.replace(")", ""); write!(write, "({}) ", id)?; Ok(()) } #[inline(always)] pub fn write_args(record: &Record<'_>, write: &mut W) -> Result<(), Error> where W: Write + Sized, { writeln!(write, "{}", record.args())?; Ok(()) } #[inline(always)] pub fn should_skip(config: &Config, record: &Record<'_>) -> bool { // If a module path and allowed list are available match (record.module_path(), &*config.filter_allow) { (Some(path), allowed) if allowed.len() > 0 => { // Check that the module path matches at least one allow filter if let None = allowed.iter().find(|v| path.starts_with(&***v)) { // If not, skip any further writing return true; } } _ => {} } // If a module path and ignore list are available match (record.module_path(), &*config.filter_ignore) { (Some(path), ignore) if ignore.len() > 0 => { // Check that the module path does not match any ignore filters if let Some(_) = ignore.iter().find(|v| path.starts_with(&***v)) { // If not, skip any further writing return true; } } _ => {} } return false; } simplelog-0.7.4/src/loggers/mod.rs010060000017500001750000000006211353770703000153100ustar0000000000000000mod comblog; pub mod logging; mod simplelog; #[cfg(feature = "term")] mod termlog; #[cfg(feature = "test")] mod testlog; mod writelog; pub use self::comblog::CombinedLogger; pub use self::simplelog::SimpleLogger; #[cfg(feature = "term")] pub use self::termlog::{TermLogError, TermLogger, TerminalMode}; #[cfg(feature = "test")] pub use self::testlog::TestLogger; pub use self::writelog::WriteLogger; simplelog-0.7.4/src/loggers/simplelog.rs010064400017500001750000000066111355033326200165360ustar0000000000000000// Copyright 2016 Victor Brekenfeld // // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. //! Module providing the SimpleLogger Implementation use super::logging::try_log; use crate::{Config, SharedLogger}; use log::{ set_boxed_logger, set_max_level, Level, LevelFilter, Log, Metadata, Record, SetLoggerError, }; use std::io::{stderr, stdout}; use std::sync::Mutex; /// The SimpleLogger struct. Provides a very basic Logger implementation pub struct SimpleLogger { level: LevelFilter, config: Config, output_lock: Mutex<()>, } impl SimpleLogger { /// init function. Globally initializes the SimpleLogger as the one and only used log facility. /// /// Takes the desired `Level` and `Config` as arguments. They cannot be changed later on. /// Fails if another Logger was already initialized. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// let _ = SimpleLogger::init(LevelFilter::Info, Config::default()); /// # } /// ``` pub fn init(log_level: LevelFilter, config: Config) -> Result<(), SetLoggerError> { set_max_level(log_level.clone()); set_boxed_logger(SimpleLogger::new(log_level, config)) } /// allows to create a new logger, that can be independently used, no matter what is globally set. /// /// no macros are provided for this case and you probably /// dont want to use this function, but `init()`, if you dont want to build a `CombinedLogger`. /// /// Takes the desired `Level` and `Config` as arguments. They cannot be changed later on. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// let simple_logger = SimpleLogger::new(LevelFilter::Info, Config::default()); /// # } /// ``` pub fn new(log_level: LevelFilter, config: Config) -> Box { Box::new(SimpleLogger { level: log_level, config: config, output_lock: Mutex::new(()), }) } } impl Log for SimpleLogger { fn enabled(&self, metadata: &Metadata<'_>) -> bool { metadata.level() <= self.level } fn log(&self, record: &Record<'_>) { if self.enabled(record.metadata()) { let _lock = self.output_lock.lock().unwrap(); match record.level() { Level::Error => { let stderr = stderr(); let mut stderr_lock = stderr.lock(); let _ = try_log(&self.config, record, &mut stderr_lock); } _ => { let stdout = stdout(); let mut stdout_lock = stdout.lock(); let _ = try_log(&self.config, record, &mut stdout_lock); } } } } fn flush(&self) { use std::io::Write; let _ = stdout().flush(); } } impl SharedLogger for SimpleLogger { fn level(&self) -> LevelFilter { self.level } fn config(&self) -> Option<&Config> { Some(&self.config) } fn as_log(self: Box) -> Box { Box::new(*self) } } simplelog-0.7.4/src/loggers/termlog.rs010060000017500001750000000231471353644200600162100ustar0000000000000000//! Module providing the TermLogger Implementation use log::{ set_boxed_logger, set_max_level, Level, LevelFilter, Log, Metadata, Record, SetLoggerError, }; use std::error; use std::fmt; use std::io::{Error, Write}; use std::sync::Mutex; use term; use term::{color, StderrTerminal, StdoutTerminal, Terminal}; use self::TermLogError::{SetLogger, Term}; use super::logging::*; use crate::{Config, SharedLogger}; /// TermLogger error type. #[derive(Debug)] pub enum TermLogError { ///The type returned by set_logger if set_logger has already been called. SetLogger(SetLoggerError), ///TermLogger initialization might also fail if stdout or stderr could not be opened, ///e.g. when no tty is attached to the process, it runs detached in the background, etc /// This is represented by the `Term` Kind Term, } impl fmt::Display for TermLogError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use std::error::Error as FmtError; write!(f, "{}", self.description()) } } impl error::Error for TermLogError { fn description(&self) -> &str { match *self { SetLogger(ref err) => err.description(), Term => "A terminal could not be opened", } } fn cause(&self) -> Option<&dyn error::Error> { match *self { SetLogger(ref err) => Some(err), Term => None, } } } impl From for TermLogError { fn from(error: SetLoggerError) -> Self { SetLogger(error) } } enum StdTerminal { Stderr(Box), Stdout(Box), } impl StdTerminal { fn flush(&mut self) -> Result<(), Error> { match self { StdTerminal::Stderr(term) => term.flush(), StdTerminal::Stdout(term) => term.flush(), } } } struct OutputStreams { err: StdTerminal, out: StdTerminal, } /// Specifies which streams should be used when logging pub enum TerminalMode { /// Only use Stdout Stdout, /// Only use Stderr Stderr, /// Use Stderr for Errors and Stdout otherwise Mixed, } impl Default for TerminalMode { fn default() -> TerminalMode { TerminalMode::Mixed } } /// The TermLogger struct. Provides a stderr/out based Logger implementation /// /// Supports colored output pub struct TermLogger { level: LevelFilter, config: Config, streams: Mutex, } impl TermLogger { /// init function. Globally initializes the TermLogger as the one and only used log facility. /// /// Takes the desired `Level` and `Config` as arguments. They cannot be changed later on. /// Fails if another Logger was already initialized or if a terminal couldn't be opened. /// /// Workaround the latter by either /// - panic'ing (not recommended). e.g. `TermLogger::init(LevelFilter::Warn, Config::default(), TerminalMode::Mixed).unwrap()` /// - silently ignoring (little better). e.g. `let _ = TermLogger::init(LevelFilter::Warn, Config::default(), TerminalMode::Mixed);` /// - falling back: /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// if let Err(_) = TermLogger::init(LevelFilter::Warn, Config::default(), TerminalMode::Mixed) { /// SimpleLogger::init(LevelFilter::Warn, Config::default()).expect("No logger should be already set") /// } /// # } /// ``` /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// TermLogger::init(LevelFilter::Info, Config::default(), TerminalMode::Mixed).expect("No interactive terminal"); /// # } /// ``` pub fn init( log_level: LevelFilter, config: Config, mode: TerminalMode, ) -> Result<(), TermLogError> { let logger = TermLogger::new(log_level, config, mode).ok_or(Term)?; set_max_level(log_level.clone()); set_boxed_logger(logger)?; Ok(()) } /// allows to create a new logger, that can be independently used, no matter whats globally set. /// /// no macros are provided for this case and you probably /// dont want to use this function, but `init()`, if you dont want to build a `CombinedLogger`. /// /// Takes the desired `Level` and `Config` as arguments. They cannot be changed later on. /// /// Returns a `Box`ed TermLogger, or None if a terminal couldn't be opened. /// Workaround this by either /// - panic'ing (not recommended). e.g. `TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed).unwrap()` /// - silently ignoring (little better). e.g. `if let Some(logger) = TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed) { /*...*/ }` /// - falling back: /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// let mut multiple = vec![]; /// match TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed) { /// Some(logger) => multiple.push(logger as Box), /// None => multiple.push(SimpleLogger::new(LevelFilter::Warn, Config::default())), /// } /// // Add more ... /// # } /// ``` /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// let term_logger = TermLogger::new(LevelFilter::Info, Config::default(), TerminalMode::Mixed).expect("No interactive terminal"); /// # } /// ``` pub fn new( log_level: LevelFilter, config: Config, mode: TerminalMode, ) -> Option> { let streams = match mode { TerminalMode::Stdout => term::stdout().and_then(|stdout| { term::stdout().map(|stdout2| { Mutex::new(OutputStreams { err: StdTerminal::Stdout(stdout), out: StdTerminal::Stdout(stdout2), }) }) }), TerminalMode::Stderr => term::stderr().and_then(|stderr| { term::stderr().map(|stderr2| { Mutex::new(OutputStreams { err: StdTerminal::Stderr(stderr), out: StdTerminal::Stderr(stderr2), }) }) }), TerminalMode::Mixed => term::stderr().and_then(|stderr| { term::stdout().map(|stdout| { Mutex::new(OutputStreams { err: StdTerminal::Stderr(stderr), out: StdTerminal::Stdout(stdout), }) }) }), }; streams.map(|streams| { Box::new(TermLogger { level: log_level, config: config, streams: streams, }) }) } fn try_log_term( &self, record: &Record<'_>, term_lock: &mut Box + Send>, ) -> Result<(), Error> where W: Write + Sized, { let color = match record.level() { Level::Error => color::RED, Level::Warn => color::YELLOW, Level::Info => color::BLUE, Level::Debug => color::CYAN, Level::Trace => color::WHITE, }; if self.config.time <= record.level() && self.config.time != LevelFilter::Off { write_time(&mut *term_lock, &self.config)?; } if self.config.level <= record.level() && self.config.level != LevelFilter::Off { term_lock.fg(color)?; write_level(record, &mut *term_lock, &self.config)?; term_lock.reset()?; } if self.config.thread <= record.level() && self.config.thread != LevelFilter::Off { write_thread_id(&mut *term_lock)?; } if self.config.target <= record.level() && self.config.target != LevelFilter::Off { write_target(record, &mut *term_lock)?; } if self.config.location <= record.level() && self.config.location != LevelFilter::Off { write_location(record, &mut *term_lock)?; } write_args(record, &mut *term_lock) } fn try_log(&self, record: &Record<'_>) -> Result<(), Error> { if self.enabled(record.metadata()) { if should_skip(&self.config, record) { return Ok(()); } let mut streams = self.streams.lock().unwrap(); if record.level() == Level::Error { match streams.err { StdTerminal::Stderr(ref mut term) => self.try_log_term(record, term), StdTerminal::Stdout(ref mut term) => self.try_log_term(record, term), } } else { match streams.out { StdTerminal::Stderr(ref mut term) => self.try_log_term(record, term), StdTerminal::Stdout(ref mut term) => self.try_log_term(record, term), } } } else { Ok(()) } } } impl Log for TermLogger { fn enabled(&self, metadata: &Metadata<'_>) -> bool { metadata.level() <= self.level } fn log(&self, record: &Record<'_>) { let _ = self.try_log(record); } fn flush(&self) { let mut streams = self.streams.lock().unwrap(); let _ = streams.out.flush(); let _ = streams.err.flush(); } } impl SharedLogger for TermLogger { fn level(&self) -> LevelFilter { self.level } fn config(&self) -> Option<&Config> { Some(&self.config) } fn as_log(self: Box) -> Box { Box::new(*self) } } simplelog-0.7.4/src/loggers/testlog.rs010060000017500001750000000120051353770724300162170ustar0000000000000000// Copyright 2016 Victor Brekenfeld // // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. //! Module providing the TestLogger Implementation use super::logging::should_skip; use crate::{Config, SharedLogger, LevelPadding}; use log::{set_boxed_logger, set_max_level, LevelFilter, Log, Metadata, Record, SetLoggerError}; use std::thread; /// The TestLogger struct. Provides a very basic Logger implementation that may be captured by cargo. pub struct TestLogger { level: LevelFilter, config: Config, } impl TestLogger { /// init function. Globally initializes the TestLogger as the one and only used log facility. /// /// Takes the desired `Level` and `Config` as arguments. They cannot be changed later on. /// Fails if another Logger was already initialized. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// #[cfg(not(test))] /// // another logger /// # let _ = TestLogger::init(LevelFilter::Info, Config::default()); /// #[cfg(test)] /// let _ = TestLogger::init(LevelFilter::Info, Config::default()); /// # } /// ``` pub fn init(log_level: LevelFilter, config: Config) -> Result<(), SetLoggerError> { set_max_level(log_level.clone()); set_boxed_logger(TestLogger::new(log_level, config)) } /// allows to create a new logger, that can be independently used, no matter what is globally set. /// /// no macros are provided for this case and you probably /// dont want to use this function, but `init()`, if you dont want to build a `CombinedLogger`. /// /// Takes the desired `Level` and `Config` as arguments. They cannot be changed later on. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # fn main() { /// #[cfg(not(test))] /// // another logger /// # let test_logger = TestLogger::new(LevelFilter::Info, Config::default()); /// #[cfg(test)] /// let test_logger = TestLogger::new(LevelFilter::Info, Config::default()); /// # } /// ``` pub fn new(log_level: LevelFilter, config: Config) -> Box { Box::new(TestLogger { level: log_level, config, }) } } impl Log for TestLogger { fn enabled(&self, metadata: &Metadata<'_>) -> bool { metadata.level() <= self.level } fn log(&self, record: &Record<'_>) { if self.enabled(record.metadata()) { let _ = log(&self.config, record); } } fn flush(&self) {} } impl SharedLogger for TestLogger { fn level(&self) -> LevelFilter { self.level } fn config(&self) -> Option<&Config> { Some(&self.config) } fn as_log(self: Box) -> Box { Box::new(*self) } } #[inline(always)] pub fn log(config: &Config, record: &Record<'_>) { if should_skip(&config, &record) { return; } if config.time <= record.level() && config.time != LevelFilter::Off { write_time(config); } if config.level <= record.level() && config.level != LevelFilter::Off { write_level(record, config); } if config.thread < record.level() && config.thread != LevelFilter::Off { write_thread_id(); } if config.target <= record.level() && config.target != LevelFilter::Off { write_target(record); } if config.location <= record.level() && config.location != LevelFilter::Off { write_location(record); } write_args(record); } #[inline(always)] pub fn write_time(config: &Config) { let cur_time = if config.time_local { chrono::Local::now().naive_local() + config.time_offset } else { chrono::Utc::now().naive_utc() + config.time_offset }; print!( "{} ", cur_time.format(&*config.time_format) ); } #[inline(always)] pub fn write_level(record: &Record<'_>, config: &Config) { match config.level_padding { LevelPadding::Left => print!("[{: >5}] ", record.level()), LevelPadding::Right => print!("[{: <5}] ", record.level()), LevelPadding::Off => print!("[{}] ", record.level()), }; } #[inline(always)] pub fn write_thread_id() { let id = format!("{:?}", thread::current().id()); let id = id.replace("ThreadId(", ""); let id = id.replace(")", ""); print!("({}) ", id); } #[inline(always)] pub fn write_target(record: &Record<'_>) { print!("{}: ", record.target()); } #[inline(always)] pub fn write_location(record: &Record<'_>) { let file = record.file().unwrap_or(""); if let Some(line) = record.line() { print!("[{}:{}] ", file, line); } else { print!("[{}:] ", file); } } #[inline(always)] pub fn write_args(record: &Record<'_>) { println!("{}", record.args()); } simplelog-0.7.4/src/loggers/writelog.rs010060000017500001750000000064361352705353700164040ustar0000000000000000// Copyright 2016 Victor Brekenfeld // // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. //! Module providing the FileLogger Implementation use super::logging::try_log; use crate::{Config, SharedLogger}; use log::{set_boxed_logger, set_max_level, LevelFilter, Log, Metadata, Record, SetLoggerError}; use std::io::Write; use std::sync::Mutex; /// The WriteLogger struct. Provides a Logger implementation for structs implementing `Write`, e.g. File pub struct WriteLogger { level: LevelFilter, config: Config, writable: Mutex, } impl WriteLogger { /// init function. Globally initializes the WriteLogger as the one and only used log facility. /// /// Takes the desired `Level`, `Config` and `Write` struct as arguments. They cannot be changed later on. /// Fails if another Logger was already initialized. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # use std::fs::File; /// # fn main() { /// let _ = WriteLogger::init(LevelFilter::Info, Config::default(), File::create("my_rust_bin.log").unwrap()); /// # } /// ``` pub fn init(log_level: LevelFilter, config: Config, writable: W) -> Result<(), SetLoggerError> { set_max_level(log_level.clone()); set_boxed_logger(WriteLogger::new(log_level, config, writable)) } /// allows to create a new logger, that can be independently used, no matter what is globally set. /// /// no macros are provided for this case and you probably /// dont want to use this function, but `init()`, if you dont want to build a `CombinedLogger`. /// /// Takes the desired `Level`, `Config` and `Write` struct as arguments. They cannot be changed later on. /// /// # Examples /// ``` /// # extern crate simplelog; /// # use simplelog::*; /// # use std::fs::File; /// # fn main() { /// let file_logger = WriteLogger::new(LevelFilter::Info, Config::default(), File::create("my_rust_bin.log").unwrap()); /// # } /// ``` pub fn new(log_level: LevelFilter, config: Config, writable: W) -> Box> { Box::new(WriteLogger { level: log_level, config: config, writable: Mutex::new(writable), }) } } impl Log for WriteLogger { fn enabled(&self, metadata: &Metadata<'_>) -> bool { metadata.level() <= self.level } fn log(&self, record: &Record<'_>) { if self.enabled(record.metadata()) { let mut write_lock = self.writable.lock().unwrap(); let _ = try_log(&self.config, record, &mut *write_lock); } } fn flush(&self) { let _ = self.writable.lock().unwrap().flush(); } } impl SharedLogger for WriteLogger { fn level(&self) -> LevelFilter { self.level } fn config(&self) -> Option<&Config> { Some(&self.config) } fn as_log(self: Box) -> Box { Box::new(*self) } } simplelog-0.7.4/Cargo.lock0000644000000424040000000000000110550ustar00# This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] name = "arrayref" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "arrayvec" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" version = "0.3.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "base64" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "blake2b_simd" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "byteorder" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chrono" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crossbeam-utils" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "dirs" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "dirs-sys" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "nodrop" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num-integer" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "proc-macro2" version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand_os" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "redox_users" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rust-argon2" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "blake2b_simd 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "simplelog" version = "0.7.4" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" version = "0.15.44" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "synstructure" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "term" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" "checksum backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum blake2b_simd 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bf775a81bb2d464e20ff170ac20316c7b08a43d11dbc72f0f82e8e8d3d6d0499" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "b548a4ee81fccb95919d4e22cfea83c7693ebfd78f0495493178db20b3139da7" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" "checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum term 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"