Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

logasm-jruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logasm-jruby

  • 1.2.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Logasm

Usage

Creating a new Logasm logger in Ruby

Logasm.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 'logasm'

logasm = Logasm.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 = Logasm.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 = Logasm.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": "****"}]}

FAQs

Package last updated on 11 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc