system: simplify logic

This commit is contained in:
Girish Ramakrishnan
2024-07-25 17:50:41 +02:00
parent 9399040cd3
commit 731295f708

View File

@@ -300,12 +300,9 @@ async function getLogs(unit, options) {
assert.strictEqual(typeof unit, 'string');
assert(options && typeof options === 'object');
debug(`Getting logs for ${unit}`);
let logFile = '';
if (unit === 'box') logFile = path.join(paths.LOG_DIR, 'box.log'); // box.log is at the top
else throw new BoxError(BoxError.BAD_FIELD, `No such unit '${unit}'`);
if (unit !== 'box') throw new BoxError(BoxError.BAD_FIELD, `No such unit '${unit}'`);
const logFile = path.join(paths.LOG_DIR, 'box.log');
const cp = logs.tail([logFile], { lines: options.lines, follow: options.follow });
const logStream = new logs.LogStream({ format: options.format || 'json', source: unit });