Tencent / vConsole

A lightweight, extendable front-end developer tool for mobile web page.
Other
16.88k stars 2.95k forks source link

How to modify or restructure the display error messages in vconsole, not getting undefined log in v3.9.4 #605

Closed isaacking5 closed 1 year ago

isaacking5 commented 1 year ago

Description

My use case is to modify the error message which are logged in consoles, there i need to highlight the error line number

I have explored and tried n number of ways like, overriding the console etc.. :point_down:

console.error = function () {
    var originalMessage = Array.prototype.join.call(arguments, ' ');
    var modifiedMessage = 'Modified error message: ' + originalMessage;
    vConsole.printLog({
        logType: 'error',
        logMsg: modifiedMessage,
        style: ''
    });
};

vConsole Version: 3.15.0 the latest version

Note : Iam using an given CDN link ('https://cdn.jsdelivr.net/npm/vconsole@latest/dist/vconsole.min.js')

But I failed to achieved the expected output


vConsole Version: 3.9.4

Note : Iam using an given CDN link on version 3.9.4

Here iam not getting an undefined log in console

const a = {}

console.log(a.test)

In console iam getting `' '` string
Maizify commented 1 year ago

There is no vConsole.printLog() method in v3.15.0.

Replace it with console.log() will work:


  console.error = function () {
    var originalMessage = Array.prototype.join.call(arguments, ' ');
    var modifiedMessage = 'Modified error message: ' + originalMessage;
    console.log({
        logType: 'error',
        logMsg: modifiedMessage,
        style: ''
    });
  };