Giter VIP home page Giter VIP logo

lager_extras's Introduction

A collection of backends, formatters, and decorators for lager. All configurations are done as property lists.

Decorators

Decorators are formatters that take another formatter as a parameter, then modify the output. All require a parameter:

{formatter, {Formatter, Config}}

This will take the output of lager_default_formatter and add ansi color codes to it for output.

lager_gelf_formatter

Creates a json record of the log message, including all metadata, suitable for sending to graylog2. Warning: strings will be turned into arrays of integers while binaries are mapped to JSON strings. The formatter tries to take an educated guess on metadata, but host and facility should be binaries in the configuration.

Config

{host, Name}  % name of the host to report.  default: "erlang"
{facility, Name} % facility name used to report. default: "erlang"
{short_message_size, N::integer()} % first N bytes of the message will be the short message. default: 80
{utf8,boolean()} % whether to use utf8 or not.  default: true 

lager_json_formatter

A basic JSON writer. Creates individual objects for each message, converting the metadata properties to key: value pairs.

Config

{utf8,boolean()} % whether to use utf8 or not.  default: true 

lager_ansi_color_decorator

Creates color for each severity that shows on the console. Useful when dumping to the console, but will just junk up log files with ANSI color codes.

Config

{formatter, {Formatter,Config}}  % The formatter and it's config that we will wrap.  Required.
{algorithm, gzip | compress | zip } % The algorithm to use for compression.  Default: gzip
{debug | info | notice | warning | error | critical | alert | emergency, color()} % override the color for a particular log level.  Optional.

lager_zlib_decorator

Compressess the output in a variety of compression formats. Note that the messages are compressed individually, so you can't write a compressed file this way due to the fact that gzip, compress, and zip do not concatenate in a straightforward manner. This is largely intended to be used with the udp backend.

Config

{formatter, {Formatter,Config}}  % The formatter and it's config that we will wrap.  Required.
{algorithm, gzip | compress | zip } % The algorithm to use for compression.  Default: gzip

lager_udp_backend

Sends the log message as a UDP packet to a host and port.

Config

{host, any()}  % who to send the packets to.  required
{port, integer()} % udp port to send to.  required

{level, level()}  % threshold to report on this logger.  default: debug
{formatter,atom()} % formatter.  default: lager_default_formatter),
{format_config, any()} % configuraiton for the formatter.  default: []
{inet_family, inet | inet6} % IPv4 or IPv6?  default: inet
{name, any()}  % name of the backend (for trace support).  default: {Host,Port}

Example: Graylog2 Config

Supporting Graylog2 is what started most of this. Use this to send compressed gelf to a Graylog2 server

{lager_udp_backend, [
   {host, "graylog2.myhost.com"},
   {port, 12201},
   {level, debug}, 
   {name, graylog2},
   {formatter, lager_zlib_decorator},
   {format_config, [
     {algorithm, compress},
     {formatter, {
       lager_gelf_formatter,[
         {host,<<"server">>},
         {facility,<<"erlang process">>}
       ]}
     }
   ]}
 ]}

lager_extras's People

Contributors

nialscorva 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.