Commits

Ivan Vučica committed 31a6139

Replaced direct console calls with zxmppConsole wrapper calls.

  • Participants
  • Parent commits 52dade6

Comments (0)

Files changed (11)

zxmpp_authdigestmd5.js

 			}
 			else
 			{
-				console.error("zxmpp::authDigestMD5::doStep(): plain authentication mechanism unsupported. giving up");
+				zxmppConsole.error("zxmpp::authDigestMD5::doStep(): plain authentication mechanism unsupported. giving up");
 
 				this.zxmpp.stream.terminate();
 	
 	{
 		if(!xml || !xml.firstChild)
 		{
-			console.error("zxmpp::authDigestMD5::handleChallenge: no challenge content");
+			zxmppConsole.error("zxmpp::authDigestMD5::handleChallenge: no challenge content");
 			this.zxmpp.stream.terminate();
 			this.zxmpp.notifyConnectionTerminate("terminate/invalid-sasl-challenge", "Server has sent an invalid SASL challenge.");
 			return;
 		var content = xml.firstChild;
 		if(!content.nodeValue)
 		{
-			console.error("zxmpp::authDigestMD5::handleChallenge: no challenge content nodevalue");
+			zxmppConsole.error("zxmpp::authDigestMD5::handleChallenge: no challenge content nodevalue");
 			this.zxmpp.stream.terminate();
 			this.zxmpp.notifyConnectionTerminate("terminate/invalid-sasl-challenge", "Server has sent an invalid SASL challenge.");
 			return;
 		if(!content)
 		{
 			// TODO copypaste code from above for throwing error
-			console.error("zxmpp::authDigestMD5::handleChallenge: could not base64decode challenge content");
+			zxmppConsole.error("zxmpp::authDigestMD5::handleChallenge: could not base64decode challenge content");
 			this.zxmpp.stream.terminate();
 			this.zxmpp.notifyConnectionTerminate("terminate/invalid-sasl-challenge", "Server has sent an invalid SASL challenge.");
 			return;
 			var entry = content[entryKey].split('=');
 			if(entry.length != 2)
 			{
-				console.error("zxmpp::authDigestMD5::handleChallenge: cannot split challenge content entry; count " + entry.length + " in " + entryStr);
+				zxmppConsole.error("zxmpp::authDigestMD5::handleChallenge: cannot split challenge content entry; count " + entry.length + " in " + entryStr);
 				this.zxmpp.stream.terminate();
 				this.zxmpp.notifyConnectionTerminate("terminate/invalid-sasl-challenge", "Server has sent an invalid SASL challenge.");
 				return;
 
 			if(!contentDict[key])
 				contentDict[key] = new Array();
-			console.log("Setting " + key + " to " + value);
+			zxmppConsole.log("Setting " + key + " to " + value);
 			contentDict[key].push(value);
 		}
 		return contentDict;
 			// note: there may be more than one realm, but we don't have a
 			// nice way to provide a GUI for picking a new realm.
 		{
-			console.error("zxmpp::authDigestMD5::handleChallenge: no realm or multiple realms");
+			zxmppConsole.error("zxmpp::authDigestMD5::handleChallenge: no realm or multiple realms");
 			for(var i in contentDict["realm"])
 			{
-				console.log(contentDict["realm"][i]);
+				zxmppConsole.log(contentDict["realm"][i]);
 			}
 			this.zxmpp.stream.terminate();
 			this.zxmpp.notifyConnectionTerminate("terminate/invalid-sasl-challenge", "Server has sent an invalid SASL challenge.");
 		if(!contentDict["nonce"] || contentDict["nonce"].length > 1)
 			// none must, by definition, appear once and once only
 		{
-			console.error("zxmpp::authDigestMD5::handleChallenge: no nonce or multiple nonces");
+			zxmppConsole.error("zxmpp::authDigestMD5::handleChallenge: no nonce or multiple nonces");
 			this.zxmpp.stream.terminate();
 			this.zxmpp.notifyConnectionTerminate("terminate/invalid-sasl-challenge", "Server has sent an invalid SASL challenge.");
 			return;
 		var response = '';
 		{
 			var x = username + ':' + realm + ':' + password;
-			console.log(x);
+			zxmppConsole.log(x);
 			var y = this.zxmpp.util.md5(x, true);
-			console.log(y);
+			zxmppConsole.log(y);
 			var a1 = y + ":" + nonce + ":" + cnonce; // + ":" + authzid; // removed for RFC 3920 (6.1 pt 7)
-			console.log(a1 + " . " + a1.length + " . " + nonce.length + " . " + cnonce.length + " . " + y.length);
+			zxmppConsole.log(a1 + " . " + a1.length + " . " + nonce.length + " . " + cnonce.length + " . " + y.length);
 			var a2 = "AUTHENTICATE:" + digesturi;
-			console.log(a2);
+			zxmppConsole.log(a2);
 			var ha1 = this.zxmpp.util.md5(a1);
-			console.log(ha1);
+			zxmppConsole.log(ha1);
 			var ha2 = this.zxmpp.util.md5(a2);
-			console.log(ha2);
+			zxmppConsole.log(ha2);
 			var kd = ha1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + ha2;
-			console.log(kd);
+			zxmppConsole.log(kd);
 			var z = this.zxmpp.util.md5(kd);
-			console.log(z);
+			zxmppConsole.log(z);
 
 			response = z;
 		}

zxmpp_authplain.js

 			}
 			else
 			{
-				console.error("zxmpp::authPlain::doStep(): plain authentication mechanism unsupported. giving up");
+				zxmppConsole.error("zxmpp::authPlain::doStep(): plain authentication mechanism unsupported. giving up");
 
 				this.zxmpp.stream.terminate();
 	
 	{
 		// PLAIN should never have to handle a challenge.
 		// For now, we just won't respond to the challenge.
-		console.log("zxmpp::authPlain::handleChallenge: ignoring challenge!");
+		zxmppConsole.log("zxmpp::authPlain::handleChallenge: ignoring challenge!");
 	}
 	this.handleSuccess = function zxmppAuthPlain_handleSuccess(xml)
 	{

zxmpp_itemroster.js

 subscription "remove" is sent and received when we're supposed to REMOVE a contact from our roster
 */
 
-		console.log("Roster: " + this.bareJid);
-		console.log(" " + this.zxmpp.util.serializedXML(xml));
+		zxmppConsole.log("Roster: " + this.bareJid);
+		zxmppConsole.log(" " + this.zxmpp.util.serializedXML(xml));
 		
 		for(var i in xml.childNodes)
 		{
 				else
 				{
 					this.groups.push(child.firstChild.nodeValue);
-					console.log(" group: " + child.firstChild.nodeValue);
+					zxmppConsole.log(" group: " + child.firstChild.nodeValue);
 				}
 				break;
 
 				default:
-				console.warn("zxmpp::itemRoster::parseXML(): unknown child " + child.nodeName);
+				zxmppConsole.warn("zxmpp::itemRoster::parseXML(): unknown child " + child.nodeName);
 				break;
 			}
 		}
 	}
 	this.toJSON = function zxmppItemRoster_toJSON(key)
 	{
-		console.log("zxmppItemRoster_toJSON()");
+		zxmppConsole.log("zxmppItemRoster_toJSON()");
 		var oldzxmpp = this.zxmpp;
 		var oldtojson = this.toJSON; // firefox4 beta7; when we return cloned, cleaned copy of this object, it attempts to stringify once again using this same function, causing this.zxmpp to be undefined. we need to remove the function too
 		delete this.zxmpp;
 	var resource = jid[1];
 	
 	if(!resource)
-		console.error("DANGER: A bare jid passed to zxmppMain_getPresence()");
+		zxmppConsole.error("DANGER: A bare jid passed to zxmppMain_getPresence()");
 
 	if(!this.presences[bareJid])
 		this.presences[bareJid] = {};
 
 zxmppClass.prototype._debugDumpPresences = function zxmppMain__debugDumpPresences()
 {
-	console.log(" ");
-	console.log("======= PRESENCES ======== ");
+	zxmppConsole.log(" ");
+	zxmppConsole.log("======= PRESENCES ======== ");
 	for(var bareJid in this.presences)
 	{
-		console.log(bareJid);
+		zxmppConsole.log(bareJid);
 		var resources = this.presences[bareJid];
 		for(var resource in resources)
 		{
 			
 			
 			
-			console.log(" " + resource + " - " + info);
+			zxmppConsole.log(" " + resource + " - " + info);
 		}
 	} 
-	console.log(" ");
+	zxmppConsole.log(" ");
 }
 
 zxmppClass.prototype._debugDumpStreamFeatures = function zxmppMain__debugDumpStreamFeatures()
 {
-	console.log(" ");
-	console.log("======= STREAM:FEATURES ======== ");
+	zxmppConsole.log(" ");
+	zxmppConsole.log("======= STREAM:FEATURES ======== ");
 	for(var xmlns in this.stream.features)
 	{
-		console.log(xmlns);
+		zxmppConsole.log(xmlns);
 		var nodes = this.stream.features[xmlns];
 		for(var node in nodes)
 		{
-			console.log(" " + node);
+			zxmppConsole.log(" " + node);
 		}
 	} 
-	console.log(" ");
+	zxmppConsole.log(" ");
 }
 
 zxmppClass.prototype.notifyConnectionTerminate = function zxmppMain_notifyConnectionTerminate(code,humanreadable)
 	if(this.stream && this.stream.hasSentInitialPresence)
 		this.stream.sendCurrentPresence();
 	else
-		console.log("Not sending presence since there is either no stream or initial presence wasn't already sent");
+		zxmppConsole.log("Not sending presence since there is either no stream or initial presence wasn't already sent");
 }
 
 zxmppClass.prototype.serialized = function zxmppMain_serialized()
         // "reviver" function
         
         var type;
-	//console.log("restoring " + key + " (a " + (typeof value) + ", classtype " + (value.type) + "): " + value);
+	//zxmppConsole.log("restoring " + key + " (a " + (typeof value) + ", classtype " + (value.type) + "): " + value);
         if(value && typeof value === "object")
         {
             type = value.type;
 		// assign cryptographic key(s) from 
 		// part 15 of XEP-0124
 		var keys = this.zxmpp.stream.assignKey();
-		console.warn("CURRENTLY DISABLED cryptographic key from part 15 of XEP-0124");
-		console.warn("This seems to solve misbehavior with punjab, but is incorrect!");
+		zxmppConsole.warn("CURRENTLY DISABLED cryptographic key from part 15 of XEP-0124");
+		zxmppConsole.warn("This seems to solve misbehavior with punjab, but is incorrect!");
 		/*
 		if(keys.key)
 			body.setAttribute('key', keys.key);
 		if(keys.newKey)
 			body.setAttribute('newkey', keys.newKey);
 		*/
-		console.log("(finalized: " + this.zxmpp.util.serializedXML(this.xml) + ")");	
+		zxmppConsole.log("(finalized: " + this.zxmpp.util.serializedXML(this.xml) + ")");	
 		return this.zxmpp.util.serializedXML(this.xml);
 		
 	}
 			if(colonsplit[0]=="xmlns" && colonsplit[1])
 			{
 				this.namespaces[colonsplit[1]] = attrs[attr];
-				//console.log("namespace '" + colonsplit[1] + "': " + attrs[attr]);
+				//zxmppConsole.log("namespace '" + colonsplit[1] + "': " + attrs[attr]);
 			}
 		}
 		
 			
 			if(!nsurl)
 			{
-				console.warn("zxmpp::packet::parseXML(): Stanza " + child.nodeName + " in unknown namespace. Stanza dropped");
+				zxmppConsole.warn("zxmpp::packet::parseXML(): Stanza " + child.nodeName + " in unknown namespace. Stanza dropped");
 				continue;
 			}
 			
 			// now we have enough data about stanza to start parsing it
 			// let's iterate through supported stanzas!
-			console.log("zxmpp::packet::parseXML(): Stanza " + stanza + " in namespace " + nsurl);
+			zxmppConsole.log("zxmpp::packet::parseXML(): Stanza " + stanza + " in namespace " + nsurl);
 			var stanzaInstance = false;
 			switch(nsurl)
 			{
 			
 			if(!stanzaInstance)
 			{
-				console.warn("zxmpp::packet::parseXML(): Stanza \'" + stanza + "\' in namespace \'" + nsurl + "\' is unknown. Stanza dropped");
+				zxmppConsole.warn("zxmpp::packet::parseXML(): Stanza \'" + stanza + "\' in namespace \'" + nsurl + "\' is unknown. Stanza dropped");
 			}
 			else
 			{
 	}
 	this.toJSON = function zxmppPacket_toJSON(key)
 	{
-		console.log("zxmppPacket_toJSON()");
+		zxmppConsole.log("zxmppPacket_toJSON()");
 		var oldzxmpp = this.zxmpp;
 		var oldtojson = this.toJSON; // firefox4 beta7; when we return cloned, cleaned copy of this object, it attempts to stringify once again using this same function, causing this.zxmpp to be undefined. we need to remove the function too
 		var oldiqstanza = this.iqStanza;

zxmpp_presence.js

 
 	this.toJSON = function zxmppPresence_toJSON(key)
 	{
-		console.log("zxmppPresence_toJSON()");
+		zxmppConsole.log("zxmppPresence_toJSON()");
 		var oldzxmpp = this.zxmpp;
 		var oldtojson = this.toJSON; // firefox4 beta7; when we return cloned, cleaned copy of this object, it attempts to stringify once again using this same function, causing this.zxmpp to be undefined. we need to remove the function too
 		delete this.zxmpp;

zxmpp_stanzaiq.js

 			{
 				// a bare jid
 				presence = this.zxmpp.getTopPresenceForBareJid(this.from);
-				console.warn("Iq from barejid");
-				console.log(xml);
+				zxmppConsole.warn("Iq from barejid");
+				zxmppConsole.log(xml);
 			}
 		}
 		
 				break;
 				
 				case "error":
-				console.error("zxmpp::stanzaIq::parseXML(): error node received: " + this.zxmpp.util.serializedXML(child));
+				zxmppConsole.error("zxmpp::stanzaIq::parseXML(): error node received: " + this.zxmpp.util.serializedXML(child));
 				if(this.zxmpp.stream.iqsAwaitingReply[this.id])
 				{
 					var orig = this.zxmpp.stream.iqsAwaitingReply[this.id];
-					console.error("zxmpp::stanzaIq::parseXML(): original stanza: " + this.zxmpp.util.serializedXML(orig.iqXML));					
+					zxmppConsole.error("zxmpp::stanzaIq::parseXML(): original stanza: " + this.zxmpp.util.serializedXML(orig.iqXML));					
 				}
 				else
 				{
-					console.error("zxmpp::stanzaIq::parseXML(): original stanza with id " + this.id + " not found");
+					zxmppConsole.error("zxmpp::stanzaIq::parseXML(): original stanza with id " + this.id + " not found");
 				}
 				
 				break;
 
 				case "vCard":
 				// TODO implement
-				//console.error("***** VCARD PARSING NOT IMPLEMENTED");
+				//zxmppConsole.error("***** VCARD PARSING NOT IMPLEMENTED");
 				//this.iqFail();
 				
 							// TODO handle error vCard responses
 				vcard.parseXML(child);
 				if(!this.from)
 					presence = this.zxmpp.getOwnPresence();
-				console.warn("Now receiving vcard for " + presence.bareJid);
-				console.warn(vcard);
+				zxmppConsole.warn("Now receiving vcard for " + presence.bareJid);
+				zxmppConsole.warn(vcard);
 				this.zxmpp.vCards[presence.bareJid] = vcard;
 				var rosteritem = this.zxmpp.roster[presence.bareJid];
 				if(rosteritem)
 					}
 					catch(e)
 					{
-						console.error(e);
-						console.error(e.message);
-						console.error(e.stack);
+						zxmppConsole.error(e);
+						zxmppConsole.error(e.message);
+						zxmppConsole.error(e.stack);
 					}
 					return parsedOk;
 				}
 				
 				if(!parsedOk)
 				{
-					console.warn("zxmpp::stanzaIq::parseXML(): Unhandled child " + child.nodeName + " (" + child.nodeName + " in " + child.prefix + " / " + child.namespaceURI + ")");
+					zxmppConsole.warn("zxmpp::stanzaIq::parseXML(): Unhandled child " + child.nodeName + " (" + child.nodeName + " in " + child.prefix + " / " + child.namespaceURI + ")");
 					this.iqFail();
 				}
 			}
 			break;
 			
 			default:
-			console.warn("zxmpp::stanzaIq::parseBindXML(): cannot handle iq's of type " + this.type);
+			zxmppConsole.warn("zxmpp::stanzaIq::parseBindXML(): cannot handle iq's of type " + this.type);
 			this.iqFail();
 		}
 	}
 				break;
 				
 				default:
-				console.warn("zxmpp::stanzaIq::parseQueryXML(): Unknown namespace " + xml.attr["xmlns"] + " (iqtype=result)");
+				zxmppConsole.warn("zxmpp::stanzaIq::parseQueryXML(): Unknown namespace " + xml.attr["xmlns"] + " (iqtype=result)");
 				this.iqFail();
 			}
 			
 				break;
 
 				default:
-				console.warn("zxmpp::stanzaIq::parseQueryXML(): Unknown namespace " + xml.attr["xmlns"] + " (iqtype=set)");
+				zxmppConsole.warn("zxmpp::stanzaIq::parseQueryXML(): Unknown namespace " + xml.attr["xmlns"] + " (iqtype=set)");
 				this.iqFail();
 
 			}
 			
 				break;
 				default:
-				console.warn("zxmpp::stanzaIq::parseQueryXML(): Unknown namespace " + xml.attr["xmlns"] + " (iqtype=get)");
+				zxmppConsole.warn("zxmpp::stanzaIq::parseQueryXML(): Unknown namespace " + xml.attr["xmlns"] + " (iqtype=get)");
 				this.iqFail();
 			}	
 			break;
 
 			default:
-			console.warn("zxmpp::stanzaIq::parseQueryXML(): unhandled iq type " + this.type);
+			zxmppConsole.warn("zxmpp::stanzaIq::parseQueryXML(): unhandled iq type " + this.type);
 			this.iqFail();
 		}
 	}
 				break;
 
 				default:
-				console.warn("zxmpp::stanzaIq::parseQueryRosterXML(): Unknown namespace " + xml.attr["xmlns"]);
+				zxmppConsole.warn("zxmpp::stanzaIq::parseQueryRosterXML(): Unknown namespace " + xml.attr["xmlns"]);
 				this.iqFail();
 			}
 		}
 	
 	this.parseQueryDiscoInfoXML = function(xml)
 	{
-		//console.log("disco info: " + this.zxmpp.util.serializedXML(xml));
+		//zxmppConsole.log("disco info: " + this.zxmpp.util.serializedXML(xml));
 		
 		
 		var node = xml.attr["node"];
 			var askingIq = (this.zxmpp.stream.iqsAwaitingReply[this.id]);
 			if(!askingIq)
 			{
-				console.error("No asking iq for id " + this.id);
-				console.log(xml);
-				console.log(this.zxmpp.stream.iqsAwaitingReply);
+				zxmppConsole.error("No asking iq for id " + this.id);
+				zxmppConsole.log(xml);
+				zxmppConsole.log(this.zxmpp.stream.iqsAwaitingReply);
 				this.iqFail();
 				return; // FIXME make sure that, after failing, we give up on processing <iq> completely
 			}
 						
 						if(!askingIq.extDest)
 						{
-							console.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): unspecified extDest, cannot store ext info");
+							zxmppConsole.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): unspecified extDest, cannot store ext info");
 							continue;
 						}
 						// remember in db:
 						// FIXME: DONT ASK ABOUT VCARD HERE
 						if(this.zxmpp.vCards[presence.bareJid] == undefined)
 						{
-							console.warn("Now requesting vcard for " + presence.bareJid);
+							zxmppConsole.warn("Now requesting vcard for " + presence.bareJid);
 							this.zxmpp.stream.sendIqVCardRequest(presence.bareJid);
 							this.zxmpp.vCards[presence.bareJid] = false; // record that a request was made. don't ask again
 						}
 			var ownpresence = this.zxmpp.getPresence(this.zxmpp.fullJid);
 			if(!ownpresence)
 			{
-				console.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): cant get own presence");
+				zxmppConsole.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): cant get own presence");
 				this.iqFail();
 				return;
 			}
 			var owncaps = ownpresence.caps;
 			if(!owncaps)
 			{
-				console.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): own presence does not have caps");
+				zxmppConsole.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): own presence does not have caps");
 				this.iqFail();
 				return;
 			}
 			break;
 
 			default:
