suhu-puh
v1.0.12
Published
Make console log more colorful
Downloads
8
Readme
chalkconsole
Make console log more colorful. While developing, we often deal with console logs. This module provides four templates namely regular log, error log, HTTP log and SQL log.
Install
npm install chalkconsole --save-dev
Usage
Below is an example regular and error log.
const { logConsole, errorConsole } = require('chalkconsole')
// regular log
logConsole('Hello world!')
// error log
errorConsole('A very cool error here')
Below is an example HTTP log.
const { httpLogConsole } = require('chalkconsole')
// log request for dev
app.use((req, res, next) => {
if (env == 'dev') httpLogConsole(req)
next()
})
Below is an example SQL log.
const { sqlLogConsole } = require('chalkconsole')
// when work with MySQL
let query = mysql.format(sql, param)
if (env == 'dev') {
sqlLogConsole(query)
}
// when work with Oracle
let query = queryBindToString(sql, param)
if (env == 'dev') {
sqlLogConsole(query)
}