Skip to content
Snippets Groups Projects
Commit d7e0abd6 authored by Ben Adida's avatar Ben Adida
Browse files

added first logging infrastructure

parent 811de3a5
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ secrets = require('./lib/secrets.js'),
db = require('./lib/db.js'),
configuration = require('../libs/configuration.js'),
substitution = require('../libs/substitute.js');
logging = require("../libs/logging.js");
// looks unused, see run.js
// const STATIC_DIR = path.join(path.dirname(__dirname), "static");
......
const winston = require("winston");
const configuration = require("./configuration");
// go through the configuration and determine log location
// for now we only log to one place
// FIXME: separate logs depending on purpose?
var log_path = configuration.get('log_path');
var LOGGER = null;
if (log_path) {
LOGGER= new (winston.Logger)({
transports: [new (winston.transports.File)({filename: log_path})]
});
}
// entry is an object that will get JSON'ified
exports.log = function(entry) {
// entry must have at least a type
if (!entry.type)
throw new Error("every log entry needs a type");
// if no logger, go to console (FIXME: do we really want to log to console?)
if (LOGGER)
LOGGER.info(JSON.stringify(entry));
else
winston.info(JSON.stringify(entry));
};
......@@ -15,5 +15,6 @@
, "temp": "0.2.0"
, "express-csrf": "0.3.2"
, "uglify-js": "1.0.6"
, "winston" : "0.3.3"
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment