|
|
@ -10,10 +10,17 @@ var util = require('util');
|
|
|
|
// si on veut reste on "write"
|
|
|
|
// si on veut reste on "write"
|
|
|
|
var logfile = fs.createWriteStream(process.cwd() + '/server.log', { flags: 'w' });
|
|
|
|
var logfile = fs.createWriteStream(process.cwd() + '/server.log', { flags: 'w' });
|
|
|
|
console.log = function () {
|
|
|
|
console.log = function () {
|
|
|
|
logfile.write(util.format.apply(null, arguments) + '\n');
|
|
|
|
let args = Array.from(arguments);
|
|
|
|
|
|
|
|
args = args.map(function (value) {
|
|
|
|
|
|
|
|
datetime=new Date();
|
|
|
|
|
|
|
|
value="\n"+datetime.toLocaleString('fr-FR', {hour12: false}) + " - " + typeof(value) + " - " +value.toString();
|
|
|
|
|
|
|
|
return(value);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
logfile.write(args.join(''));
|
|
|
|
process.stdout.write(util.format.apply(null, arguments) + '\n');
|
|
|
|
process.stdout.write(util.format.apply(null, arguments) + '\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const server = http.createServer(function (request, response) {
|
|
|
|
const server = http.createServer(function (request, response) {
|
|
|
|
parsedUrl = url.parse(request.url, false);
|
|
|
|
parsedUrl = url.parse(request.url, false);
|
|
|
|
json_response(200,{status : "active"},response);
|
|
|
|
json_response(200,{status : "active"},response);
|
|
|
@ -41,7 +48,7 @@ fs.access(local_env_file, fs.constants.R_OK, (err) => {
|
|
|
|
server.listen(process.env.SERVER_PORT || 8080);
|
|
|
|
server.listen(process.env.SERVER_PORT || 8080);
|
|
|
|
datetime=new Date();
|
|
|
|
datetime=new Date();
|
|
|
|
console.log('server started at :'+datetime.toLocaleString('fr-FR', {hour12: false}));
|
|
|
|
console.log('server started at :'+datetime.toLocaleString('fr-FR', {hour12: false}));
|
|
|
|
console.log('server started at :'+datetime.toLocaleString('en-EN'),'server started at :'+datetime);
|
|
|
|
console.log("coucou",1,'server started at :'+datetime.toLocaleString('en-EN'),'server started at :'+datetime);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//usefull functions
|
|
|
|
//usefull functions
|
|
|
|