JSPM

  • Created
  • Published
  • Downloads 1029
  • Score
    100M100P100Q110958F
  • License Apache-2.0

Empathy simple logger

Package Exports

  • @empathyco/x-logger
  • @empathyco/x-logger/dist/cjs/index.js
  • @empathyco/x-logger/dist/esm/index.js

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

Readme

X Logger

This project is a simple logger

Installation

To install the logger:

# or pnpm or yarn
npm install @empathyco/x-logger --save-dev

Usage

import { logger, LogLevel } from '@empathyco/x-logger';

There are different log levels to be set in the console level and server level.

enum LogLevel {
  silent = 0,
  error = 1,
  warn = 2,
  info = 3,
  debug = 4,
  trace = 5
}

And different methods to be called to use the logger:

logger.error()
logger.warn()
logger.info()
logger.debug()
logger.trace()

Depending on the LogLevel, only some levels will be displayed in the console. Setting the LogLevel to warn, the console will display the levels below it and itself, in this case, error and warn.

logger.consoleLevel = LogLevel.warn;
logger.serverLevel = LogLevel.silent;

logger.error() // console.error called
logger.warn() // console.warn called
logger.info() // console.info not called
logger.debug() // console.debug  not called
logger.trace() // console.trace not called