-			console.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): unimplemented response to iq's of type " + this.type);
+			zxmppConsole.warn("zxmpp::stanzaIq::parseQueryDiscoInfoXML(): unimplemented response to iq's of type " + this.type);
 			this.iqFail();
 		}
 	}
 	
 	this.iqFail = function()
 	{
-		console.warn("zxmpp::stanzaIq::iqFail(): a failure parsing IQ stanza has occured: " + this.zxmpp.util.serializedXML(this.iqXML));
+		zxmppConsole.warn("zxmpp::stanzaIq::iqFail(): a failure parsing IQ stanza has occured: " + this.zxmpp.util.serializedXML(this.iqXML));
 			
 		switch(this.type)
 		{
 			default:
 			case "get":
 			case "set":
-			console.warn("zxmpp::stanzaIq::iqFail(): responding to " + this.type + "-type iq failure ");
+			zxmppConsole.warn("zxmpp::stanzaIq::iqFail(): responding to " + this.type + "-type iq failure ");
 			
 			// FIXME perhaps we MUST include failure reason?
 			// because currently we don't do that.
 		packet.iqStanza = this;
 			
 		// remember we wait for a result or error <iq> stanza
-		console.log("appended " + this.type);
+		zxmppConsole.log("appended " + this.type);
 		if(this.type == "set" || this.type == "get")
 		{
-			//console.log("remembering " + this.id);
+			//zxmppConsole.log("remembering " + this.id);
 			this.zxmpp.stream.iqsAwaitingReply[this.id] = this;
 		}
 	}
 		
 		if(!this.iqXML)
 		{
-			console.error("zxmpp::stanzaIq::setType(): iq not set");
+			zxmppConsole.error("zxmpp::stanzaIq::setType(): iq not set");
 			return;
 		}
 		switch(aType)
 			break;
 			
 			default:
-			console.error("zxmpp::stanzaIq::setType(): invalid type " + aType);
+			zxmppConsole.error("zxmpp::stanzaIq::setType(): invalid type " + aType);
 			return;
 		}
 		
 		
 		if(!this.iqXML)
 		{
-			console.error("zxmpp::stanzaIq::setFrom(): iq not set");
+			zxmppConsole.error("zxmpp::stanzaIq::setFrom(): iq not set");
 			return;
 		}
 		
 		if(from && from != zxmpp.fullJid)
 		{
-			console.warn("zxmpp::stanzaIq::setFrom(): setting from to non-own jid");
+			zxmppConsole.warn("zxmpp::stanzaIq::setFrom(): setting from to non-own jid");
 			this.iqXML.setAttribute("from", from);
 			this.from = from;
 			return;
 		
 		if(!this.iqXML)
 		{
-			console.error("zxmpp::stanzaIq::setTo(): iq not set");
+			zxmppConsole.error("zxmpp::stanzaIq::setTo(): iq not set");
 			return;
 		}
 		this.to = to;
 	this.toJSON = function()
 	{
 		// TODO
-		console.warn("skipping encoding of stanzaIq");
+		zxmppConsole.warn("skipping encoding of stanzaIq");
 		return "< not encoding stanzaIq >";
 	}
 }

