Crate bunyarrs

Crate bunyarrs 

Source
Expand description

§Bunyarrs

bunyarrs is a very opinionated, low performance logging library, modelled on node bunyan.


use bunyarrs::{Bunyarr, vars};
use serde_json::json;

let logger = Bunyarr::with_name("my-module");

let foo = init_foo();
let bar = init_bar();

logger.info(vars! { foo, bar }, "initialisation complete");
logger.debug(json!({ "version": 4, "hello": "world", }), "system stats");

The levels are in the following order:

  • debug
  • info
  • warn
  • error
  • fatal

The default log level is info, which can be changed with the LOG_LEVEL environment variable, e.g. LOG_LEVEL=error. There is no special handling for debug or fatal (i.e. this are always available in debug and production builds, and never interfere with program flow).

All of the log methods have the same signature, which accepts:

  • the context object, for which you can use vars! or json!, like above, or vars_dbg!, or you can specify () (nothing). This would ideally accept anything that can be turned into [(String, serde_json::Value)]. Please raise issues if you have an interesting usecase.
  • the “event name”. This is not a log line, in the traditional sense. There is no templating here, no placeholders, no support for dynamic strings at all. This should be a static string literal in nearly every situation.

Macros§

vars
vars_dbg

Structs§

Bunyarr
The main logger interface.