diff options
| author | tunkki <tunkki@tunkkikone> | 2016-08-14 18:02:13 +0300 |
|---|---|---|
| committer | tunkki <tunkki@tunkkikone> | 2016-08-14 18:02:13 +0300 |
| commit | a3c6f98ce18c6dc26abff965bed06b9885f2d27c (patch) | |
| tree | 4397f1d3e9cc12d06f6ec8cec448875cda3e0d64 | |
| parent | 33f3d9b7a8183949a06adffcd8f11485bc6f5cce (diff) | |
Add winston logging
| -rw-r--r-- | index.js | 11 | ||||
| -rw-r--r-- | logs/server.log | 1 | ||||
| -rw-r--r-- | package.json | 7 |
3 files changed, 13 insertions, 6 deletions
@@ -1,6 +1,11 @@ var statuscake = require("statuscake"); var express = require("express"); var ejs = require("ejs"); +var winston = require("winston"); +winston.remove(winston.transports.Console); +winston.add(winston.transports.Console, {'timestamp': true}); +winston.add(winston.transports.File, { filename: './logs/server.log', level: 'info', timestamp: true, handleExceptions: true, maxsize: 5242880, maxFiles: 10}); +winston.level = 'info'; var app = express(); app.set("views", __dirname + "/views"); @@ -9,7 +14,7 @@ app.use(express.static("public")); var args = process.argv.slice(2); if (args.length != 2) { - console.log("Please provide user and key as positional arguments."); + winston.error("Please provide user and key as positional arguments."); process.exit(1); } @@ -34,7 +39,7 @@ app.get("/status", function(req, res) { }); app.listen(PORT, function() { - console.log("radiodiodi status display listening on port " + PORT + "."); + winston.info("radiodiodi status display listening on port " + PORT + "."); }); function get_status(err, data) { @@ -48,7 +53,7 @@ function get_status(err, data) { currentStatus.push(system); } - console.log(currentStatus); + winston.info(currentStatus); } statuscake.tests(get_status); diff --git a/logs/server.log b/logs/server.log new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/logs/server.log @@ -0,0 +1 @@ + diff --git a/package.json b/package.json index de0a3e2..a0bb66d 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,11 @@ }, "homepage": "https://github.com/jantuomi/radiodiodi-status-display#readme", "dependencies": { - "statuscake": "0.1.3", + "angular": "1.5.8", "d3": "4.2.1", - "express": "4.14.0", "ejs": "2.5.1", - "angular": "1.5.8" + "express": "4.14.0", + "statuscake": "0.1.3", + "winston": "^2.2.0" } } |
