make getLogs async

This commit is contained in:
Girish Ramakrishnan
2021-10-01 09:23:20 -07:00
parent b34d642490
commit 1483dff018
2 changed files with 15 additions and 17 deletions
+9 -10
View File
@@ -618,7 +618,7 @@ function getLogStream(req, res, next) {
});
}
function getLogs(req, res, next) {
async function getLogs(req, res, next) {
assert.strictEqual(typeof req.app, 'object');
var lines = 'lines' in req.query ? parseInt(req.query.lines, 10) : 10;
@@ -630,17 +630,16 @@ function getLogs(req, res, next) {
format: req.query.format || 'json'
};
apps.getLogs(req.app, options, function (error, logStream) {
if (error) return next(BoxError.toHttpError(error));
const [error, logStream] = await safe(apps.getLogs(req.app, options));
if (error) return next(BoxError.toHttpError(error));
res.writeHead(200, {
'Content-Type': 'application/x-logs',
'Content-Disposition': `attachment; filename="${req.app.id}.log"`,
'Cache-Control': 'no-cache',
'X-Accel-Buffering': 'no' // disable nginx buffering
});
logStream.pipe(res);
res.writeHead(200, {
'Content-Type': 'application/x-logs',
'Content-Disposition': `attachment; filename="${req.app.id}.log"`,
'Cache-Control': 'no-cache',
'X-Accel-Buffering': 'no' // disable nginx buffering
});
logStream.pipe(res);
}
function demuxStream(stream, stdin) {