7 unstable releases (3 breaking)

Uses old Rust 2015

0.4.1 Nov 23, 2017
0.4.0 Nov 15, 2017
0.3.2 Nov 8, 2017
0.2.0 Nov 8, 2017
0.1.0 Sep 29, 2017

#34 in #targets

MIT license

26KB
413 lines

Quil is a easy to use library that supports message levels, multiple output targets, sub-loggers, and message contexts. Quil can be used across threads safely, and is easy to extend.

Examples

Basic example:

let logger = Logger::new(Console::new(), context!{ src: "root" });

logger.info("hello world");
Tue,  7 Nov 2017 23:55:42 +0000 - info:    hello world src=root

Sub-context example:

let logger = Logger::new(Console::new(), context!{ src: "root", tag: "1" });
logger.info("hello");

let sub_logger = logger.ctx(context!{ tag: "", marker: "49" });
logger.info("world");
Tue,  7 Nov 2017 23:55:42 +0000 - info:    hello src=root tag=1
Tue,  7 Nov 2017 23:55:42 +0000 - info:    world src=root marker=49

Multi-target example:

let logger = Logger::new(targets![
  Console::new(),
  JsonFile::open("path/to/logfile.json"),
], context!{ some_meta_key: "some_meta_value" });

logger.info("hello");

let sub_logger = logger.ctx(context!{ marker: "49" });
logger.warn("world");

Shell:

Tue,  7 Nov 2017 23:55:42 +0000 - info:    hello some_meta_key=some_meta_value
Tue,  7 Nov 2017 23:55:42 +0000 - warn:    world some_meta_key=some_meta_value marker=49

Log File:

{ "level": "info", "message": "hello", "context": { "some_meta_key": "some_meta_value" } }
{ "level": "warn", "message": "world", "context": { "some_meta_key": "some_meta_value", "marker": "49" } }

Quil is a easy to use library that supports message levels, multiple targets, and message contexts. Quil is thread safe and so it is possible to send loggers accross threads.

Documentation

Examples

Basic example:

let logger = Logger::new(Console::new(), context!{ src: "root" });

logger.info("hello world");
Tue,  7 Nov 2017 23:55:42 +0000 - info:    hello world src=root

Sub-context example:

let logger = Logger::new(Console::new(), context!{ src: "root", tag: "1" });
logger.info("hello");

let sub_logger = logger.ctx(context!{ tag: "", marker: "49" });
logger.info("world");
Tue,  7 Nov 2017 23:55:42 +0000 - info:    hello src=root tag=1
Tue,  7 Nov 2017 23:55:42 +0000 - info:    world src=root marker=49

Dependencies

~1–8MB
~57K SLoC