@ianwalter/log
v5.0.1
Published
A tiny level-based console logger
Downloads
328
Readme
@ianwalter/log
A tiny level-based console logger
Installation
yarn add @ianwalter/log
Usage
Basic
import log from '@ianwalter/log'
log.update({ level: 'warn' })
log.warn('Such logging!')
Using a custom logger (e.g. signale)
import log from '@ianwalter/log'
import signale from 'signale'
log.update({ types: Object.keys(signale._types), logger: signale })
log.complete('log can be used with signale')
Creating a separate, local logger
import log from '@ianwalter/log'
const localLog = log.create({ level: 'debug' })
localLog.debug('I am a debug statement')
Using namespaces
import log from '@ianwalter/log'
// Allows outputting log statements from loggers who have namespaces that match
// 'app.*'.
log.update({ unrestricted: 'app.*' })
// Create a logger that has an allowed namesapce.
const serverLog = log.ns('app.server')
// This log statement will be printed even though the log level is 'debug'.
serverLog.debug('I am a debug statement')
// So will this one.
log.ns('app.storage').debug('I, too, amd a debug statement')
License
Apache 2.0 with Commons Clause - See LICENSE
Created by Ian Walter