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 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright @ 2015 Atlassian Pty Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * Strophe logger implementation. Logs from level WARN and above.
  18. */
  19. module.exports = function () {
  20. Strophe.log = function (level, msg) {
  21. switch (level) {
  22. case Strophe.LogLevel.WARN:
  23. console.warn("Strophe: " + msg);
  24. break;
  25. case Strophe.LogLevel.ERROR:
  26. case Strophe.LogLevel.FATAL:
  27. console.error("Strophe: " + 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. };