Compare commits

..

3 Commits

Author SHA1 Message Date
Rafa de la Torre
2d432c55d5 Use microsecond precision to log response time 2018-04-20 19:04:28 +02:00
Francisco Dans
145d5f91e3 Merge pull request #1 from CartoDB/master
Upstream update, adds x-forwarde-for by default
2015-06-01 16:02:53 +02:00
Raul Ochoa
a669f7c2f4 Allow shutting down of appenders without disabling future log writes 2014-12-02 12:16:15 +01:00
3 changed files with 15 additions and 3 deletions

View File

@ -85,7 +85,9 @@ function configure(config, options) {
}
function shutdown(cb) {
async.each(openFiles, function(file, done) {
var filesToClose = openFiles;
openFiles = [];
async.each(filesToClose, function(file, done) {
if (!file.write(eol, "utf-8")) {
file.once('drain', function() {
file.end(done);

View File

@ -54,7 +54,7 @@ function getLogger(logger4js, options) {
if (nolog && nolog.test(req.originalUrl)) return next();
if (thislogger.isLevelEnabled(level) || options.level === 'auto') {
var start = new Date()
var start = process.hrtime()
, statusCode
, writeHead = res.writeHead
, url = req.originalUrl;
@ -81,7 +81,8 @@ function getLogger(logger4js, options) {
//hook on end request to emit the log entry of the HTTP request.
res.on('finish', function() {
res.responseTime = new Date() - start;
var end = process.hrtime();
res.responseTime = (end[0] - start[0]) * 1000 + (end[1] - start[1]) / 1000000;
//status code response level handling
if(res.statusCode && options.level === 'auto'){
level = levels.INFO;

View File

@ -219,6 +219,11 @@ function clearAppenders () {
}
}
function clearAndShutdownAppenders(cb) {
clearAppenders();
shutdownAppenders(cb);
}
function configureAppenders(appenderList, options) {
clearAppenders();
if (appenderList) {
@ -428,7 +433,10 @@ function shutdown(cb) {
// First, disable all writing to appenders. This prevents appenders from
// not being able to be drained because of run-away log writes.
loggerModule.disableAllLogWrites();
shutdownAppenders(cb);
}
function shutdownAppenders(cb) {
// Next, get all the shutdown functions for appenders as an array.
var shutdownFunctions = Object.keys(appenderShutdowns).reduce(
function(accum, category) {
@ -454,6 +462,7 @@ module.exports = {
addAppender: addAppender,
loadAppender: loadAppender,
clearAppenders: clearAppenders,
clearAndShutdownAppenders: clearAndShutdownAppenders,
configure: configure,
shutdown: shutdown,