/logger

Pretty-print utility logger for JS/TS

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

NPM Discord GPL-3.0-only

Pretty-print utility logger for JS/TS

@evilkiwi/logger provides a small interface on top of the existing console API and includes things such as:

  • Automatic code highlighting via `template literal` syntax
  • High-precision timestamps
  • Namespacing and Instanced Loggers
  • Enable/disable logging at runtime

Installation

This package is available via NPM:

yarn add @evilkiwi/logger

# or

npm install @evilkiwi/logger

Usage

Since version 2.0.0, there are no global logger exports. Instead, you must always create a logger instance:

import { createLogger } from '@evilkiwi/logger';

const loggerA = createLogger({
  name: 'module-a',
  color: '#FF0000',
});
const loggerB = createLogger({
  name: 'module-b',
  color: '#00FF00',
});

loggerA.debug('hello world A!');
loggerA.error('hello world B!');