Skip to content

RobertWHurst/Quil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple logger for Rust projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages