diff --git a/.gitignore b/.gitignore index 04dab2f9..ae3ea1b8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ tmp apache-status #file used by nodester -.nodester.appconfig \ No newline at end of file +.nodester.appconfig + +#log file +log.txt \ No newline at end of file diff --git a/config.json b/config.json index 72791598..fefe21d5 100644 --- a/config.json +++ b/config.json @@ -6,5 +6,6 @@ "html" : true, "img" : true }, - "server" : true + "server" : true, + "logs" : true } \ No newline at end of file diff --git a/server.js b/server.js index 12ba0684..47836440 100644 --- a/server.js +++ b/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(); \ No newline at end of file