Clean custom logs
This commit is contained in:
parent
bd5c10eca9
commit
61352eb54d
@ -1,7 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var serverOptions = require('./../../server-options');
|
||||
var { logger } = serverOptions();
|
||||
var crypto = require('crypto');
|
||||
var uuid = require('uuid');
|
||||
var step = require('step');
|
||||
@ -245,24 +243,19 @@ OgrFormat.prototype.toOGR_SingleFile = function (options, fmt, callback) {
|
||||
OgrFormat.prototype.sendResponse = function (opts, callback) {
|
||||
var exportRequest = new ExportRequest(opts.sink, callback, opts.beforeSink);
|
||||
|
||||
logger.info({ custom: true }, 'sendResponse');
|
||||
|
||||
this.generate(opts, function (err, dumpfile) {
|
||||
if (opts.profiler) {
|
||||
opts.profiler.done('generate');
|
||||
}
|
||||
step(
|
||||
function sendResult () {
|
||||
logger.info({ custom: true }, 'sendResult');
|
||||
if (err) {
|
||||
logger.info({ custom: true }, 'sendResult: error');
|
||||
exportRequest.cb(err);
|
||||
return true;
|
||||
}
|
||||
exportRequest.sendFile(dumpfile, this);
|
||||
},
|
||||
function cleanup () {
|
||||
logger.info({ custom: true }, 'cleanup');
|
||||
// unlink dump file (sync to avoid race condition)
|
||||
console.log('removing', dumpfile);
|
||||
try { fs.unlinkSync(dumpfile); } catch (e) {
|
||||
@ -286,7 +279,6 @@ function ExportRequest (ostream, callback, beforeSink) {
|
||||
var that = this;
|
||||
|
||||
this.ostream.on('close', function () {
|
||||
logger.info({ custom: true }, 'close ExportRequest');
|
||||
that.canceled = true;
|
||||
if (that.istream) {
|
||||
that.istream.destroy();
|
||||
@ -296,7 +288,6 @@ function ExportRequest (ostream, callback, beforeSink) {
|
||||
|
||||
ExportRequest.prototype.sendFile = function (filename, callback) {
|
||||
if (this.canceled) {
|
||||
logger.info({ custom: true }, 'sendFile canceled');
|
||||
return callback();
|
||||
}
|
||||
|
||||
@ -307,8 +298,6 @@ ExportRequest.prototype.sendFile = function (filename, callback) {
|
||||
that.beforeSink();
|
||||
}
|
||||
|
||||
logger.info({ custom: true }, 'sendFile: open');
|
||||
|
||||
that.istream
|
||||
.pipe(that.ostream)
|
||||
.on('end', () => {
|
||||
@ -321,7 +310,6 @@ ExportRequest.prototype.sendFile = function (filename, callback) {
|
||||
});
|
||||
})
|
||||
.on('error', function (e) {
|
||||
logger.info({ custom: true }, 'sendFile: error');
|
||||
console.log("Can't send response: " + e);
|
||||
that.read = true;
|
||||
that.ostream.end();
|
||||
@ -329,13 +317,11 @@ ExportRequest.prototype.sendFile = function (filename, callback) {
|
||||
callback();
|
||||
})
|
||||
.on('end', () => {
|
||||
logger.info({ custom: true }, 'sendFile: end');
|
||||
that.read = true;
|
||||
that.cb();
|
||||
callback();
|
||||
})
|
||||
.on('close', () => {
|
||||
logger.info({ custom: true }, 'sendFile: close');
|
||||
if (!that.read) { // NOTE: Covering 304 responses, when the 'ostream' is closed after 'pipe'
|
||||
callback();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user