1.0.3 • Published 6 months ago
pretty-node-logs v1.0.3
About The Project
The motivation for this project is to offer a simple solution to printing well formatted and more informative console messages at ease, offering a better experience while developing nodejs
apps.
Installation
npm install --save-dev pretty-node-logs
yarn add --dev pretty-node-logs
Usage
Default Configuration
// ESM
import NodeLogger from 'pretty-node-logs';
// CJS
const NodeLogger = require('pretty-node-logs');
const logger = new NodeLogger();
defaultLogger.print('black', 'green', 'Custom colored print');
logger.log('This is a log');
logger.log('foo', 'bar');
logger.warn('This is a warning');
logger.warn('foo', 'bar');
logger.error('This is an error');
logger.error('foo', 'bar');
logger.info('For your information');
logger.info('foo', 'bar');
logger.success('This is a success');
logger.success('foo', 'bar');
logger.debug('This is a debugging message');
logger.debug('foo', 'bar');
logger.assert('This is an assertion');
logger.assert('foo', 'bar');
Custom Configuration
Property | Type | Default |
---|---|---|
useIcons | boolean | true |
useTimestamp | groupboolean singleboolean | groupfalse singlefalse |
groupTitles | logstring warningstring errorstring infostring successstring debugstring assertionstring | log"LOGS" warning"WARNINGS" error"ERRORS" info"INFORMATION" success"SUCCESS" debug"DEBUG" assertion"ASSERTIONS" |
const logger = new NodeLogger({
useIcons: false,
useTimestamp: { group: true, single: true },
groupTitles: {
log: 'custom log title',
},
});