logs: make logPaths work

we have to tail via sudo script

Fixes #811
This commit is contained in:
Girish Ramakrishnan
2024-02-22 18:08:32 +01:00
parent ce42680888
commit d0dc104ede
10 changed files with 29 additions and 27 deletions
+2 -3
View File
@@ -669,8 +669,6 @@ async function getLogStream(req, res, next) {
const lines = 'lines' in req.query ? parseInt(req.query.lines, 10) : 10; // we ignore last-event-id
if (isNaN(lines)) return next(new HttpError(400, 'lines must be a valid number'));
function sse(id, data) { return 'id: ' + id + '\ndata: ' + data + '\n\n'; }
if (req.headers.accept !== 'text/event-stream') return next(new HttpError(400, 'This API call requires EventStream'));
const options = {
@@ -693,7 +691,8 @@ async function getLogStream(req, res, next) {
res.on('close', logStream.close);
logStream.on('data', function (data) {
const obj = JSON.parse(data);
res.write(sse(obj.realtimeTimestamp, JSON.stringify(obj))); // send timestamp as id
const sse = `data: ${JSON.stringify(obj)}\n\n`;
res.write(sse);
});
logStream.on('end', res.end.bind(res));
logStream.on('error', res.end.bind(res, null));