This commit is contained in:
Luk 2024-02-05 10:07:49 +08:00
parent 7c0b1bce15
commit 25a01e9bb0

14
cc.js
View File

@ -13,9 +13,9 @@ function deepStringify (args = []) {
}
}
function routeNow () {
function fromPath () {
if (globalThis.process?.release?.name === 'node') {
return {} // { _from: routeNow.caller.name } // new Error().stack?.split('\n') , .match(/at (.*?) /g)[2]
return {} // { _from: fromPath.caller.name } // new Error().stack?.split('\n') , .match(/at (.*?) /g)[2]
} else if (globalThis.uni && globalThis.UniApp) {
return { _from: globalThis.getCurrentPages?.()?.pop?.()?.route?.substring?.(6) || 'VueApp' }
} else {
@ -39,7 +39,7 @@ module.exports =
console.log(deepStringify({
_at: new Date().toJSON(),
_type: 'CLOG', // arguments.callee.name doesn't work in nodejs strict mode
...routeNow(),
...fromPath(),
...expandArgs(args)
}))
globalThis.UniApp || console.log(',')
@ -48,7 +48,7 @@ module.exports =
console.info(deepStringify({
_at: new Date().toJSON(),
_type: 'CINFO',
...routeNow(),
...fromPath(),
...expandArgs(args)
}))
globalThis.UniApp || console.log(',')
@ -57,7 +57,7 @@ module.exports =
console.warn(deepStringify({
_at: new Date().toJSON(),
_type: 'CWARN',
...routeNow(),
...fromPath(),
...expandArgs(args)
}))
globalThis.UniApp || console.log(',')
@ -66,7 +66,7 @@ module.exports =
console.error(deepStringify({
_at: new Date().toJSON(),
_type: 'CERROR',
...routeNow(),
...fromPath(),
...expandArgs(args)
}))
globalThis.UniApp || console.log(',')
@ -76,7 +76,7 @@ module.exports =
console.debug(deepStringify({
_at: new Date().toJSON(),
_type: 'CDEBUG',
...routeNow(),
...fromPath(),
...expandArgs(args)
}))
globalThis.UniApp || console.log(',')