Browse Source

Merge branch 'master' into colorizing

Sam Clements 6 years ago
parent
commit
74b34f6eef
4 changed files with 17 additions and 9 deletions
  1. 3 3
      Cargo.toml
  2. 7 0
      LICENSE
  3. 4 4
      README.md
  4. 3 2
      src/lib.rs

+ 3 - 3
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "simple_logger"
-version = "0.5.0"
+version = "1.1.0"
 license = "MIT"
 authors = ["Sam Clements <sam@borntyping.co.uk>"]
 description = "A logger that prints all messages with a readable output format"
@@ -10,6 +10,6 @@ repository = "https://github.com/borntyping/rust-simple_logger"
 default = ["colored"]
 
 [dependencies]
-log = { version = "^0.4.1", features = ["std"] }
-time = "^0.1.25"
+log = { version = "^0.4.5", features = ["std"] }
+chrono = "0.4.6"
 colored = { version = "^1.6", optional = true }

+ 7 - 0
LICENSE

@@ -0,0 +1,7 @@
+Copyright 2015-2019 Sam Clements
+
+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.

+ 4 - 4
README.md

@@ -2,11 +2,11 @@
 
 A logger that prints all messages with a readable output format.
 
-The output format is based on the format used by [Supervisord](http://supervisord.org/). Future updates may include coulored output based on the log level of the message and selecting a log level based on the value of an input string (e.g. from a flag parsed by [docopt](https://github.com/docopt/docopt.rs)).
+The output format is based on the format used by [Supervisord](http://supervisord.org/).
 
-* `Source on GitHub <https://github.com/borntyping/rust-simple_logger>`_
-* `Packages on Crates.io <https://crates.io/crates/simple_logger>`_
-* `Builds on Travis CI <https://travis-ci.org/borntyping/rust-simple_logger>`_
+* [Source on GitHub](https://github.com/borntyping/rust-simple_logger)
+* [Packages on Crates.io](https://crates.io/crates/simple_logger)
+* [Builds on Travis CI](https://travis-ci.org/borntyping/rust-simple_logger)
 
 Usage
 -----

+ 3 - 2
src/lib.rs

@@ -1,12 +1,13 @@
 //! A logger that prints all messages with a readable output format.
 
 extern crate log;
-extern crate time;
+extern crate chrono;
 
 #[cfg(feature = "colored")] extern crate colored;
 #[cfg(feature = "colored")] use colored::*;
 
 use log::{Log,Level,Metadata,Record,SetLoggerError};
+use chrono::Local;
 
 struct SimpleLogger {
     level: Level,
@@ -35,7 +36,7 @@ impl Log for SimpleLogger {
             };
             println!(
                 "{} {:<5} [{}] {}",
-                time::strftime("%Y-%m-%d %H:%M:%S", &time::now()).unwrap(),
+                Local::now().format("%Y-%m-%d %H:%M:%S,%3f"),
                 level_string,
                 record.module_path().unwrap_or_default(),
                 record.args());