console.log({_at, ...})
This commit is contained in:
56
coco-browser.js
Normal file
56
coco-browser.js
Normal file
@@ -0,0 +1,56 @@
|
||||
function routeNow () {
|
||||
const pageNow = globalThis.getCurrentPages()[globalThis.getCurrentPages().length - 1]
|
||||
return pageNow?.route || 'VueApp'
|
||||
}
|
||||
|
||||
function deepStringify (args = []) {
|
||||
return JSON.stringify(args, null, 2) // used in web browser console, to avoid clicking to expand by hand.
|
||||
}
|
||||
|
||||
module.exports =
|
||||
{
|
||||
cclog (...args) {
|
||||
console.log(
|
||||
`%c ${new Date().toJSON()} [LOG] ${routeNow()}`,
|
||||
'background: #808080; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
|
||||
deepStringify(args)
|
||||
)
|
||||
},
|
||||
ccinfo (...args) {
|
||||
console.info(
|
||||
`%c ${new Date().toJSON()} [INFO] ${routeNow()}`,
|
||||
'background: #0000ff; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
|
||||
deepStringify(args)
|
||||
)
|
||||
},
|
||||
ccgood (...args) {
|
||||
console.info(
|
||||
`%c ${new Date().toJSON()} [GOOD] ${routeNow()}`,
|
||||
'background: #2ecc71; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
|
||||
deepStringify(args)
|
||||
)
|
||||
},
|
||||
ccwarn (...args) {
|
||||
console.warn(
|
||||
`%c ${new Date().toJSON()} [WARN] ${routeNow()}`,
|
||||
'background: #f39c12; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
|
||||
deepStringify(args)
|
||||
)
|
||||
},
|
||||
ccerror (...args) {
|
||||
console.error(
|
||||
`%c ${new Date().toJSON()} [ERROR] ${routeNow()}`,
|
||||
'background: #c0392b; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
|
||||
deepStringify(args)
|
||||
)
|
||||
},
|
||||
ccdebug (...args) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
console.debug(
|
||||
`%c ${new Date().toJSON()} [DEBUG] ${routeNow()}`,
|
||||
'background: purple; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
|
||||
deepStringify(args)
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user