added loggin function, no all logs can be writed to file log.txt

This commit is contained in:
coderaiser 2012-07-06 10:26:52 -04:00
parent efb4e25840
commit 55f57f353f
3 changed files with 23 additions and 2 deletions

5
.gitignore vendored
View file

@ -24,4 +24,7 @@ tmp
apache-status
#file used by nodester
.nodester.appconfig
.nodester.appconfig
#log file
log.txt

View file

@ -6,5 +6,6 @@
"html" : true,
"img" : true
},
"server" : true
"server" : true,
"logs" : true
}

View file

@ -216,6 +216,12 @@ CloudServer.init=(function(){
* setting config to testing
*/
if(process.argv[1]==='testing')CloudServer.Config.server=false;
if(CloudServer.Config.logs){
console.log('log param setted up in config.json\n' +
'from now all logs will be writed to log.txt');
CloudServer.writeLogsToFile();
}
}catch(pError){
console.log('warning: configureation file config.json not found...\n' +
'using default values...\n' +
@ -715,4 +721,15 @@ CloudServer.sendResponse = function(pHead, pData,pName){
}
};
/* function sets stdout to file log.txt */
CloudServer.writeLogsToFile = function(){
var stdo = require('fs').createWriteStream('./log.txt');
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
stdo.write(string);
}
})(process.stdout.write)
}
CloudServer.start();