zxmpp_stanzamessage.js

 				// ignore some:
 				if(child.nodeName == "#text")
 					continue;
-				console.log("zxmpp::stanzaMessage::parseXML(): Unhandled child node " + child.nodeName + " (" + child.extendedNodeName + ")");	
+				zxmppConsole.log("zxmpp::stanzaMessage::parseXML(): Unhandled child node " + child.nodeName + " (" + child.extendedNodeName + ")");	
 			}
 			
 		}
 	this.toJSON = function()
 	{
 		// TODO
-		console.warn("skipping encoding of stanzaMessage");
+		zxmppConsole.warn("skipping encoding of stanzaMessage");
 		return "< not encoding stanzaMessage >";
 	}
 	

zxmpp_stanzapresence.js

 	this.parseXML = function (xml)
 	{
 		
-		//console.log("Presence parsing: " + this.zxmpp.util.serializedXML(xml));
+		//zxmppConsole.log("Presence parsing: " + this.zxmpp.util.serializedXML(xml));
 		this.zxmpp.util.easierAttrs(xml);
 		
 		this.from = xml.attr["from"];
 			else
 			{
 				// a bare jid
-				console.warn("Presence from barejid");
+				zxmppConsole.warn("Presence from barejid");
 				presence = this.zxmpp.getTopPresenceForBareJid(this.from);
-				console.log(xml);
+				zxmppConsole.log(xml);
 			}
 		}
 
 				break;
 				
 				default:
