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 /index.js | |
| parent | 33f3d9b7a8183949a06adffcd8f11485bc6f5cce (diff) | |
Add winston logging
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 11 |
1 files changed, 8 insertions, 3 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); |
