mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
added loggin function, no all logs can be writed to file log.txt
This commit is contained in:
parent
efb4e25840
commit
55f57f353f
3 changed files with 23 additions and 2 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -24,4 +24,7 @@ tmp
|
|||
apache-status
|
||||
|
||||
#file used by nodester
|
||||
.nodester.appconfig
|
||||
.nodester.appconfig
|
||||
|
||||
#log file
|
||||
log.txt
|
||||
|
|
@ -6,5 +6,6 @@
|
|||
"html" : true,
|
||||
"img" : true
|
||||
},
|
||||
"server" : true
|
||||
"server" : true,
|
||||
"logs" : true
|
||||
}
|
||||
17
server.js
17
server.js
|
|
@ -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();
|
||||
Loading…
Add table
Add a link
Reference in a new issue