GithubHelp home page GithubHelp logo

dmarell / slogger Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

Node js logger package. The name does not stand for what the word may suggest, instead it means a logger that is simple, structured and standard output

JavaScript 100.00%

slogger's Introduction

Node.js logging library

Output logs on standard output both in cloud and locally. The package has some features compared to logging using raw console.log:

  • Simplified syntax
  • Standard compact timestamp format
  • Supports logging plain strings or an object
  • Supports metadata for cloud logging (for example severity and labels) without ruining readability when running locally. Sets the parameter json in init to true when running in the cloud, for Stackdriver logging to pickup severity and metadata
  • A http request logger for node express

Logger usage

const {logger} = require('@dmarell/slogger')

// Initialize logging before using it
logger.init(`config.envName && config.envName !== 'dev')

// Optionally set labels
logger.addLabel('appName', config.appName)
logger.addLabel('envName', config.envName)
logger.addLabel('version', process.env.VERSION)

// Logging examples
logger.error('logger error')
logger.warn('logger warn')
logger.info('logger info, %d', 42)
logger.info('The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog')
logger.debug('The Answer is %s, really.', 42)
logger.debug({foo: 'Text', bar: 42})
logger.debug({message: 'Text', value: 42})

RequestLogger usage

Used for logging HTTP request with Node Express. Does not log request body.

const {RequestLogger} = require('@dmarell/slogger')
const app = require('express')()
app.use(new RequestLogger().getMiddleware())

slogger's People

Contributors

dmarell avatar

Watchers

 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.