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-07-29 12:53:20 +02:00
|
|
|
function addLogger(name, color, active) {
|
|
|
|
if (active) {
|
|
|
|
process.console.addLogger(name, color, {
|
|
|
|
logInConsole: false
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
process.console[name] = function () {
|
|
|
|
this._reset(); // forget tags, etc. for this logging event
|
|
|
|
};
|
|
|
|
}
|
2016-05-24 19:14:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:53:20 +02:00
|
|
|
addLogger('debug', 'grey', config.server.logging.debug);
|
|
|
|
addLogger('profile', 'blue', config.server.logging.profile);
|
|
|
|
|
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;
|