# vConsole

On the real machine, if you want to see console API The output log content and additional debugging information will be selected from the menu that opens by clicking on the button in the top right corner of the screenOpen debuggingAt this time the Mini Program/The small game will exit. When it is reopened, there will be a vConsole Button. to hit vConsole Button to open the log panel.

Small programs and small games vConsole Display content will be different, the picture on the left is the Mini Program VConsole. On the right is the small game vConsole

# vConsole Instructions

Due to the limitations of the implementation mechanism, the developer calls the console API The printed log content, is converted to JSON Character string to the vConsole Of, leading to vConsole There are some limitations to what is shown in

  • except NumberStringBooleannull Other types will be used as Object Processing display, print objects, and prototype chains Enumerable Property.
  • Infinity and NaN Will appear as null
  • undefinedArrayBufferFunction Type cannot be displayed
  • Unable to print objects with circular references
let a = {}
a.b = a
console.log(a) // 2.3.2 The following version, will print `An object width circular Reference can't be logged`

In response to the above, the Mini Program/Small game in use. vConsole I did something about it.

  • 2.3.2 And above, support to print circular reference objects. The object properties of the loop reference display the reference path,@Represents the object itself.
const circular = { x: {}, c: {} }
circular.x = [{ promise: Promise.resolve() }]
circular.a = circular
circular.c.x0  = circular.x[0]

console.log(circular)
// "{a: '<Circular: @>', c: {x0: '<Circular: @.x[0]>'}, x: [{promise:  '<Promise>'}]}"
  • 2.3.1 And above, support to display all types of data. The base library performs a conversion of the log content, and the converted content uses the<>Package. For example:

    • <Function: func>
    • <Undefined>
    • <Infinity>
    • <Map: size=0>
    • <ArrayBuffer: byteLength=10>
    • ...
  • 2.2.3 2.3.0 Version, you can show ArrayBuffer and Function Type,undefined Will be printed as a character string. 'undefined'

Note: Try to avoid printing overly complex or overlong log content (such as sprites or material objects in the game engine) in non-debug scenarios, which may cause additional time. To prevent exceptions, log content beyond a certain length is replaced with<LOG_EXCEED_MAX_LENGTH>, at which point the developer is required to crop the log content.