-				console.log("zxmpp::stanzapresence::parseXML(): Unhandled child node " + child.localName);	
+				zxmppConsole.log("zxmpp::stanzapresence::parseXML(): Unhandled child node " + child.localName);	
 			}
 			
 		}
 	this.toJSON = function()
 	{
 		// TODO
-		console.warn("skipping encoding of stanzaPresence");
+		zxmppConsole.warn("skipping encoding of stanzaPresence");
 		return "< not encoding stanzaPresence >";
 	}	
 	
 				this.genKeys();
 				ret.newKey = this.keys.pop();
 			} else {
-				console.log("would generate newkey but just peeking");
+				zxmppConsole.log("would generate newkey but just peeking");
 			}
 		}
 		return ret;
 			var conn = connection_pool[i];
 			if(conn.readyState == 0)
 			{
-				//console.log("free slot found at: " + i);
+				//zxmppConsole.log("free slot found at: " + i);
 				availableConn = conn;
 				availableConn.connindex = i;
 				availableConn.conntype = send_style;
 				return availableConn;
 				break;
 			}
-			//console.log("searching passed: " + i);
+			//zxmppConsole.log("searching passed: " + i);
 		}
-		//console.log("...but did not find empty slot");
+		//zxmppConsole.log("...but did not find empty slot");
 		return false;
 		
 	}
 		
 		
 		/*
-		console.log("============ TRANSMIT (" + send_style + ") ============");
-		console.log("(not finalized packet)");
-		console.log(this.zxmpp.util.serializedXML(packet.xml));
-		console.log("=======================================");		
+		zxmppConsole.log("============ TRANSMIT (" + send_style + ") ============");
+		zxmppConsole.log("(not finalized packet)");
+		zxmppConsole.log(this.zxmpp.util.serializedXML(packet.xml));
+		zxmppConsole.log("=======================================");		
 		*/
 		
 		if(!packet)
 		{
 			if(packet == "")
 			
-				console.error("A packet passed into transmitPacket is an empty string!");
+				zxmppConsole.error("A packet passed into transmitPacket is an empty string!");
 			else
-				console.error("A packet passed into transmitPacket is null, false or zero!");
+				zxmppConsole.error("A packet passed into transmitPacket is null, false or zero!");
 			if(printStackTrace)
 			{
 				var st = printStackTrace();
 				for(var frame in st)
 				{
-					console.error(st[frame]);
+					zxmppConsole.error(st[frame]);
 				}
 			}
 			return;
 
 		var conn = this.findFreeConnection(send_style);
 		
-		if(conn) console.log("Sending " + send_style + " with pollqueue " + this.pollPacketQueue.length + ": " + this.zxmpp.util.serializedXML(packet.xml));
+		if(conn) zxmppConsole.log("Sending " + send_style + " with pollqueue " + this.pollPacketQueue.length + ": " + this.zxmpp.util.serializedXML(packet.xml));
 
 		var assignedRid = this.assignRID(true);
 		var ridTooFarApart = this.sentUnrespondedRIDs.length && assignedRid-this.sentUnrespondedRIDs[0]>1;
 		if(ridTooFarApart)
 		{
-			console.log("Would send for RID " + assignedRid + "; but last unresponded is too far apart: " + (this.sentUnrespondedRIDs[0] ? this.sentUnrespondedRIDs[0] : "nil") + " - diff " + (assignedRid-this.sentUnrespondedRIDs[0]));
+			zxmppConsole.log("Would send for RID " + assignedRid + "; but last unresponded is too far apart: " + (this.sentUnrespondedRIDs[0] ? this.sentUnrespondedRIDs[0] : "nil") + " - diff " + (assignedRid-this.sentUnrespondedRIDs[0]));
 			return false;
 		}
 		if(conn && !ridTooFarApart && (send_style=="hold" || (send_style == "poll" && (this.pollPacketQueue.length == 0 ||sending_from_queue) )))
 			// there is an available hold or poll connection slot
 			// and, our rid is not too different from the last one we received
 
-			console.log("Sending for RID " + assignedRid + "; last unresponded is " + this.sentUnrespondedRIDs[0] + " -- toofarapart: " + ridTooFarApart + " for " + (assignedRid-this.sentUnrespondedRIDs[0]));
+			zxmppConsole.log("Sending for RID " + assignedRid + "; last unresponded is " + this.sentUnrespondedRIDs[0] + " -- toofarapart: " + ridTooFarApart + " for " + (assignedRid-this.sentUnrespondedRIDs[0]));
 
 			conn.open("POST", this.zxmpp.cfg["bind-url"]);
  			conn.setRequestHeader("Content-type","text/xml; charset=utf-8");
 			var packet = this.pollPacketQueue.shift();
 			if(!packet)
 			{
-				console.warn("zxmppStream tryEmptyingPollQueue(): Invalid packet found in poll queue has been skipped and is not sent: " + packet);
+				zxmppConsole.warn("zxmppStream tryEmptyingPollQueue(): Invalid packet found in poll queue has been skipped and is not sent: " + packet);
 				continue;
 			}
 			
 		// retry sending after timeout
 		// also, only if poll queue is completely free.
 		// otherwise, delay more
-		console.log("this.retryConn");	
+		zxmppConsole.log("this.retryConn");	
 		/*if(conn.connzxmpp.stream.pollPacketQueue.length)
 		{
-			console.log("zxmpp retryConn delaying more");
+			zxmppConsole.log("zxmpp retryConn delaying more");
 			conn.connzxmpp.stream.tryEmptyingPollQueue();
 			setTimeout(conn.connzxmpp.stream.retryConn, 1000, conn);
 			return;
 		}
-		console.log("Yay");
+		zxmppConsole.log("Yay");
 */
 		conn2 = new XMLHttpRequest();
 		conn2.open("POST", conn.connzxmpp.cfg["bind-url"]);
 		
 		if(typeof this.readyState == "undefined")
 		{
-			console.error("zxmppClass::Stream::handleConnectionStateChange(): 'this' is not XMLHttpRequest: " + typeof(this));
+			zxmppConsole.error("zxmppClass::Stream::handleConnectionStateChange(): 'this' is not XMLHttpRequest: " + typeof(this));
 			return;
 		}
 		
 			{
 				// treat as if it was a 404!
 				conn.status = 499;
-				console.warn("A terminate/item-not-found event");
+				zxmppConsole.warn("A terminate/item-not-found event");
 			}
 		}
 
 				// connection)
 				case 502:
 				// probably proxy timeout!
