From e380f88c7778e715c7087c40e4854497382f3a86 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 13 Oct 2014 20:34:23 +0300 Subject: [PATCH] Cleans up logging a bit. --- app.js | 5 +---- libs/strophe/strophe.util.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index d4b47ae49..3e35da6f2 100644 --- a/app.js +++ b/app.js @@ -121,8 +121,8 @@ function connect(jid, password) { var anonymousConnectionFailed = false; connection.connect(jid, password, function (status, msg) { + console.log('Strophe status changed to', Strophe.getStatusString(status)); if (status === Strophe.Status.CONNECTED) { - console.log('connected'); if (config.useStunTurn) { connection.jingle.getStunAndTurnCredentials(); } @@ -135,7 +135,6 @@ function connect(jid, password) { if(msg === 'x-strophe-bad-non-anon-jid') { anonymousConnectionFailed = true; } - console.log('status', status); } else if (status === Strophe.Status.DISCONNECTED) { if(anonymousConnectionFailed) { // prompt user for username and password @@ -145,8 +144,6 @@ function connect(jid, password) { // wrong password or username, prompt user $(document).trigger('passwordrequired.main'); - } else { - console.log('status', status); } }); } diff --git a/libs/strophe/strophe.util.js b/libs/strophe/strophe.util.js index a079c645f..126ecf633 100644 --- a/libs/strophe/strophe.util.js +++ b/libs/strophe/strophe.util.js @@ -12,3 +12,30 @@ Strophe.log = function (level, msg) { break; } }; + +Strophe.getStatusString = function(status) +{ + switch (status) + { + case Strophe.Status.ERROR: + return "ERROR"; + case Strophe.Status.CONNECTING: + return "CONNECTING"; + case Strophe.Status.CONNFAIL: + return "CONNFAIL"; + case Strophe.Status.AUTHENTICATING: + return "AUTHENTICATING"; + case Strophe.Status.AUTHFAIL: + return "AUTHFAIL"; + case Strophe.Status.CONNECTED: + return "CONNECTED"; + case Strophe.Status.DISCONNECTED: + return "DISCONNECTED"; + case Strophe.Status.DISCONNECTING: + return "DISCONNECTING"; + case Strophe.Status.ATTACHED: + return "ATTACHED"; + default: + return "unknown"; + } +};