wo-base-netinfo/tool4log.js
2022-03-25 20:05:02 +08:00

22 lines
931 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const colors = require('colors')
// HBuilder 内置环境的 console 不支持颜色。为了检查是否支持颜色,可测试 uniCloud 是否存在不存在说明在自己的server环境里或 require('supports-color'),相应的返回不同的 ccXXX 函数。
module.exports = {
cclog(...args) {
console.log(colors.blue({timeiso: new Date().toJSON()}), ...args)
},
ccinfo(...args) {
console.info(colors.green({timeiso: new Date().toJSON()}), ...args)
},
ccerr(...args) { // console.error will appear in pm2's error log
console.error(colors.red({timeiso: new Date().toJSON()}), ...args)
},
ccwarn(...args) { // console.warn will appear in pm2's error log
console.warn(colors.yellow({timeiso: new Date().toJSON()}), ...args)
},
ccdebug(...args) {
'development'===process.env.NODE_ENV && console.log(colors.rainbow(JSON.stringify({timeiso: new Date().toJSON()})), ...args)
}
}