Skip to content

Node.js based forum software built for the modern web

added timing to prune

Baris Soner Usaklidaa115479795
diff --git a/src/events.js b/src/events.js
index 283c1f3d5e..54953f6b67 100644
--- a/src/events.js
+++ b/src/events.js
@@ -57,7 +57,7 @@ var fs = require('fs'),
return;
}
- var msg = '[' + new Date().toUTCString() + '] - ' + username + '(uid ' + uid + ') ' + string + '\n';
+ var msg = '[' + new Date().toUTCString() + '] - ' + username + '(uid ' + uid + ') ' + string;
log(msg);
});
}
@@ -65,7 +65,7 @@ var fs = require('fs'),
events.log = function(msg) {
var logFile = path.join(nconf.get('base_dir'), logFileName);
- fs.appendFile(logFile, msg, function(err) {
+ fs.appendFile(logFile, msg + '\n', function(err) {
if(err) {
winston.error('Error logging event. ' + err.message);
return;
diff --git a/src/notifications.js b/src/notifications.js
index f546ebdd3e..e1d5f3ed35 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -197,6 +197,8 @@ var async = require('async'),
};
Notifications.prune = function(cutoff) {
+ var start = process.hrtime();
+
if (process.env.NODE_ENV === 'development') {
winston.info('[notifications.prune] Removing expired notifications from the database.');
}
@@ -269,6 +271,9 @@ var async = require('async'),
if (process.env.NODE_ENV === 'development') {
winston.info('[notifications.prune] Notification pruning completed. ' + numPruned + ' expired notification' + (numPruned !== 1 ? 's' : '') + ' removed.');
}
+ var diff = process.hrtime(start);
+ events.log('Pruning notifications took : ' + (diff[0] * 1e3 + diff[1] / 1e6) + ' ms');
+
});
});