-				console.log("Disconnect (HTTP status " + conn.status + ") - retrying");
+				zxmppConsole.log("Disconnect (HTTP status " + conn.status + ") - retrying");
 				case 499:
 				// our internal status to denote a terminate+item-not-found
 
 				// TODO check if BOSH really specifies 404 upon out of order packet, or is this ejabberd specific behavior?		
 				if(conn.connzxmpp.stream.retriesUpon404<0)
 				{
-					console.error("zxmppClass::Stream::handleConnectionStateChange(): Too many " + conn.status + " failures, giving up and terminating");
+					zxmppConsole.error("zxmppClass::Stream::handleConnectionStateChange(): Too many " + conn.status + " failures, giving up and terminating");
 					conn.connzxmpp.stream.terminate();
 	
 					var code = "terminate/http-" + conn.status;
 				}
 				
 				conn.connzxmpp.stream.retriesUpon404--;
-				console.warn("zxmppClass::Stream::handeConnectionStateChange(): http " + conn.status + " - out of order request? http abort? retrying");
+				zxmppConsole.warn("zxmppClass::Stream::handeConnectionStateChange(): http " + conn.status + " - out of order request? http abort? retrying");
 				
 //				conn.send(conn.connoutgoing);
 
 				return;
 				
 				case 503:
