@ianwalter/log

5.0.1 • Public • Published

@ianwalter/log

A tiny level-based console logger

npm page

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

/@ianwalter/log/

    Package Sidebar

    Install

    npm i @ianwalter/log

    Weekly Downloads

    83

    Version

    5.0.1

    License

    SEE LICENSE IN LICENSE

    Unpacked Size

    9.76 kB

    Total Files

    7

    Last publish

    Collaborators

    • ianwalter