ComunicWeb/assets/js/common/debug.js

104 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

/**
* Debug functions
*
* @author Pierre HUBERT
*/
2017-01-22 17:46:06 +00:00
ComunicWeb.debug = {
/**
* @var {Object} Internal log variable
*/
__log: {},
/**
* Display message on browser console
*
* @param {String} message The message to show on browser console
*/
logMessage: function(message){
//We check we are not in production mode
2018-01-02 17:48:39 +00:00
if(ComunicWeb.__config.productionMode != true){
2017-01-22 17:46:06 +00:00
console.log("ComunicWebApp debug message", message);
}
//Save log message
this.saveLogMessage(message);
//Everything seems ok
return 0;
},
/**
* Save a new log message
*
* @param {String} message The message to store
*/
saveLogMessage: function(message){
//Get current timestamp
var timeStamp = new Date().getTime();
//Get a random number for log ID
var logElemId = Math.random();
//Save the new message
this.__log[logElemId] = {
timeStamp: timeStamp,
message: message,
}
//Everything seems to be OK
return 0;
},
/**
* Get log content into a String
*
* @return {String} The log parsed into strings
*/
getLogContent: function(){
//Prepare return
var logString = "---ComunicWebApp v"+ComunicWeb.__config.appVersion+" ---\n";
//Process each line of the log
for(i in this.__log){
logString += i + " \t " + this.__log[i].timeStamp + " \t " + this.__log[i].message + "\n";
}
//Return result
return logString;
},
/**
* Display Comunic Logo on the developper console
*
* @return {Boolean} True for a success
*/
displayComunicLogo: function(){
//Prepare message
var message = " \n";
message += " \n";
message += " ==================== \n";
message += " ==================== \n";
message += " ==================== \n";
message += " ======== \n";
message += " ======== \n";
message += " ======== \n";
message += " ======== \n";
message += " ======== \n";
message += " ======== \n";
message += " ==================== \n";
message += " ==================== \n";
message += " ==================== \n";
message += " \n";
message += " ComunicWeb 2.0 \n";
message += " \n";
message += " v"+ComunicWeb.__config.appVersion+" \n";
message += " \n";
//Display message
console.log(message);
}
2017-01-22 17:46:06 +00:00
}