Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@evilkiwi/logger

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evilkiwi/logger

Pretty-print utility logger for JS/TS

Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source
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

By default, @evilkiwi/logger exports traditional logging methods using a shared logger instance. For example:

import { debug, error } from '@evilkiwi/logger';

try {
  await something();
  debug('success!');
} catch (e) {
  error('failure!', e);
}

However, if you'd like to add namespaces and use multiple logger instances within your application, you can instead instantiate a new Logger:

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!');

You can also set a global namespace for all Logger instances created via your App. This can be useful if your console displays output from multiple systems, for example an Electron App or when using iFrames.

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

setNamespace({
  name: 'website',
  color: '#0000FF',
});

This will be pre-pended to all logging that passes through @evilkiwi/logger, regardless of whether it was instanced.

Keywords

typescript

FAQs

Package last updated on 23 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts