Fix process logs not returning

The API endpoint listening for a dump of process logs was not returning logs properly for two reasons:
1. The `id` field was being appended to each log. This had been moved to the `handleLog` function of the `LogHandler`.
2. The slice needed to grab logs from the end, so the `limit` was made negative on the `.slice()`.
This commit is contained in:
emizzle 2018-10-25 08:01:48 +02:00 committed by Pascal Precht
parent dcdcfb5b32
commit efa21a1915
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 1 additions and 1 deletions

View File

@ -28,7 +28,7 @@ class ProcessLogsApi {
(req, res) => {
let limit = parseInt(req.query.limit, 10);
if (!Number.isInteger(limit)) limit = 0;
const result = this.logHandler.logs.map((log, id) => Object.assign(log, {id})).slice(limit);
const result = this.logHandler.logs.slice(limit * -1);
res.send(JSON.stringify(result));
}
);