progress-logs
v0.0.2
Published
A simple tool to make your Node application running log formatting and clarity
Downloads
2
Readme
Translate
Why use progress-logs
When developing the node program, the program running log may sometimes be confused and scattered, which can not effectively distinguish.
progress-logs
can make your program log structured and clear. With dynamic loading effect, Emoji expression makes your
blog more personalized and meaningful.
How to use
It is easy to use progress-logs
, and you can add it into the existing code logic and get an effectively logs for your
code.
1. Create a progress log queue
const ProgressLog = require('progress-logs')
const progressLog = new ProgressLog({
title: 'Build and publish',
record: true,
loadingEffect: 18
})
At this time,you can configure the log main title: title
,either record the time or not: record
,running
effect: loadingEffect
default: 18, See here for more。
2. Add specific log items
progressLog.add('Linting', 'npm run lint')
progressLog.add('Bundled created', 'npm run build')
progressLog.add('Release', 'npm publish')
Through this list, you can also clearly know the whole process of running the program.
When adding items, you can customize the emoji icon and color of success, warning, and failure for each log item.
See here for available emoji icons and colors: emoji icons 、colors
// when incoming is string, default to specify the value of success status
progressLog.add('Linting', 'npm run lint', { color: 'green', emoji: 'heart' })
// when incoming is object, you can specify the respective values of success, failure and warning
progressLog.add('Linting', 'npm run lint', {
color: { success: 'green', warning: 'yellow', error: 'red' },
emoji: { success: 'heart', warning: 'heavy_multiplication_x', error: 'warning' }
})
3. Adding log actions into your code
progressLog.start() // start the log item
progressLog.next() // run next log item
progressLog.end(0) // end with exit code. 0:success 1: fail 2:warning
Customization
You can set the global success, warning and failure status emoji icons and colors with the follow method
progressLog.setGlobalLogEmoji({
success: 'heart',
fail: 'heavy_multiplication_x'
})
progressLog.setGlobalLogColor({
success: 'green'
})
Emoji platform support
Due to the inconsistent support of Emoji in various platforms and terminals, it may lead to inconsistent display.
As my main development platform is Windows
, so I had tried Webstorm
和 VSCode
under Windows
Platform. Founded
that the 'vscode' terminal has better support for Emoji, while the 'webstorm' terminal is relatively poor. So I filter
some available icon sets are provided here. You can choose them when you customize them.