u
This commit is contained in:
		
							parent
							
								
									011853758f
								
							
						
					
					
						commit
						fbaf230f48
					
				
							
								
								
									
										18
									
								
								cc.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								cc.js
									
									
									
									
									
								
							@ -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 {
 | 
			
		||||
 | 
			
		||||
@ -7,6 +7,15 @@ function deepStringify (args = []) {
 | 
			
		||||
  return JSON.stringify(args, null, 2) // used in web browser console, to avoid clicking to expand by hand.
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// function prettyPrint (title, text, color) {
 | 
			
		||||
//   console.log(
 | 
			
		||||
//     `%c ${title} %c ${text} %c`,
 | 
			
		||||
//     `background:${color};border:1px solid ${color}; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;`,
 | 
			
		||||
//     `border:1px solid ${color}; padding: 1px; border-radius: 0 2px 2px 0; color: ${color};`,
 | 
			
		||||
//     'background:transparent'
 | 
			
		||||
//   )
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
module.exports =
 | 
			
		||||
{
 | 
			
		||||
  cclog (...args) {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								coco.js
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								coco.js
									
									
									
									
									
								
							@ -8,7 +8,7 @@
 | 
			
		||||
// typeof(globalThis.getApp)==='function' // 在 web/app 里都为 true
 | 
			
		||||
 | 
			
		||||
module.exports =
 | 
			
		||||
  process?.release?.name === 'node' ? require('./coco-nodejs.js')
 | 
			
		||||
  globalThis.process?.release?.name === 'node' ? require('./coco-nodejs.js')
 | 
			
		||||
    : globalThis.uniCloud ? require('./coco-unicloud.js')
 | 
			
		||||
      : globalThis.window && globalThis.location ? require('./coco-browser.js')
 | 
			
		||||
        : globalThis.uni && globalThis.getApp ? require('./coco-app.js')
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user