0.1.3 • Published 5 years ago

pretty-shell-logs v0.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Pretty shell logs

NPM

Package to have a really consultable console

TAGS and PRETTY OBJ

The core implementation for this library is the tagging (paired with a color) to identify a log competence area and an easy object rapresentation thanks to log.pretty() method

Configuration

ParameterDescriptionDefault value
titleMinimumWidththe minimum space for the title section14
levellog level debug, info, warn, errorOrSuccess, nothingdebug
grep.titlefilter for a title''
grep.contentfilter for a content''
exclude.titlehide title occurrences''
exclude.contenthide content occurrence''
showDateset the date visibilitytrue
titleColorReverseinvert the title and background colorstrue
showLevelLabelset the log level label visibilitytrue

Implementation example

const logger = require('./index')

logger.init({
  	titleMinimumWidth: 10,
	level: 'debug',
	showDate: false,
  	titleColorReverse: true,
  	showLevelLabel: false,
	grep: {
		title: 'server',
		content: '',
	},
	exclude: {
		title: '',
		content: '',
	},
})

const obj = {
	foo: 'bar',
}

const tagOneLog = logger.create('Tag nr 1', 'blue')
tagOneLog.d('Debug log')
tagOneLog.i('Info log')
tagOneLog.w('Warning log')
tagOneLog.error('Warning log')

const tagTwoLog = logger.create('Tag nr 2', 'magenta')
tagTwoLog.e('Error log')
tagTwoLog.s('Success log')
tagTwoLog.w('Warning log with a \'pretty\' object',obj, tagTwoLog.pretty(obj, 'Object description'))

Usage results

titleColorReverse as true: