@robpc/logger
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@robpc/logger

Simple logging library for use in node and the browser. Intended to be a extremely light-weight version, has only one file and no dependencies.

Installation

npm install --save @robpc/logger

Usage

index.js

const LoggerFactory = require('@robpc/logger');

// Set to push output to stderr (useful for node scripts)
// NOTE: Must be called before setLogLevel to prevent all printing to stdout
LoggerFactory.setStderrOutput(true);

// Set once at the top of your application and applies everywhere
LoggerFactory.setLogLevel('DEBUG'); // or LoggerFactory.LEVELS.INFO or 2
const logger = LoggerFactory.get('main');

const data = { rob: 1 };

logger.debug('Good Morning, Rob!', 'data:', data);

other.js

const LoggerFactory = require('@robpc/logger');

const logger = LoggerFactory.get('other');

logger.info('Good Evening, Rob!');

console output

[main] DEBUG: Good Morning, Rob! data: { rob: 1 }
[other] INFO: Good Evening, Rob!

Readme

Keywords

Package Sidebar

Install

npm i @robpc/logger

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

22.6 kB

Total Files

15

Last publish

Collaborators

  • robpc