Project

logasm

0.0
No release in over 3 years
Low commit activity in last 3 years
It's logasmic
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Lenjador

Usage

Creating a new Lenjador logger in Ruby

Lenjador.build(application_name, logger_config)

logger_config is a hash with logger types and their configuration.

Configuration

loggers:
  stdout:
    level: 'debug'

Supported log levels:

  1. fatal
  2. error
  3. warn
  4. info
  5. debug

For example level: 'warn' will log everything with warn and above.

Examples

Creating a new stdout logger

require 'lenjador'

lenjador = Lenjador.build('myApp', stdout: nil)

When no loggers are specified, it creates a stdout logger by default.

Preprocessors

Preprocessors allow modification of log messages, prior to sending of the message to the configured logger(s).

Blacklist

Excludes or masks defined fields of the passed hash object. You can specify the name of the field and which action to take on it. Nested hashes of any level are preprocessed as well.

Available actions:

  • prune (default) - fully excludes the field and its value from the hash.
  • mask - replaces every character from the original value with *. In case of array, hash or boolean value is replaced with one *.

Configuration

preprocessors:
  blacklist:
    fields:
      - key: password
      - key: phone
    action: mask

Usage

logger = Lenjador.build(application_name, logger_config, preprocessors)

input = {password: 'password', info: {phone: '+12055555555'}}

logger.debug("Received request", input)

Logger output:

Received request {"info":{"phone":"************"}}

Whitelist

Prunes or masks all the fields except those whitelisted in the configuration using JSON Pointer. Only simple values(string, number, boolean) can be whitelisted. Whitelisting array and hash elements can be done using wildcard symbol ~.

Available actions:

  • mask (default) - replaces every character from the original value with *. In case of array, hash or boolean value is replaced with one *.
  • prune - fully excludes the field and its value from the hash.

Configuration

preprocessors:
  whitelist:
    pointers: ['/info/phone', '/addresses/~/host']
  action: prune

Usage

logger = Lenjador.build(application_name, logger_config, preprocessors)

input = {password: 'password', info: {phone: '+12055555555'}, addresses: [{host: 'example.com', path: 'info'}]}

logger.debug("Received request", input)

Logger output:

Received request {password: "********", "info": {"phone": "+12055555555"}, "addresses": [{"host": "example.com","path": "****"}]}

Releasing a new version

A new version is created when a change is merged into the master branch that changes the version number in lenjador.gemspec. A Github Action will create a tag for the version and push the .gem file to rubygems.org