Crate quil

Source
Expand description

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" } }

Re-exports§

Modules§

  • A convenience module that can be used to include commonly used quil types.
  • Contains logger targets and the target trait for implementing custom targets

Macros§

Structs§

  • A logging context.
  • Logger has methods for logging messages from your program. This struct is the heart of Quil. Logger is clonable and can be send across threads safely.

Enums§