Added support for writing profiling logs.
For now it supports profiling database queries and job execution time.
This commit is contained in:
parent
f0830dc359
commit
7921178165
|
@ -116,6 +116,7 @@ Dann die `config.json` anpassen nach belieben. Es gibt die folgenden Konfigurati
|
||||||
|
|
||||||
* **`server.logging.directory`** Verzeichnis unter dem Log-Files abgelegt werden, z. B.: `"$FFFFNG_HOME/logs"`
|
* **`server.logging.directory`** Verzeichnis unter dem Log-Files abgelegt werden, z. B.: `"$FFFFNG_HOME/logs"`
|
||||||
* **`server.logging.debug`** Gibt an, ob Debug-Output geloggt werden soll (Achtung, viel!), z. B.: `false`
|
* **`server.logging.debug`** Gibt an, ob Debug-Output geloggt werden soll (Achtung, viel!), z. B.: `false`
|
||||||
|
* **`server.logging.profile`** Gibt an, ob Profiling-Output geloggt werden soll (Achtung, viel!), z. B.: `false`
|
||||||
* **`server.logging.logRequests`** Gib an, ob HTTP-Requests geloggt werden sollen (Achtung, Datenschutz!), z. B.: `false`
|
* **`server.logging.logRequests`** Gib an, ob HTTP-Requests geloggt werden sollen (Achtung, Datenschutz!), z. B.: `false`
|
||||||
|
|
||||||
* **`server.internal.active`** Gibt an, ob interne URLs, wie Admin-Panel und Logging-Interface, erreichbar sein sollen,
|
* **`server.internal.active`** Gibt an, ob interne URLs, wie Admin-Panel und Logging-Interface, erreichbar sein sollen,
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"logging": {
|
"logging": {
|
||||||
"directory": "/tmp/logs",
|
"directory": "/tmp/logs",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
|
"profile": false,
|
||||||
"logRequests": false
|
"logRequests": false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ var defaultConfig = {
|
||||||
logging: {
|
logging: {
|
||||||
directory: '/tmp/logs',
|
directory: '/tmp/logs',
|
||||||
debug: false,
|
debug: false,
|
||||||
|
profile: false,
|
||||||
logRequests: false
|
logRequests: false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,10 @@ module.exports = {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.on('profile', function (sql, time) {
|
||||||
|
Logger.tag('database').profile('[%sms]\t%s', time, sql);
|
||||||
|
});
|
||||||
|
|
||||||
applyMigrations(db, function (err) {
|
applyMigrations(db, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
Logger.tag('database').error('Error migrating database:', err);
|
Logger.tag('database').error('Error migrating database:', err);
|
||||||
|
|
|
@ -53,6 +53,8 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi
|
||||||
task.state = 'running';
|
task.state = 'running';
|
||||||
|
|
||||||
job.run(function () {
|
job.run(function () {
|
||||||
|
var now = moment();
|
||||||
|
Logger.tag('jobs').profile('[%sms]\t%s', now.diff(task.runningSince), task.name);
|
||||||
task.runningSince = false;
|
task.runningSince = false;
|
||||||
task.state = 'idle';
|
task.state = 'idle';
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,15 +18,20 @@ var scribe = require('scribe-js')({
|
||||||
rootPath: config.server.logging.directory,
|
rootPath: config.server.logging.directory,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config.server.logging.debug) {
|
function addLogger(name, color, active) {
|
||||||
process.console.addLogger('debug', 'grey', {
|
if (active) {
|
||||||
|
process.console.addLogger(name, color, {
|
||||||
logInConsole: false
|
logInConsole: false
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
process.console.debug = function () {
|
process.console[name] = function () {
|
||||||
this._reset(); // forget tags, etc. for this logging event
|
this._reset(); // forget tags, etc. for this logging event
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addLogger('debug', 'grey', config.server.logging.debug);
|
||||||
|
addLogger('profile', 'blue', config.server.logging.profile);
|
||||||
|
|
||||||
angular.module('ffffng').factory('Logger', function (app) {
|
angular.module('ffffng').factory('Logger', function (app) {
|
||||||
if (config.server.logging.logRequests) {
|
if (config.server.logging.logRequests) {
|
||||||
|
|
Loading…
Reference in a new issue