Skip to content

Commit

Permalink
Changed logging to stdout.
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg84 authored and pleia2 committed Aug 9, 2017
1 parent 40f7bbb commit d5bc5ec
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
18 changes: 1 addition & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var path = require("path");
// NPM modules
var express = require("express");
var morgan = require("morgan");
var rotatingFileStream = require("rotating-file-stream");

// Project modules
var config = require("./lib/config");
Expand All @@ -19,29 +18,14 @@ morgan.token("remote-addr", function (req) {
return req.headers["x-real-ip"] || req.headers["x-forwarded-for"] || req.connection.remoteAddress;
});

// Define log directory
var logDirectory = config.application.logFolder;

// Ensure log directory exists
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory);

// Create a rotating write stream
var accessLogStream = rotatingFileStream(function(time, index) {
if (!time) time = new Date();
return 'access-' + time.toISOString().substr(0,10).split('-').join('') + '.log'
}, {
interval: '1d', // rotate daily
path: logDirectory
});

// Set application properties
app.set("port", process.env.PORT0 || config.application.port);
app.set("host", process.env.HOST || config.application.host);
app.set("env", process.env.NODE_ENV || config.application.environment);
app.set("logLevel", process.env.LOG_LEVEL || config.application.logLevel);

// Setup the logger for the routes
app.use(morgan("combined", { skip: false, stream: accessLogStream}));
app.use(morgan("combined", { skip: false}));

// Define static files path
app.use(express.static("public"));
Expand Down
1 change: 0 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
environment: process.env.NODE_ENV || "development",
apiVersion: "v1",
logLevel: "info",
logFolder: process.env.MESOS_SANDBOX || path.join(__dirname, "logs"),
refresh: {
universe: parseInt(process.env.REFRESH_UNIVERSE) || 3600000, // One hour
examples: parseInt(process.env.REFRESH_EXAMPLES) || 3600000 // One hour
Expand Down

0 comments on commit d5bc5ec

Please sign in to comment.