Giter Site home page Giter Site logo

chokecherry's Introduction

Chokecherry

Build Status

Wrapper around lager logger which limits the volume of info messages irrespectively of the lager's backend.

The calls chokecherry:info, chokecherry:warning, chokecherry:error are getting translated into the lager:info, lager:warning, lager:error, retaining the proper arity.

There are two ways to log out the original module's name and the invocation process' Pid:

  • Use the compiler option right inside the file which uses the chockecherry:
-compile([{parse_transform, chokecherry_transform}]).

Important: that line should precede the

-compile([{parse_transform, lager_transform}]).
  • Use that compiler option in the global rebar.config for the project:
{erl_opts, [
    % ...
    {parse_transform, chokecherry_transform},
    {parse_transform, lager_transform}
    % ...
}.

Important: the chokecherry_transform should precede the lager_transform.

Configuration

This application can be somewhat customized by redefining the following settings:

  • the queue length for the shaper
  • timeout for the shaper

Default settings are as follows:

[
    {chokecherry, [
        {shaper, [
            {timeout, 1000},
            {log_queue_capacity, 10000}
        ]}
    ]}
].

How it works

+------------+     +------------+     +------------+     +------------+
|            |     |            |     |            |     |            |
|    app     +----->   shaper   +----->   writer   +----->   lager    |
|            |     |            |     |            |     |            |
+------------+     +------------+     +------------+     +------------+

shaper accumulates incoming messages in the queue. If the queue size exceeds log_queue_capacity within a certain time period (1 second), it sends an error_report "chokecherry dropped N messages in the last second", and drops messages from the end of the queue, while receiving new ones and maintaining the maximum size of the queue.

writer pulls messages from shaper and transmits them to lager.

Changelog

0.2.8

  1. Simplify logic in chokecherry_shaper and chokecherry_writer.
  2. Configuration parameter {writer, [{timeout, 200}] doesn't need anymore.

0.2.7

  1. Added chokecherry_shaper_logger shaped messages gen_event manager.

chokecherry's People

Contributors

juise avatar savonarola avatar vlm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.