JSPM

@dnpr/logger

0.2.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1090
    • Score
      100M100P100Q104224F
    • License MIT

    A console.log() wrapper that logs more information.

    Package Exports

    • @dnpr/logger

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dnpr/logger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Logger

    A console.log() wrapper that logs more information.

    Installation

    npm install @dnpr/logger

    Usage

    Create an instance.

    const { Logger } = require('@dnpr/logger')
    
    const log = new Logger('HelloApp', {
      logLevel: 'verbose',
      useColor: true 
    })

    Log messages with different levels.

    log.verbose('Something verbose', 'Second verbose message')
    log.debug('Something for debugging')
    log.info('Some useful info')
    log.warn('Some warnings')
    log.error('Something goes wrong')

    Result :

    Ideas

    • Log to other target than stdout. For example, stderr, file, remote address or URL.

    • Log JSON formatted objects instead of strings.

    • Let the user setup callback for each log level, so they can do some custom handling stuff.

    • Customize log header format with a format string.

    Fun Facts