diff options
author | BuildTools <unconfigured@null.spigotmc.org> | 2017-10-01 11:44:21 +0200 |
---|---|---|
committer | BuildTools <unconfigured@null.spigotmc.org> | 2017-10-01 11:44:21 +0200 |
commit | b658c4360685e816bc0b21e567ffd16724571dcb (patch) | |
tree | 0a621b3a00b107d90c2feea02b28cc910daf0b23 | |
parent | css (diff) |
log files
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | app.js | 12 |
2 files changed, 13 insertions, 1 deletions
@@ -1,3 +1,5 @@ md md/ node_modules/ +node.access.log +node.error.log @@ -9,6 +9,12 @@ 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'}); + +process.stdout.write = access.write.bind(access); +process.stderr.write = error.write.bind(error); + converter.setOption('parseImgDimensions', 'true'); converter.setOption('literalMidWordUnderscores', 'true'); converter.setOption('literalMidWordAsterisks', 'true'); @@ -19,6 +25,7 @@ converter.setOption('tasklists', 'true'); app.use(express.static('public')); app.get('/' + path + '/*', function(req, res) { + console.log("200 - " + req.url); fs.readFile(req.url.substr(1), 'utf8', function(err, data) { if (err) return console.log(err); @@ -27,16 +34,19 @@ app.get('/' + path + '/*', function(req, res) { }); app.get('/data', function(req, res) { + console.log("200 - " + req.url); res.send(dirTree(path, {extensions:/\.md/})); }); app.get('/img/*', function (req, res) { + console.log("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); fs.readFile('public/index.html', 'utf8', function(err, data) { if (err) return console.log(err); @@ -45,7 +55,7 @@ app.get('/', function(req, res) { }); app.get('*', function(req, res) { - console.log("404 - " + req.url); + console.error("404 - " + req.url); fs.readFile('public/404.md', 'utf8', function(err, data) { if (err) return console.log(err); |