ffffng/server/logger.js

39 lines
830 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 () {};
}
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 16:40:57 +02:00
app.use('/internal/logs', scribe.webPanel());
return process.console;
});
module.exports = process.console;