This commit is contained in:
Luk
2024-06-24 09:49:28 +08:00
parent 011853758f
commit fbaf230f48
3 changed files with 26 additions and 3 deletions

18
cc.js
View File

@@ -2,10 +2,24 @@ const util = require('util')
function deepStringify (args = []) {
if (globalThis.process?.release?.name === 'node') {
return globalThis.wo?.envar?.logDeep ? util.inspect(args, { showHidden: false, depth: null, colors: typeof globalThis.wo?.envar?.logColor === 'undefined' ? true : globalThis.wo?.envar?.logColor }) : args // JSON.stringify(args, null, 2) // in nodejs console, object only shows children of depth <= 3 by default. 如果要完整数据,就要进行扩展。
// in nodejs console, object only shows children of depth <= 3 by default. 如果要完整数据,就要进行扩展。
return globalThis.wo?.envar?.logDeep
? util.inspect(args, {
showHidden: false,
depth: null,
colors: typeof globalThis.wo?.envar?.logColor === 'undefined' ? true : globalThis.wo?.envar?.logColor
})
: args // JSON.stringify(args, null, 2)
} else if (globalThis.uni && globalThis.UniApp) {
// 可再分为 web 和 app通过 #ifdef 或 globalThis.window/location 判断
return globalThis.wo?.envar?.logDeep ? util.inspect(args, { showHidden: false, depth: null, colors: typeof globalThis.wo?.envar?.logColor === 'undefined' ? true : globalThis.wo?.envar?.logColor }) : args // in browser console, object is expandable by default.
// in browser console, object is expandable by default.
return globalThis.wo?.envar?.logDeep
? util.inspect(args, {
showHidden: false,
depth: null,
colors: typeof globalThis.wo?.envar?.logColor === 'undefined' ? true : globalThis.wo?.envar?.logColor
})
: args
} else if (globalThis.uniCloud) {
return args
} else {