-				console.error("zxmppClass::Stream::handleConnectionStateChange(): service not running or overloaded: http " + conn.status + ", terminating connection");
+				zxmppConsole.error("zxmppClass::Stream::handleConnectionStateChange(): service not running or overloaded: http " + conn.status + ", terminating connection");
 				conn.connzxmpp.stream.terminate();
 
 				var code = "terminate/http-" + conn.status;
 				case 500:
 				window.open("data:text/html," + conn.responseText, "Name");
 				default:
-				console.error("zxmppClass::Stream::handleConnectionStateChange(): invalid http status " + conn.status + ", terminating connection");
+				zxmppConsole.error("zxmppClass::Stream::handleConnectionStateChange(): invalid http status " + conn.status + ", terminating connection");
 				conn.connzxmpp.stream.terminate();
 
 				var code = "terminate/http-" + conn.status;
 			conn.connzxmpp.stream.handleConnection(conn);
 			conn.connzxmpp.stream.tryEmptyingPollQueue();
 		}
-		console.log("That was received rid " + conn.connrid);
+		zxmppConsole.log("That was received rid " + conn.connrid);
 		var idx = conn.connzxmpp.stream.sentUnrespondedRIDs.indexOf(conn.connrid);
 		if(idx!=-1)
 		{
 		}
 		catch(e)
 		{
-			console.error(e);
-			console.error(e.message);
-			console.error(e.stack);
+			zxmppConsole.error(e);
+			zxmppConsole.error(e.message);
+			zxmppConsole.error(e.stack);
 		}
 		
 		if(!this.auth)
 				var pickedMechanismName = pickedMechanism[0];
 				var pickedMechanismClass = pickedMechanism[1];
 
