Prints colorful status messages to the console
- As a developer, I don't want to format log messages again and again using tags, ASCII color and
console
API
- ✅ Does offer colorful logging function
- ✅ Severities are:
error(...)
,warn(...)
,log(...)
,info(...)
,debug(...)
,trace(...)
- ✅ Duration time measurements:
time(label: string)
,timeEnd(label: string)
- ✅ Uses the correct
console
API functions automatically (per severity) - ✅ Beautiful loading spinner animation
- ✅ Ability to rewind and clear the previous line (custom animations)
- ✅ Available as a simple API
- ✅ Just
535 byte
nano sized (ESM, gizpped) - ✅ Tree-shakable and side-effect free
- ✅ First class TypeScript support
- ✅ 100% Unit Test coverage
- yarn:
yarn add @jsheaven/status-message
- npm:
npm install @jsheaven/status-message
import { log, error, warn, info, debug, trace, time, timeEnd, spinner } from '@jsheaven/status-message'
time('Log every feature')
error('FATAL', 'You did not use this library yet')
warn('DANGER', 'Other logging libraries do not support arbitrary args', { right: true }, process.version)
log('SUCCESS', 'But this lib is only 361 bytes and has it all')
info('NOTE', 'It even has 100% test coverage')
debug('DEBUG', 'It is even tree-shakable')
trace('DURATION', 'You can trace the runtime of a task easily too:')
timeEnd('Log every feature')
const stopAnimation = spinner('Loading...')
await(async () => new Promise((resolve) => setTimeout(resolve, 2000)))()
stopAnimation()
let i = 1
const countTo100 = setInterval(() => {
if (i > 1) clearPrevLine()
info('COUNT', i)
i++
if (i > 100) clearInterval(countTo100)
}, 25)
for (let i = 0; i < 20; i++) clearPrevLine()
const { log, logTime, logTimeEnd } = require('@jsheaven/status-message')
// same API like ESM variant