versatica / JsSIP

JsSIP, the JavaScript SIP library
https://jssip.net
Other
2.4k stars 739 forks source link

JsSIP Logger Override Functionality Not Working As Expected in v3.7.7 #830

Closed KevinRavasi closed 10 months ago

KevinRavasi commented 1 year ago

Description:

In the JsSIP library, since the upgrade to version 3.7.7, we have encountered a problem where the functionality to override the library's logger does not work as expected. This override feature worked fine in previous versions, however in v3.7.7 the same implementation seems to not function correctly.

Steps to reproduce:

Here are the steps to reproduce the issue:

  1. Enable JsSIP debug logs:

    JsSIP.debug.enable("JsSIP:*");
  2. Create a custom logger:

    const customJsSipLogger = (...args) => {
        console.log(args);
    }
  3. Attempt to replace the default logger with a custom logger:

    if (this.customLogger) {
        JsSIP.debug.log = this.customLogger;
    }
  4. Minimal example:

    var socket = new JsSIP.WebSocketInterface('wss://sip.myhost.com');
    var configuration = {
      sockets  : [ socket ],
      uri      : 'sip:alice@example.com',
      password : 'superpassword'
    };
    
    const customJsSipLogger = (...args) => {
        console.log(args);
    }
    
    JsSIP.debug.log = customJsSipLogger;
    
    var coolPhone = new JsSIP.UA(configuration);
    coolPhone.start();
    

Expected results:

In previous versions of JsSIP, setting JsSIP.debug.log to a custom logger effectively replaced the default logger with the custom logger provided. Therefore, we would expect all logging that JsSIP does to be passed through the custom logger.

Actual results:

Since the update to v3.7.7, the override attempt using JsSIP.debug.log = this.customLogger; no longer results in the logging being passed to the custom logger. The custom logger is simply not being called, and the library continues to use the default logger.

Environment:

This issue occurs on JsSIP version 3.7.7 and later. It was not present in prior versions of the library.

jmillan commented 10 months ago

There is no such functionality in JsSIP to override the logger, sorry.