ffffng/server/logger.js

43 lines
953 B
JavaScript
Raw Normal View History

2016-05-24 16:40:57 +02:00
'use strict';
var config = require('./config');
2016-05-24 19:14:09 +02:00
// Hack to allow proper logging of Error.
Object.defineProperty(Error.prototype, 'message', {
configurable: true,
enumerable: true
});
Object.defineProperty(Error.prototype, 'stack', {
configurable: true,
enumerable: true
2016-05-24 16:40:57 +02:00
});
2016-05-24 19:14:09 +02:00
var scribe = require('scribe-js')({
rootPath: config.server.logging.directory,
2016-05-24 16:40:57 +02:00
});
2016-05-24 19:14:09 +02:00
if (config.server.logging.debug) {
process.console.addLogger('debug', 'grey', {
logInConsole: false
});
} else {
process.console.debug = function () {
this._reset(); // forget tags, etc. for this logging event
};
2016-05-24 19:14:09 +02:00
}
2016-05-24 16:40:57 +02:00
angular.module('ffffng').factory('Logger', function (app) {
2016-05-24 19:14:09 +02:00
if (config.server.logging.logRequests) {
app.use(scribe.express.logger());
}
2016-05-24 19:40:02 +02:00
if (config.server.internal.active) {
app.use('/internal/logs', scribe.webPanel());
}
2016-05-24 16:40:57 +02:00
return process.console;
});
module.exports = process.console;