1.0.5 • Published 3 years ago
@thesuhu/colorconsole v1.0.5
colorconsole
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 @thesuhu/colorconsole --save-dev
Usage
Below is an example regular and error log.
const { logConsole, errorConsole } = require('@thesuhu/colorconsole')
// regular log
logConsole('Hello world!')
// error log
errorConsole('A very cool error here')
Below is an example HTTP log.
const { httpLogConsole } = require('@thesuhu/colorconsole')
// log request for dev
app.use((req, res, next) => {
if (env == 'dev') httpLogConsole(req)
next()
})
Below is an example SQL log.
const { sqlLogConsole } = require('@thesuhu/colorconsole')
// 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)
}