Skip to content

waitingsong/log

Repository files navigation

Log

Lightweight simple ECMAScript logging for Browser and Node.js

Version License Build Status Build status Coverage Status

Features

  • Loggin things (message, data) at a given level with API trace(), debug(), log(), info(), warn(), error()
  • Filter logging by runLevel (all the below or 'silent'), so you can run site with default runLevel error, and run setRunLevel('trace') for debugging

Installing

npm install @waiting/log

Usage

log with desired API

import { error, trace, setRunLevel } from '@waiting/log'

error('log message')

setRunLevel('trace')
const data = {
  foo: new Date()
}
trace(data)
setRunLevel('error')  // turn trace off

log with single API

import * as log from '@waiting/log'

log.error('log message')

log.setRunLevel('trace')
const data = {
  foo: new Date()
}
log.log(data) // equal to console.log()
log.setRunLevel('error')  // turn debug off

On Node.js

  • Needs polylfill node-localstorage for persistent logging

    import { LocalStorage } from 'node-localstorage'
    
    // @ts-ignore
    global.localStorage = new LocalStorage(<path>)

Demos

License

MIT

Languages

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published