JSPM

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

Plain simple logger with banner and colors

Package Exports

  • @prostojs/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 (@prostojs/logger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Plain simple logger with banner and colors based on @prostojs/dye

Install

npm: npm install @prostojs/logger

Via CDN:

<script src="https://unpkg.com/@prostojs/dye"></script>
<script src="https://unpkg.com/@prostojs/logger"></script>

Usage

const { dye } = require('@prostojs/dye')
const { ProstoLogger, EProstoLogLevel }  = require('@prostojs/logger')

const logger = new ProstoLogger({
    banner: dye('green')('[Logger]'),
    logLevel: EProstoLogLevel.DEBUG,
})

logger.debug('logger.debug')
logger.info('logger.info')
logger.log('logger.log')
logger.warn('logger.warn')
logger.error('logger.error')

Options

const logger = new ProstoLogger({

    // banner that will be shown next to each message
    // *optional
    banner: dye('green')('[Logger]'),

    // maximum log level that will show message
    // *default EProstoLogLevel.LOG
    logLevel: EProstoLogLevel.DEBUG,

    // console interface (usually `console` itself)
    // *default console
    console: console,

    // styles for each message type
    // *optional
    styles: {
        debug:  dye('yellow-bright', 'dim'),
        info:   dye('green', 'dim'),
        log:    dye(),
        warn:   dye('yellow'),
        error:  dye('red', 'red-bright'),
    },

    // banners for each message type
    // *optional
    typeBanners: {
        debug:  '[ DEBUG ]',
        info:   '[ INFO  ]',
        log:    '[  LOG  ]',
        warn:   dye('bg-yellow', 'red')('[WARNING]'),
        error:  dye('bg-red', 'white')('[ ERROR ]'),
    },
})