basho/hut

Name: hut

Owner: Basho Technologies

Description: helper library for making Erlang libraries logging framework agnostic

Forked from: tolbrino/hut

Created: 2017-01-06 19:58:58.0

Updated: 2017-01-06 19:59:00.0

Pushed: 2016-11-02 09:11:38.0

Homepage:

Size: 75

Language: Erlang

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

BuildStatus

Overview

Hut is a header-only library for Erlang libraries and small applications to stay agnostic to the logging framework in use. Its purpose is to allow the developers of umbrella applications to use their logging framework of choice and ensure that dependency stick to that choice as well.

Origin

The idea for Hut came out of a discussion about exometer_core's logging facilities.

Usage
  1. Include Hut as a dependency in your toolchain.
  2. Include Hut in your .erl files via -include_lib(hut/include/hut.hrl)
  3. Log with
  4. ?log(Level, Msg) to log the given message
  5. ?log(Level, Fmt, Args) to format the given message with the arguments using io_lib:format/2
  6. ?log(Level, Fmt, Args, Opts) to pass additional options to the logging backend in use
  7. Compile and pass the appropriate macro to the compiler to enable a certain backend as described next.
  8. Ensure that the application hut is started as part of your system.
Supported Logging Backends
Log Level Gates

Hut provides a simple mechanisms to drop log messages depending on the enabled log level. The functionality is similar to how Lager works with log levels.

The current log level (default is info) can be set through the application variable level:

-hut level debug

All log messages with levels below the current log level will be dropped.

The gating mechanism can be disabled through the application variable use_log_level_gate:

-hut use_log_level_gate false

NOTE: The gating mechanism is not supported for the Lager backend, since Lager itself provides a similar functionality which you should rely on when using Lager.

Examples

Refer to the respective Makefile in each example for details.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.