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

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