category-logger
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Category Logger

Log with color-coded categories.

Example

example.png

Create log categories using Enum and set colors to each category using Map.

import CategoryLogger from 'category-logger';

export enum Categories {
    API,
    DATA,
    ERROR,
}

const categoryColors = new Map([
    [Categories.API, '#1976D2'], // blue
    [Categories.DATA, '#388E3C'], // green
    [Categories.ERROR, '#D32F2F'], // red
]);

const logger = new CategoryLogger(Categories, categoryColors, true);
export default logger;
import logger, { Categories } from './logger';

logger.log(Categories.API, 'GET /user');
logger.log(Categories.API, 'GET /article');
logger.log(Categories.DATA, 'Collected data from archive');
logger.log(Categories.API, 'POST /article');
logger.log(Categories.DATA, 'Saved data to database');
logger.log(Categories.ERROR, 'Exception while parsing data');

Readme

Keywords

Package Sidebar

Install

npm i category-logger

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

4.74 kB

Total Files

8

Last publish

Collaborators

  • rulyox