JSPM

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

A lib that helps you log things with various prefix easily.

Package Exports

  • 3h-log

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 (3h-log) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

3h-log

A lib that helps you log things with various prefix easily.

Install

$ npm install 3h-log

Example

const Logger = require('3h-log');

Logger.default.info('A piece of information logged by the default logger.');

const logger = new Logger();

logger.warn('A warning with default prefix.');

logger.prefix.warn = 'MyWarn';
logger.warn('A warning with my prefix.');

logger.showTime = false;
logger.error('An error without time.');

logger.preLen += 2;
logger.info('A piece of information with 2 more spaces.');

API

  • Logger(out?: stream.Writable) - The constructor of loggers.
    • default - An instance of Logger.
  • logger - ( Any instance of Logger. )
    • preLen: number - Target length of prefixes.
    • showTime: boolean - Whether to show the current time.
    • prefix - The prefixes.
      • info: string - The prefix for logger.info.
      • error: string - The prefix for logger.error.
      • warn: string - The prefix for logger.warn.
      • trace: string - The prefix for logger.trace.
    • write(prefix: string, msg: string) - To write something.
    • info(msg: string) - To log some information.
    • error(msg: string) - To log some errors.
    • warn(msg: string) - To log some warnings.
    • trace(msg: string) - To log some traces.