mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-25 05:19:22 +00:00
Added log system
This commit is contained in:
parent
677b4c33d7
commit
979940fdb9
@ -4,17 +4,69 @@
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display message on browser console
|
||||
*
|
||||
* @param {String} message The message to show on browser console
|
||||
*/
|
||||
ComunicWeb.debug.logMessage = function(message){
|
||||
//We check we are not in production mode
|
||||
if(ComunicWeb.__config.productionMode != 1){
|
||||
console.log("ComunicWebApp debug message", message);
|
||||
}
|
||||
ComunicWeb.debug = {
|
||||
|
||||
//Everything seems ok
|
||||
return 0;
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
if(ComunicWeb.__config.productionMode != 1){
|
||||
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;
|
||||
},
|
||||
|
||||
}
|
||||
|
@ -69,4 +69,22 @@ ComunicWeb.common.error.fatalError = function(errorMessage, errorCode, errorData
|
||||
|
||||
//Make an API request to submit error
|
||||
this.submitError("fatal", errorMessage, errorCode, errorData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle and show a 404 not found error message
|
||||
*
|
||||
* @return {Boolean} True for a success
|
||||
*/
|
||||
ComunicWeb.common.error.pageNotFound = function(){
|
||||
alert("404 not found");
|
||||
|
||||
//Report error
|
||||
var errorData = {
|
||||
pageURL: location.href,
|
||||
};
|
||||
this.submitError("normal", "Page not found", "404", errorData);
|
||||
|
||||
//Everything seems to be OK
|
||||
return true;
|
||||
}
|
@ -74,6 +74,11 @@ var ComunicWeb = {
|
||||
* Handle and show a fatal error
|
||||
*/
|
||||
fatalError: function(errorMessage, errorCode, errorData){},
|
||||
|
||||
/**
|
||||
* Handle a 404 not found error
|
||||
*/
|
||||
pageNotFound: function(){},
|
||||
},
|
||||
|
||||
/**
|
||||
@ -87,7 +92,30 @@ var ComunicWeb = {
|
||||
* Page functions
|
||||
*/
|
||||
page: {
|
||||
/**
|
||||
* Empty current page
|
||||
*/
|
||||
emptyPage: function(createWrapper){},
|
||||
|
||||
/**
|
||||
* Show a full wait splash screen
|
||||
*/
|
||||
showWaitSplashScreen: function(){},
|
||||
|
||||
/**
|
||||
* Open a page
|
||||
*/
|
||||
openPage: function(pageURI, additionnalData){},
|
||||
|
||||
/**
|
||||
* Prepare a template load by specifying datas
|
||||
*/
|
||||
prepareLoadTemplate: function(){},
|
||||
|
||||
/**
|
||||
* Load, parse and show a template
|
||||
*/
|
||||
//Not implemented yet
|
||||
},
|
||||
|
||||
/**
|
||||
@ -99,6 +127,11 @@ var ComunicWeb = {
|
||||
* Include a Javascript file
|
||||
*/
|
||||
includeFile: function(fileURL){},
|
||||
|
||||
/**
|
||||
* Execute some source code contained in a variable
|
||||
*/
|
||||
executeJSsource: function(source){},
|
||||
},
|
||||
},
|
||||
|
||||
@ -106,9 +139,24 @@ var ComunicWeb = {
|
||||
* Debug functions
|
||||
*/
|
||||
debug:{
|
||||
/**
|
||||
* @var {Object} Internal log variable
|
||||
*/
|
||||
__log: {},
|
||||
|
||||
/**
|
||||
* Display message on browser console
|
||||
*/
|
||||
logMessage: function(message){},
|
||||
|
||||
/**
|
||||
* Save a new log message
|
||||
*/
|
||||
saveLogMessage: function(message){},
|
||||
|
||||
/**
|
||||
* Get log content in a string
|
||||
*/
|
||||
getLogContent: function(){},
|
||||
}
|
||||
}
|
@ -23,4 +23,15 @@ ComunicWeb.common.jsFiles.includeFile = function(fileURL){
|
||||
|
||||
//Everything is OK
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute some source code contained in a variable
|
||||
*
|
||||
* @param {String} source The source code to execute
|
||||
*/
|
||||
ComunicWeb.common.jsFiles.executeJSsource = function(source){
|
||||
var jsSourceContainer = document.createElement("script");
|
||||
jsSourceContainer.innerHTML = source;
|
||||
document.body.appendChild(jsSourceContainer);
|
||||
}
|
||||
|
@ -61,8 +61,9 @@ ComunicWeb.common.page = {
|
||||
* Open a page
|
||||
*
|
||||
* @param {String} pageURI The URI to the page
|
||||
* @param {Object} additionnalData Additionnal data to pass to the new page
|
||||
*/
|
||||
openPage: function(pageURI){
|
||||
openPage: function(pageURI, additionnalData){
|
||||
//Log message
|
||||
ComunicWeb.debug.logMessage("Open the following page: " + pageURI);
|
||||
|
||||
@ -99,6 +100,13 @@ ComunicWeb.common.page = {
|
||||
if(!mainContenerElem){
|
||||
mainConterElem = this.emptyPage(true);
|
||||
}
|
||||
|
||||
//Check if some additionnal data was specified
|
||||
if(!additionnalData)
|
||||
additionnalData = {};
|
||||
|
||||
//Call the method related to the page
|
||||
|
||||
|
||||
},
|
||||
|
||||
@ -116,7 +124,7 @@ ComunicWeb.common.page = {
|
||||
|
||||
//Return object
|
||||
return obj;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Load, parse and show a template
|
||||
@ -124,4 +132,7 @@ ComunicWeb.common.page = {
|
||||
* @param {Object} targetElem The target element where the template will be applied
|
||||
* @param {Object} ResumeHERE
|
||||
*/
|
||||
//getAndShowTemplate: function(){
|
||||
|
||||
//}
|
||||
};
|
@ -17,7 +17,8 @@ ComunicWeb.pagesList = {
|
||||
* 404 Page not found
|
||||
*/
|
||||
notFound: {
|
||||
pageTitle: "404 page not found"
|
||||
pageTitle: "404 page not found",
|
||||
methodHandler: "ComunicWeb.common.error.pageNotFound",
|
||||
}
|
||||
|
||||
};
|
@ -48,4 +48,7 @@ $config['JSfiles'] = array(
|
||||
$config['languagesPath'] = "%PATH_ASSETS%js/langs/";
|
||||
|
||||
//Production mode
|
||||
$config['productionMode'] = 0;
|
||||
$config['productionMode'] = 0;
|
||||
|
||||
//Application version
|
||||
$config['appVersion'] = "0.1";
|
Loading…
Reference in New Issue
Block a user