Integrate winston-papertrail plugin

This commit is contained in:
Tankred Hase 2017-08-18 18:04:43 +08:00
parent 35dbc08015
commit ba6f75984e
4 changed files with 45 additions and 1 deletions

View File

@ -6,6 +6,11 @@ module.exports = {
level: process.env.LOG_LEVEL || 'silly'
},
papertrail: {
host: process.env.PAPERTRAIL_HOST,
port: process.env.PAPERTRAIL_PORT
},
server: {
port: process.env.PORT || 8888,
httpsUpgrade: process.env.HTTPS_UPGRADE,

View File

@ -21,8 +21,10 @@ const cluster = require('cluster');
const numCPUs = require('os').cpus().length;
const config = require('config');
const log = require('winston');
const papertrail = require('./src/dao/papertrail');
log.level = config.log.level;
papertrail.init(config.papertrail);
//
// Start worker cluster depending on number of CPUs

View File

@ -30,7 +30,8 @@
"nodemailer": "^2.4.2",
"nodemailer-openpgp": "^1.0.2",
"openpgp": "^2.3.0",
"winston": "^2.3.1"
"winston": "^2.3.1",
"winston-papertrail": "^1.0.5"
},
"devDependencies": {
"chai": "^4.1.1",

36
src/dao/papertrail.js Normal file
View File

@ -0,0 +1,36 @@
/**
* Mailvelope - secure email with OpenPGP encryption for Webmail
* Copyright (C) 2016 Mailvelope GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
const log = require('winston');
const config = require('config');
require('winston-papertrail');
log.exitOnError = false;
log.level = config.log.level;
exports.init = function({host, port}) {
if (!host || !port) {
return;
}
log.add(log.transports.Papertrail, {
level: config.log.level,
host,
port
});
};