-				console.log("Picked authentication mechanism " + pickedMechanismName);
+				zxmppConsole.log("Picked authentication mechanism " + pickedMechanismName);
 				this.auth = new pickedMechanismClass(this.zxmpp);
 				this.auth.startAuth();
 			}
 			else
 			{
-				console.error("zxmpp::stream::handleConnection(): no authentication mechanism supported. giving up");
+				zxmppConsole.error("zxmpp::stream::handleConnection(): no authentication mechanism supported. giving up");
 
 				this.zxmpp.stream.terminate();
 	
 			// we need to add caps parsing for that first, though
 			this.sendIqQuery("jabber:iq:roster", "get");//, this.zxmpp.bareJid);
 			this.hasSentRosterRequest = true;
-			console.log("ROSTER REQUEST SENT");
+			zxmppConsole.log("ROSTER REQUEST SENT");
 		} else if (this.hasSentRosterRequest && !this.hasSentInitialPresence)
 		{
 			// set up initial presence
 		}
 		else
 		{
-			console.error("Something broke down");
-			console.log("Fulljid: " + this.zxmpp.fullJid);
+			zxmppConsole.error("Something broke down");
+			zxmppConsole.log("Fulljid: " + this.zxmpp.fullJid);
 		}
 	}
 	this.fillPollConnection = function zxmppStream_findPollConnection()
 		// form: <iq type="set"><bind><resource>name</resource></bind></iq>
 		if(!(this.zxmpp.stream.features["urn:ietf:params:xml:ns:xmpp-bind"]))
 		{
-			console.error("zxmpp::stream::sendBindRequest(): Server does not support binding. Aborting");
+			zxmppConsole.error("zxmpp::stream::sendBindRequest(): Server does not support binding. Aborting");
 			return;
 		}
 		var packet = new this.zxmpp.packet(this.zxmpp);
 		// form: <iq type="set"><session/></iq>
 		if(!(this.zxmpp.stream.features["urn:ietf:params:xml:ns:xmpp-session"]))
 		{
-			console.error("zxmpp::stream::sendSessionRequest(): Server does not support session. Aborting");
+			zxmppConsole.error("zxmpp::stream::sendSessionRequest(): Server does not support session. Aborting");
 			return;
 		}
 
 	
 	this.terminate = function zxmppStream_terminate(dont_reset_state)
 	{
-		console.log("Finishing stream termination");
+		zxmppConsole.log("Finishing stream termination");
 		for(var conn in this.connectionsHold)
 		{
 			conn.onreadystatechange = false;
 			{
 				if(typeof this.pollPacketQueue[i] == "function")
 					continue;
-				console.log("Unpacking " + i);
+				zxmppConsole.log("Unpacking " + i);
 				this.pollPacketQueue[i].wakeUp(this.zxmpp);
 			}
 		}
 		catch(e)
 		{
-			console.error(e);
-			console.log(this.zxmpp.util.prettyJson(window.sessionStorage.zxmpp));
+			zxmppConsole.error(e);
+			zxmppConsole.log(this.zxmpp.util.prettyJson(window.sessionStorage.zxmpp));
 			this.pollPacketQueue = [];
 		}
 		this.fillPollConnection();
  * international copyright laws.
  */
 
+
+var zxmppConsole = function()
+{
+}
+zxmppConsole.log = function(message)
+{
+	console.log(message);
+}
+zxmppConsole.warn = function(message)
+{
+	console.warn(message);
+}
+zxmppConsole.error = function(message)
+{
+	console.error(message);
+}
+
 zxmppClass.prototype.util = function (zxmpp)
 {
 	this.zxmpp = zxmpp;
 			if(colonsplit[0]=="xmlns" && colonsplit[1])
 			{
 				xml.namespaces[colonsplit[1]] = xml.attributes[attribute].nodeValue;
-				console.log("NAMESPACE " + colonsplit[1]);
 			}
 		}