You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

strophe.util.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* global Strophe */
  2. /**
  3. * Strophe logger implementation. Logs from level WARN and above.
  4. */
  5. import {getLogger} from "jitsi-meet-logger";
  6. const logger = getLogger(__filename);
  7. import GlobalOnErrorHandler from "../util/GlobalOnErrorHandler";
  8. export default function () {
  9. Strophe.log = function (level, msg) {
  10. // Our global handler reports uncaught errors to the stats which may
  11. // interpret those as partial call failure.
  12. // Strophe log entry about secondary request timeout does not mean that
  13. // it's a final failure(the request will be restarted), so we lower it's
  14. // level here to a warning.
  15. if (typeof msg === 'string' &&
  16. msg.indexOf("Request ") !== -1 &&
  17. msg.indexOf("timed out (secondary), restarting") !== -1) {
  18. level = Strophe.LogLevel.WARN;
  19. }
  20. switch (level) {
  21. case Strophe.LogLevel.WARN:
  22. logger.warn("Strophe: " + msg);
  23. break;
  24. case Strophe.LogLevel.ERROR:
  25. case Strophe.LogLevel.FATAL:
  26. msg = "Strophe: " + msg;
  27. GlobalOnErrorHandler.callErrorHandler(new Error(msg));
  28. logger.error(msg);
  29. break;
  30. }
  31. };
  32. Strophe.getStatusString = function (status) {
  33. switch (status) {
  34. case Strophe.Status.ERROR:
  35. return "ERROR";
  36. case Strophe.Status.CONNECTING:
  37. return "CONNECTING";
  38. case Strophe.Status.CONNFAIL:
  39. return "CONNFAIL";
  40. case Strophe.Status.AUTHENTICATING:
  41. return "AUTHENTICATING";
  42. case Strophe.Status.AUTHFAIL:
  43. return "AUTHFAIL";
  44. case Strophe.Status.CONNECTED:
  45. return "CONNECTED";
  46. case Strophe.Status.DISCONNECTED:
  47. return "DISCONNECTED";
  48. case Strophe.Status.DISCONNECTING:
  49. return "DISCONNECTING";
  50. case Strophe.Status.ATTACHED:
  51. return "ATTACHED";
  52. default:
  53. return "unknown";
  54. }
  55. };
  56. }