@waiting/log
v1.0.2
Published
Lightweight logging for browser
Downloads
1,078
Maintainers
Readme
Log
Lightweight simple ECMAScript logging for Browser and Node.js
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 runsetRunLevel('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>)