if(typeof window.econda == 'undefined') {
var econda = window.econda = {};
}
/**
* Provides some basic debugging functions
* <p>This api will not output any messages (including errors) as long as debug mode
* is not enabled!</p>
* <p>During development, we strongly recommend to enable debug mode. This will output
* debug messages, warning and errors on browser console.</p>
* // somewhere before you use the tracking api
* econda.debug.setEnabled(true);
*
* @class econda.debug
* @static
*/
econda.debug =
{
/**
* @property {Boolean} enabled
* @private
* @static
* True to enable debug output. This includes also warnings and errors.
*/
enabled : false,
/**
* Enable debug mode for current page.
*
* @TODO Add support to enable debug mode for session (set cookie)
*
* @method
* @static
* @param {Boolean} enabled
*/
setEnabled : function(enabled)
{
this.enabled = enabled;
return this;
},
/**
* Get status, returns true if enabled
*
* @method
* @static
* @return {Boolean} True if debug mode is enabled
*/
getEnabled : function()
{
return this.enabled;
},
/**
* Writes error message to console if debug mode is enabled
* @method
* @static
* @param {String} message
* @param {Array} data additional information
*/
error : function()
{
var data = [];
for(var n=1;n<arguments.length; n++) {
data.push(arguments[n]);
}
if(this.enabled && typeof console != 'undefined' && console.error) {
console.error(arguments[0], data);
}
return this;
},
/**
* Writes warning to console if debug mode is enabled
* @method
* @static
* @param {String} message
* @param {Array} data additional information
*/
warn : function()
{
var data = [];
for(var n=1;n<arguments.length; n++) {
data.push(arguments[n]);
}
if(this.enabled && typeof console != 'undefined' && console.warn) {
console.warn(arguments[0], data);
}
return this;
},
/**
* Writes debug message to console if debug mode is enabled
* @method
* @static
* @param {String} message
* @param {Array} data additional information
*/
log : function()
{
var data = [];
for(var n=1;n<arguments.length; n++) {
data.push(arguments[n]);
}
if(this.enabled && typeof console != 'undefined' && console.log) {
console.log(arguments[0], data);
}
return this;
}
};