diff --git a/api/src/log.js b/api/src/log.js index bff2a10a..0d0d04ed 100644 --- a/api/src/log.js +++ b/api/src/log.js @@ -5,7 +5,7 @@ `audit` records security-relevant events and always emits. */ const RANK = { debug: 10, info: 20, warn: 30, error: 40 }; -const THRESHOLD = { debug: 10, info: 20, warn: 30, error: 30, errors: 30 }; +const THRESHOLD = { debug: 10, info: 20, warn: 30, error: 30 }; const ABBR = { debug: 'DBG', info: 'INF', warn: 'WRN', error: 'ERR', audit: 'AUD' }; let _threshold = THRESHOLD.info; diff --git a/api/test/log.test.js b/api/test/log.test.js index 7e0405b2..4f5bc4b6 100644 --- a/api/test/log.test.js +++ b/api/test/log.test.js @@ -61,6 +61,26 @@ test('setLevel accepts known names and rejects unknown ones', () => { assert.equal(log.setLevel('nonsense'), false); }); +/* The threshold table carried a fifth name, `errors`, that the rank table never + had: documented nowhere, offered by no UI, rejected by the settings route, + and reachable only by setting LOG_LEVEL to it by hand. */ +test('the accepted level names are the four the rest of the app knows', () => { + for (const name of ['debug', 'info', 'warn', 'error']) { + assert.equal(log.setLevel(name), true, `${name} must stay accepted`); + } + assert.equal(log.setLevel('errors'), false, 'the undocumented alias is gone'); +}); + +/* warn and error deliberately share a threshold: the Settings tip reads "Errors + shows warnings and errors only". Raising error to 40 would silently drop + warnings for every install that selected it. */ +test('warnings still emit at the error level', t => { + const lines = capture(t); + log.setLevel('error'); + log.warn('still here'); + assert.match(lines.join(''), /msg="still here"/); +}); + /* ── P1-4: values were printed bare ─────────────────────────────────────────── A value containing a newline ended the line and started another, so one log.error call could emit a second line indistinguishable from a genuine AUD