make getLogs async
This commit is contained in:
+9
-10
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user