brave/sdebug

Name: sdebug

Owner: Brave Software

Description: a wrapper around debug() to add structured data logging

Created: 2016-02-18 17:15:27.0

Updated: 2017-02-17 21:45:26.0

Pushed: 2017-10-05 03:28:51.0

Homepage: null

Size: 10

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

sdebug

A wrapper around debug() to add structured data logging, viz., RFC5424.

First, take a look at the excellent debug module to understand the basic concepts.

Next, to add structure:

% DEBUG='*' node

    // create a new debugging instance with the 'server' prefix
    var debug = new (require('sdebug'))('server')

    // add default properties for every log entry
    debug.initialize({ 'server': { id: server.info.id } })

    // create a log entry with unstructured text
    debug('hello world.')

    // outputs:
    server [server@1104 id="zekariah.local:58165:iksjwi0d"] hello world

    // create a log entry with structured data
    var params = { request: { id: '...', method: '...', pathname: '...', statusCode='...' },
                   headers: ... }
    debug('end', params)

    // outputs (newlines added for readability):
    server [request@1104 id="1455817135688:zekariah.local:58165:iksjwi0d:10000" method="GET" pathname="/" statusCode="200"]
           [headers@1104 content_type="text/html; charset=utf-8" cache_control="no-cache" vary="accept-encoding" content_encoding="gzip"]
           end

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.