From 4a0addeb2a8e1c57e7bd4dba62a238825752283d Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 1 Oct 2017 11:58:46 +0200 Subject: log dates --- app.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index 8a4313b..0c4aa64 100644 --- a/app.js +++ b/app.js @@ -9,8 +9,8 @@ const converter = new showdown.Converter(); const app = express(); const path = 'md'; -const access = fs.createWriteStream('node.access.log', {flags: 'a'}); -const error = fs.createWriteStream('node.error.log', {flags: 'a'}); +const access = fs.createWriteStream('node.access.log'); +const error = fs.createWriteStream('node.error.log'); process.stdout.write = access.write.bind(access); process.stderr.write = error.write.bind(error); @@ -25,7 +25,7 @@ converter.setOption('tasklists', 'true'); app.use(express.static('public')); app.get('/' + path + '/*', function(req, res) { - console.log("200 - " + req.url); + console.log("[" + new Date() + "] > " + "200 - " + req.url); fs.readFile(req.url.substr(1), 'utf8', function(err, data) { if (err) return console.log(err); @@ -34,19 +34,19 @@ app.get('/' + path + '/*', function(req, res) { }); app.get('/data', function(req, res) { - console.log("200 - " + req.url); + console.log("[" + new Date() + "] > " + "200 - " + req.url); res.send(dirTree(path, {extensions:/\.md/})); }); app.get('/img/*', function (req, res) { - console.log("200 - " + req.url); + console.log("[" + new Date() + "] > " + "200 - " + req.url); var img = fs.readFileSync(req.url.replace('/img', path)); res.writeHead(200, {'Content-Type': 'image/gif' }); res.end(img, 'binary'); }); app.get('/', function(req, res) { - console.log("200 - " + req.url); + console.log("[" + new Date() + "] > " + "200 - " + req.url); fs.readFile('public/index.html', 'utf8', function(err, data) { if (err) return console.log(err); @@ -55,7 +55,7 @@ app.get('/', function(req, res) { }); app.get('*', function(req, res) { - console.error("404 - " + req.url); + console.log("[" + new Date() + "] > " + "404 - " + req.url); fs.readFile('public/404.md', 'utf8', function(err, data) { if (err) return console.log(err); -- cgit v1.2.3