standard-log 11.2.2 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -19
- package/dist/standard-log.es5.js +192 -170
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +1 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js +11 -14
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/package.json +4 -4
- package/cjs/testUtil.d.ts +0 -10
- package/cjs/testUtil.d.ts.map +0 -1
- package/cjs/testUtil.js +0 -25
- package/cjs/testUtil.js.map +0 -1
- package/esm/console.spec.d.ts +0 -2
- package/esm/console.spec.d.ts.map +0 -1
- package/esm/console.spec.js +0 -159
- package/esm/console.spec.js.map +0 -1
- package/esm/formatter.spec.d.ts +0 -2
- package/esm/formatter.spec.d.ts.map +0 -1
- package/esm/formatter.spec.js +0 -30
- package/esm/formatter.spec.js.map +0 -1
- package/esm/index.spec.d.ts +0 -2
- package/esm/index.spec.d.ts.map +0 -1
- package/esm/index.spec.js +0 -13
- package/esm/index.spec.js.map +0 -1
- package/esm/logLevels.spec.d.ts +0 -2
- package/esm/logLevels.spec.d.ts.map +0 -1
- package/esm/logLevels.spec.js +0 -8
- package/esm/logLevels.spec.js.map +0 -1
- package/esm/logStore.spec.d.ts +0 -2
- package/esm/logStore.spec.d.ts.map +0 -1
- package/esm/logStore.spec.js +0 -93
- package/esm/logStore.spec.js.map +0 -1
- package/esm/memory.spec.d.ts +0 -2
- package/esm/memory.spec.d.ts.map +0 -1
- package/esm/memory.spec.js +0 -144
- package/esm/memory.spec.js.map +0 -1
- package/esm/standardLog.spec.d.ts +0 -2
- package/esm/standardLog.spec.d.ts.map +0 -1
- package/esm/standardLog.spec.js +0 -576
- package/esm/standardLog.spec.js.map +0 -1
- package/esm/testUtil.d.ts +0 -10
- package/esm/testUtil.d.ts.map +0 -1
- package/esm/testUtil.js +0 -18
- package/esm/testUtil.js.map +0 -1
- package/esm/types.spec.d.ts +0 -2
- package/esm/types.spec.d.ts.map +0 -1
- package/esm/types.spec.js +0 -5
- package/esm/types.spec.js.map +0 -1
package/esm/console.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console.spec.js","sourceRoot":"","sources":["../ts/console.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EACgB,wBAAwB,EAClC,SAAS,EAAE,iBAAiB,EAAE,eAAe,EACzD,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,+EAA+E,EAAE,GAAG,EAAE;QACvF,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC3C,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC7C,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAE7C,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC5C,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC5C,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE5C,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC5C,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAA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EAAE,CAAA;IACxB,OAAO;QACL,MAAM;QACN,KAAK;QACL,KAAK;QACL,MAAM;QACN,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;KAC5C,CAAA;AACH,CAAC","sourcesContent":["import { createStandardLog } from './standardLog.js'\nimport {\n ConsoleLogFormatter, createConsoleLogReporter,\n LogFilter, logLevels, plainLogFormatter, toConsoleMethod\n} from './index.js'\nimport { polyfill } from './platform.js'\n\ndescribe('toConsoleMethod()', () => {\n it('converts any level to standard console method names: debug, info, warn, error', () => {\n expect(toConsoleMethod(1)).toEqual('error')\n expect(toConsoleMethod(399)).toEqual('error')\n expect(toConsoleMethod(400)).toEqual('error')\n\n expect(toConsoleMethod(401)).toEqual('warn')\n expect(toConsoleMethod(499)).toEqual('warn')\n expect(toConsoleMethod(500)).toEqual('warn')\n\n expect(toConsoleMethod(501)).toEqual('info')\n expect(toConsoleMethod(700)).toEqual('info')\n\n expect(toConsoleMethod(701)).toEqual('debug')\n expect(toConsoleMethod(800)).toEqual('debug')\n expect(toConsoleMethod(801)).toEqual('debug')\n expect(toConsoleMethod(Infinity)).toEqual('debug')\n })\n it('converts to debug for 0 (none) or negative (not valid) level', () => {\n // these are invalid input.\n // so instead of hiding them and not logged,\n // log them so that it is easier to discover.\n expect(toConsoleMethod(-1)).toEqual('debug')\n expect(toConsoleMethod(0)).toEqual('debug')\n })\n})\ndescribe('rendering tests', () => {\n test('plain rendering', () => {\n const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'plain', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n})\n\n\ndescribe('createConsoleLogReporter', () => {\n let fakeConsole = createFakeConsole()\n beforeEach(() => polyfill.console = fakeConsole = createFakeConsole())\n\n describe('id', () => {\n test('default is \"console\"', () => {\n const reporter = createConsoleLogReporter()\n expect(reporter.id).toBe('console')\n })\n test('can be overridden', () => {\n const reporter = createConsoleLogReporter({ id: 'neo-console' })\n expect(reporter.id).toBe('neo-console')\n })\n })\n\n describe('log level', () => {\n test('error, alert, critical and emergency logs are written to console.error', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.error, args: ['error'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(4)\n })\n\n test('warn logs are written to console.warn', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() })\n\n expect(fakeConsole.warns.length).toBe(1)\n })\n\n test('notice and info logs are written to console.info', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() })\n\n expect(fakeConsole.infos.length).toBe(2)\n })\n\n\n test('debug, trace, and planck logs are written to console.debug', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() })\n\n expect(fakeConsole.debugs.length).toBe(3)\n })\n })\n\n describe('custom logs', () => {\n test('are written according to their log level value', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n const sl = createStandardLog({\n logLevel: logLevels.all,\n customLevels: {\n 'high': 50,\n 'important': 450,\n 'interest': 650,\n 'silly': 1000\n },\n reporters: [reporter]\n })\n const log = sl.getLogger(id)\n log.high('a')\n log.important('b')\n log.interest('c')\n log.silly('d')\n\n expect(fakeConsole.errors.length).toBe(1)\n expect(fakeConsole.warns.length).toBe(1)\n expect(fakeConsole.infos.length).toBe(1)\n expect(fakeConsole.debugs.length).toBe(1)\n })\n })\n\n const idFormatter: ConsoleLogFormatter = (entry) => [entry.id]\n\n describe('formatter', () => {\n test('use specific formatter', () => {\n const id = 'id-only'\n const reporter = createConsoleLogReporter({ formatter: idFormatter })\n expect(reporter.formatter).toBe(idFormatter)\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\n })\n it('uses consoleFormatter if formatter is undefined', () => {\n const reporter = createConsoleLogReporter({ formatter: undefined })\n\n const entry = { id: 'no formatter', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() }\n reporter.write(entry)\n\n expect(fakeConsole.errors).toEqual([\n ['emergency']\n ])\n })\n })\n\n describe('filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n test('use specific filter', () => {\n const reporter = createConsoleLogReporter({ formatter: idFormatter, filter })\n expect(reporter.filter).toBe(filter)\n\n reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['normal']])\n })\n })\n\n test('write log entry with multiple arguments', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter({ formatter: plainLogFormatter })\n\n const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() }\n\n reporter.write(entry)\n\n expect(fakeConsole.infos).toEqual([\n [entry.timestamp.toISOString(), 'log', '(INFO)', 'a', 'b', 'c']\n ])\n })\n})\n\nfunction createFakeConsole() {\n const errors: any[] = []\n const infos: any[] = []\n const warns: any[] = []\n const debugs: any[] = []\n return {\n errors,\n infos,\n warns,\n debugs,\n error(...args: any[]) { errors.push(args) },\n info(...args: any[]) { infos.push(args) },\n warn(...args: any[]) { warns.push(args) },\n debug(...args: any[]) { debugs.push(args) }\n }\n}\n"]}
|
package/esm/formatter.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.spec.d.ts","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":""}
|
package/esm/formatter.spec.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createTimestampFormatter, logLevels, plainLogFormatter } from './index.js';
|
|
2
|
-
describe('plainLogFormatter()', () => {
|
|
3
|
-
it('convert log entries to string', () => {
|
|
4
|
-
const timestamp = new Date(2019, 6);
|
|
5
|
-
const actual = plainLogFormatter({ id: 'plain', level: logLevels.emergency, args: ['emergency'], timestamp });
|
|
6
|
-
expect(actual).toEqual([timestamp.toISOString(), 'plain', `(EMERGENCY)`, `emergency`]);
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
describe('createTimestampFormatter()', () => {
|
|
10
|
-
test('none', () => {
|
|
11
|
-
const formatter = createTimestampFormatter('none');
|
|
12
|
-
const now = new Date();
|
|
13
|
-
const actual = [formatter(now)];
|
|
14
|
-
expect(actual).toEqual([undefined]);
|
|
15
|
-
});
|
|
16
|
-
test('iso', () => {
|
|
17
|
-
const formatter = createTimestampFormatter('iso');
|
|
18
|
-
const now = new Date();
|
|
19
|
-
const actual = [formatter(now)];
|
|
20
|
-
expect(actual).toEqual([now.toISOString()]);
|
|
21
|
-
});
|
|
22
|
-
test('elapsed', () => {
|
|
23
|
-
const formatter = createTimestampFormatter('elapsed');
|
|
24
|
-
const now = new Date();
|
|
25
|
-
const next = new Date(now.getTime() + 10);
|
|
26
|
-
const actual = [formatter(now), formatter(next)];
|
|
27
|
-
expect(actual).toEqual(['0ms', '10ms']);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=formatter.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.spec.js","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnC,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;QAE7G,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;IACxF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;QAChB,MAAM,SAAS,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAA;QAClD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;QACf,MAAM,SAAS,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAA;QACjD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;QACnB,MAAM,SAAS,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAA;QACrD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { createTimestampFormatter, logLevels, plainLogFormatter } from './index.js'\n\ndescribe('plainLogFormatter()', () => {\n it('convert log entries to string', () => {\n const timestamp = new Date(2019, 6)\n const actual = plainLogFormatter({ id: 'plain', level: logLevels.emergency, args: ['emergency'], timestamp })\n\n expect(actual).toEqual([timestamp.toISOString(), 'plain', `(EMERGENCY)`, `emergency`])\n })\n})\n\ndescribe('createTimestampFormatter()', () => {\n test('none', () => {\n const formatter = createTimestampFormatter('none')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([undefined])\n })\n\n test('iso', () => {\n const formatter = createTimestampFormatter('iso')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([now.toISOString()])\n })\n\n test('elapsed', () => {\n const formatter = createTimestampFormatter('elapsed')\n const now = new Date()\n const next = new Date(now.getTime() + 10)\n const actual = [formatter(now), formatter(next)]\n\n expect(actual).toEqual(['0ms', '10ms'])\n })\n})\n"]}
|
package/esm/index.spec.d.ts
DELETED
package/esm/index.spec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../ts/index.spec.ts"],"names":[],"mappings":""}
|
package/esm/index.spec.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isType } from 'type-plus';
|
|
2
|
-
import { DEFAULT_LOG_METHOD_NAMES } from './index.js';
|
|
3
|
-
describe('type tests', () => {
|
|
4
|
-
it('export types', () => {
|
|
5
|
-
isType.equal();
|
|
6
|
-
isType.equal();
|
|
7
|
-
isType.equal();
|
|
8
|
-
});
|
|
9
|
-
it('exports DEFAULT_LOG_METHOD_NAMES', () => {
|
|
10
|
-
expect(DEFAULT_LOG_METHOD_NAMES).toBeDefined();
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=index.spec.js.map
|
package/esm/index.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../ts/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAwD,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAE3G,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,MAAM,CAAC,KAAK,EAA4B,CAAA;QACxC,MAAM,CAAC,KAAK,EAAmC,CAAA;QAC/C,MAAM,CAAC,KAAK,EAAoC,CAAA;IAClD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,wBAAwB,CAAC,CAAC,WAAW,EAAE,CAAA;IAChD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { isType } from 'type-plus'\nimport { StandardLog, StandardLogForTest, StandardLogInstance, DEFAULT_LOG_METHOD_NAMES } from './index.js'\n\ndescribe('type tests', () => {\n it('export types', () => {\n isType.equal<false, void, StandardLog>()\n isType.equal<false, void, StandardLogForTest>()\n isType.equal<false, void, StandardLogInstance>()\n })\n\n it('exports DEFAULT_LOG_METHOD_NAMES', () => {\n expect(DEFAULT_LOG_METHOD_NAMES).toBeDefined()\n })\n})\n"]}
|
package/esm/logLevels.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logLevels.spec.d.ts","sourceRoot":"","sources":["../ts/logLevels.spec.ts"],"names":[],"mappings":""}
|
package/esm/logLevels.spec.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { toLogLevel } from './logLevels.js';
|
|
2
|
-
describe(`${toLogLevel.name}()`, () => {
|
|
3
|
-
it('returns undefined if value is not a default log level name', () => {
|
|
4
|
-
const result = toLogLevel('unknown');
|
|
5
|
-
expect(result).toBeUndefined();
|
|
6
|
-
});
|
|
7
|
-
});
|
|
8
|
-
//# sourceMappingURL=logLevels.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logLevels.spec.js","sourceRoot":"","sources":["../ts/logLevels.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,QAAQ,CAAC,GAAG,UAAU,CAAC,IAAI,IAAI,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;QACpC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { toLogLevel } from './logLevels.js'\n\ndescribe(`${toLogLevel.name}()`, () => {\n it('returns undefined if value is not a default log level name', () => {\n const result = toLogLevel('unknown')\n expect(result).toBeUndefined()\n })\n})\n"]}
|
package/esm/logStore.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logStore.spec.d.ts","sourceRoot":"","sources":["../ts/logStore.spec.ts"],"names":[],"mappings":""}
|
package/esm/logStore.spec.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { forEachKey } from 'type-plus';
|
|
2
|
-
import { logLevels } from './logLevels.js';
|
|
3
|
-
import { logLevelStore } from './logStore.js';
|
|
4
|
-
import { rangeEntries } from './testUtil.js';
|
|
5
|
-
describe('getName()', () => {
|
|
6
|
-
it.each([
|
|
7
|
-
...rangeEntries(99, 100, 'emergency'),
|
|
8
|
-
...rangeEntries(199, 200, 'alert'),
|
|
9
|
-
...rangeEntries(299, 300, 'critical'),
|
|
10
|
-
...rangeEntries(399, 400, 'error'),
|
|
11
|
-
...rangeEntries(499, 500, 'warn'),
|
|
12
|
-
...rangeEntries(599, 600, 'notice'),
|
|
13
|
-
...rangeEntries(699, 700, 'info'),
|
|
14
|
-
...rangeEntries(799, 800, 'debug'),
|
|
15
|
-
...rangeEntries(899, 900, 'trace'),
|
|
16
|
-
...rangeEntries(9999999, 10000000, 'planck')
|
|
17
|
-
])('convert %i to %s', (level, logLevel) => {
|
|
18
|
-
const store = logLevelStore({ customLevels: {} });
|
|
19
|
-
expect(store.getName(level)).toBe(logLevel);
|
|
20
|
-
});
|
|
21
|
-
it('gets custom log level name', () => {
|
|
22
|
-
const store = logLevelStore({ customLevels: { 'cust-name': 144 } });
|
|
23
|
-
expect(store.getName(144)).toBe('cust-name');
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('getLevel()', () => {
|
|
27
|
-
it('get default log levels', () => {
|
|
28
|
-
const store = logLevelStore({ customLevels: {} });
|
|
29
|
-
const names = [
|
|
30
|
-
'emergency',
|
|
31
|
-
'alert',
|
|
32
|
-
'critical',
|
|
33
|
-
'error',
|
|
34
|
-
'warn',
|
|
35
|
-
'notice',
|
|
36
|
-
'info',
|
|
37
|
-
'debug',
|
|
38
|
-
'trace',
|
|
39
|
-
'planck'
|
|
40
|
-
];
|
|
41
|
-
expect(names.map(n => store.getLevel(n))).toEqual([
|
|
42
|
-
100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity
|
|
43
|
-
]);
|
|
44
|
-
});
|
|
45
|
-
it('is case insensitive for default levels', () => {
|
|
46
|
-
const store = logLevelStore({ customLevels: {} });
|
|
47
|
-
const names = [
|
|
48
|
-
'emerGency',
|
|
49
|
-
'aleRt',
|
|
50
|
-
'critIcal',
|
|
51
|
-
'errOr',
|
|
52
|
-
'warN',
|
|
53
|
-
'nOtice',
|
|
54
|
-
'iNfo',
|
|
55
|
-
'deBug',
|
|
56
|
-
'traCe',
|
|
57
|
-
'planCk',
|
|
58
|
-
];
|
|
59
|
-
expect(names.map(n => store.getLevel(n))).toEqual([
|
|
60
|
-
100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity
|
|
61
|
-
]);
|
|
62
|
-
});
|
|
63
|
-
it('gets custom log level', () => {
|
|
64
|
-
const store = logLevelStore({ customLevels: { 'cust-get': 123 } });
|
|
65
|
-
expect(store.getLevel('cust-get')).toBe(123);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
describe('getAllLevels()', () => {
|
|
69
|
-
it('gets all default log levels except none and all', () => {
|
|
70
|
-
const store = logLevelStore({ customLevels: {} });
|
|
71
|
-
const actual = store.getAllLevels();
|
|
72
|
-
forEachKey(logLevels, name => {
|
|
73
|
-
if (name === 'none' || name === 'all') {
|
|
74
|
-
expect(actual.find(x => x.name === name)).toBeUndefined();
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
expect(actual.find(x => x.name === name)).toEqual({ name, level: logLevels[name] });
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
it('include custom level (even if they have the same level value as one of the default level)', () => {
|
|
82
|
-
const store = logLevelStore({
|
|
83
|
-
customLevels: {
|
|
84
|
-
'info_a': 301,
|
|
85
|
-
'info_b': logLevels.info
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
const actual = store.getAllLevels();
|
|
89
|
-
expect(actual.find(x => x.name === 'info_a')).toEqual({ name: 'info_a', level: 301 });
|
|
90
|
-
expect(actual.find(x => x.name === 'info_b')).toEqual({ name: 'info_b', level: logLevels.info });
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
//# sourceMappingURL=logStore.spec.js.map
|
package/esm/logStore.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logStore.spec.js","sourceRoot":"","sources":["../ts/logStore.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,IAAI,CAAC;QACN,GAAG,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,CAAC;QACrC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;QAClC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC;QACrC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;QAClC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC;QACjC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC;QACnC,GAAG,YAAY,CAAC,GAAG,EA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logLevels } from './logLevels.js'\nimport { logLevelStore } from './logStore.js'\nimport { rangeEntries } from './testUtil.js'\n\ndescribe('getName()', () => {\n it.each([\n ...rangeEntries(99, 100, 'emergency'),\n ...rangeEntries(199, 200, 'alert'),\n ...rangeEntries(299, 300, 'critical'),\n ...rangeEntries(399, 400, 'error'),\n ...rangeEntries(499, 500, 'warn'),\n ...rangeEntries(599, 600, 'notice'),\n ...rangeEntries(699, 700, 'info'),\n ...rangeEntries(799, 800, 'debug'),\n ...rangeEntries(899, 900, 'trace'),\n ...rangeEntries(9999999, 10000000, 'planck')\n ])('convert %i to %s', (level: number, logLevel: string) => {\n const store = logLevelStore({ customLevels: {} })\n expect(store.getName(level)).toBe(logLevel)\n })\n it('gets custom log level name', () => {\n const store = logLevelStore({ customLevels: { 'cust-name': 144 } })\n expect(store.getName(144)).toBe('cust-name')\n })\n})\n\ndescribe('getLevel()', () => {\n it('get default log levels', () => {\n const store = logLevelStore({ customLevels: {} })\n const names = [\n 'emergency',\n 'alert',\n 'critical',\n 'error',\n 'warn',\n 'notice',\n 'info',\n 'debug',\n 'trace',\n 'planck'\n ]\n expect(names.map(n => store.getLevel(n))).toEqual([\n 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity\n ])\n })\n it('is case insensitive for default levels', () => {\n const store = logLevelStore({ customLevels: {} })\n const names = [\n 'emerGency',\n 'aleRt',\n 'critIcal',\n 'errOr',\n 'warN',\n 'nOtice',\n 'iNfo',\n 'deBug',\n 'traCe',\n 'planCk',\n ]\n expect(names.map(n => store.getLevel(n))).toEqual([\n 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity\n ])\n })\n it('gets custom log level', () => {\n const store = logLevelStore({ customLevels: { 'cust-get': 123 } })\n expect(store.getLevel('cust-get')).toBe(123)\n })\n})\n\ndescribe('getAllLevels()', () => {\n it('gets all default log levels except none and all', () => {\n const store = logLevelStore({ customLevels: {} })\n const actual = store.getAllLevels()\n forEachKey(logLevels, name => {\n if (name === 'none' || name === 'all') {\n expect(actual.find(x => x.name === name)).toBeUndefined()\n }\n else {\n expect(actual.find(x => x.name === name)).toEqual({ name, level: logLevels[name] })\n }\n })\n })\n it('include custom level (even if they have the same level value as one of the default level)', () => {\n const store = logLevelStore({\n customLevels: {\n 'info_a': 301,\n 'info_b': logLevels.info\n }\n })\n const actual = store.getAllLevels()\n expect(actual.find(x => x.name === 'info_a')).toEqual({ name: 'info_a', level: 301 })\n expect(actual.find(x => x.name === 'info_b')).toEqual({ name: 'info_b', level: logLevels.info })\n })\n})\n"]}
|
package/esm/memory.spec.d.ts
DELETED
package/esm/memory.spec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.spec.d.ts","sourceRoot":"","sources":["../ts/memory.spec.ts"],"names":[],"mappings":""}
|
package/esm/memory.spec.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import a from 'assertron';
|
|
2
|
-
import { createMemoryLogReporter, logLevels } from './index.js';
|
|
3
|
-
import { assertSSF, logEntriesToString } from './testUtil.js';
|
|
4
|
-
import { filename } from 'dirname-filename-esm';
|
|
5
|
-
const mikuIsSinging = { id: 'test-log', level: logLevels.info, args: ['miku', 'is', 'singing'], timestamp: new Date() };
|
|
6
|
-
const lukaIsDancing = { id: 'test-log', level: logLevels.warn, args: ['luka', 'is', 'dancing'], timestamp: new Date() };
|
|
7
|
-
const reporter = createMemoryLogReporter();
|
|
8
|
-
describe(createMemoryLogReporter.name, () => {
|
|
9
|
-
it('filter is readonly', () => {
|
|
10
|
-
const reporter = createMemoryLogReporter();
|
|
11
|
-
const err = a.throws(() => { reporter.filter = () => true; }, err => /only a getter/.test(err));
|
|
12
|
-
assertSSF(err, filename(import.meta));
|
|
13
|
-
});
|
|
14
|
-
test('log entries are saved in the `logs` property', () => {
|
|
15
|
-
const reporter = createMemoryLogReporter();
|
|
16
|
-
const entry = { id: 'log', level: 1, args: ['some messages'], timestamp: new Date() };
|
|
17
|
-
reporter.write(entry);
|
|
18
|
-
expect(reporter.logs).toEqual([entry]);
|
|
19
|
-
});
|
|
20
|
-
test('can override id', () => {
|
|
21
|
-
const reporter = createMemoryLogReporter({ id: 'custom-id-mem' });
|
|
22
|
-
expect(reporter.id).toBe('custom-id-mem');
|
|
23
|
-
});
|
|
24
|
-
test('can filter', () => {
|
|
25
|
-
const filter = (entry) => entry.id !== 'secret';
|
|
26
|
-
const reporter = createMemoryLogReporter({ filter });
|
|
27
|
-
expect(reporter.filter).toBe(filter);
|
|
28
|
-
reporter.write({ id: 'ok', level: 1, args: ['some messages'], timestamp: new Date() });
|
|
29
|
-
reporter.write({ id: 'secret', level: 1, args: ['some messages'], timestamp: new Date() });
|
|
30
|
-
expect(reporter.logs.length).toBe(1);
|
|
31
|
-
});
|
|
32
|
-
test('formatter can be used to pre-process the log', () => {
|
|
33
|
-
const formatter = (entry) => ({
|
|
34
|
-
...entry,
|
|
35
|
-
args: entry.args.map(arg => arg === 'secret' ? '<censored>' : arg)
|
|
36
|
-
});
|
|
37
|
-
const reporter = createMemoryLogReporter({ formatter });
|
|
38
|
-
expect(reporter.formatter).toBe(formatter);
|
|
39
|
-
const entry = { id: 'log', level: 1, args: ['a', 'secret', 'b'], timestamp: new Date() };
|
|
40
|
-
reporter.write(entry);
|
|
41
|
-
expect(reporter.logs[0].args[1]).toBe('<censored>');
|
|
42
|
-
});
|
|
43
|
-
describe(reporter.getLogMessages.name, () => {
|
|
44
|
-
it('maps each log entries to string', () => {
|
|
45
|
-
const r = createMemoryLogReporter();
|
|
46
|
-
r.write(mikuIsSinging);
|
|
47
|
-
r.write(lukaIsDancing);
|
|
48
|
-
expect(r.getLogMessages()).toEqual([
|
|
49
|
-
'miku is singing',
|
|
50
|
-
'luka is dancing'
|
|
51
|
-
]);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe(reporter.getLogMessage.name, () => {
|
|
55
|
-
test('empty logs returns empty string', () => {
|
|
56
|
-
const reporter = createMemoryLogReporter();
|
|
57
|
-
expect(reporter.getLogMessage()).toEqual('');
|
|
58
|
-
});
|
|
59
|
-
test('print args', () => {
|
|
60
|
-
const reporter = createMemoryLogReporter();
|
|
61
|
-
const entry = { id: 'log', level: 1, args: ['miku', 'is', 'singing'], timestamp: new Date() };
|
|
62
|
-
reporter.write(entry);
|
|
63
|
-
expect(reporter.getLogMessage()).toEqual('miku is singing');
|
|
64
|
-
});
|
|
65
|
-
test('print object arg', () => {
|
|
66
|
-
const reporter = createMemoryLogReporter();
|
|
67
|
-
const entry = { id: 'log', level: 1, args: [{ 'miku': 'sing' }], timestamp: new Date() };
|
|
68
|
-
reporter.write(entry);
|
|
69
|
-
expect(reporter.getLogMessage()).toEqual("{ miku: 'sing' }");
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
describe(reporter.getLogMessageWithLevel.name, () => {
|
|
73
|
-
test('print with level', () => {
|
|
74
|
-
const reporter = createMemoryLogReporter();
|
|
75
|
-
reporter.write({ id: 'log', level: logLevels.info, args: ['msg 1'], timestamp: new Date() });
|
|
76
|
-
reporter.write({ id: 'log', level: logLevels.warn, args: ['msg 2'], timestamp: new Date() });
|
|
77
|
-
expect(reporter.getLogMessageWithLevel()).toEqual(`(INFO) msg 1\n(WARN) msg 2`);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe(reporter.getLogMessagesWithIdAndLevel.name, () => {
|
|
81
|
-
it('does what the name says', () => {
|
|
82
|
-
const r = createMemoryLogReporter();
|
|
83
|
-
r.write(mikuIsSinging);
|
|
84
|
-
r.write(lukaIsDancing);
|
|
85
|
-
expect(r.getLogMessagesWithIdAndLevel()).toEqual([
|
|
86
|
-
'test-log (INFO) miku is singing',
|
|
87
|
-
'test-log (WARN) luka is dancing'
|
|
88
|
-
]);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
describe(reporter.emit.name, () => {
|
|
92
|
-
it('emit saved logs to console', () => {
|
|
93
|
-
const r = createMemoryLogReporter();
|
|
94
|
-
r.write(mikuIsSinging);
|
|
95
|
-
r.write(lukaIsDancing);
|
|
96
|
-
r.write({ id: 'test-log', level: logLevels.info, args: ['the two messages above are expected'], timestamp: new Date() });
|
|
97
|
-
// inspect visually
|
|
98
|
-
r.emit();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
describe(logEntriesToString.name, () => {
|
|
103
|
-
test('convert log entries to string', () => {
|
|
104
|
-
const timestamp = new Date(2019, 6);
|
|
105
|
-
const actual = logEntriesToString([
|
|
106
|
-
{ id: 'log', level: logLevels.emergency, args: ['emergency'], timestamp },
|
|
107
|
-
{ id: 'log', level: logLevels.critical, args: ['critical'], timestamp },
|
|
108
|
-
{ id: 'log', level: logLevels.alert, args: ['alert'], timestamp },
|
|
109
|
-
{ id: 'log', level: logLevels.error, args: ['error'], timestamp },
|
|
110
|
-
{ id: 'log', level: logLevels.warn, args: ['warn'], timestamp },
|
|
111
|
-
{ id: 'log', level: logLevels.notice, args: ['notice'], timestamp },
|
|
112
|
-
{ id: 'log', level: logLevels.info, args: ['info'], timestamp },
|
|
113
|
-
{ id: 'log', level: logLevels.debug, args: ['debug'], timestamp },
|
|
114
|
-
{ id: 'log', level: logLevels.trace, args: ['trace'], timestamp }
|
|
115
|
-
]);
|
|
116
|
-
const iso = timestamp.toISOString();
|
|
117
|
-
expect(actual).toEqual(`${iso},log,(EMERGENCY),emergency
|
|
118
|
-
${iso},log,(CRITICAL),critical
|
|
119
|
-
${iso},log,(ALERT),alert
|
|
120
|
-
${iso},log,(ERROR),error
|
|
121
|
-
${iso},log,(WARN),warn
|
|
122
|
-
${iso},log,(NOTICE),notice
|
|
123
|
-
${iso},log,(INFO),info
|
|
124
|
-
${iso},log,(DEBUG),debug
|
|
125
|
-
${iso},log,(TRACE),trace`);
|
|
126
|
-
});
|
|
127
|
-
test('print out object', () => {
|
|
128
|
-
const timestamp = new Date(2021, 4);
|
|
129
|
-
const actual = logEntriesToString([
|
|
130
|
-
{ id: 'log', level: logLevels.info, args: ['a', { a: 1 }], timestamp }
|
|
131
|
-
]);
|
|
132
|
-
const iso = timestamp.toISOString();
|
|
133
|
-
expect(actual).toEqual(`${iso},log,(INFO),a,{ a: 1 }`);
|
|
134
|
-
});
|
|
135
|
-
test('print out array', () => {
|
|
136
|
-
const timestamp = new Date(2021, 4);
|
|
137
|
-
const actual = logEntriesToString([
|
|
138
|
-
{ id: 'log', level: logLevels.info, args: ['a', [1, 2, 3]], timestamp }
|
|
139
|
-
]);
|
|
140
|
-
const iso = timestamp.toISOString();
|
|
141
|
-
expect(actual).toEqual(`${iso},log,(INFO),a,[ 1, 2, 3 ]`);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
//# sourceMappingURL=memory.spec.js.map
|
package/esm/memory.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.spec.js","sourceRoot":"","sources":["../ts/memory.spec.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,EAAqC,SAAS,EAAE,MAAM,YAAY,CAAA;AAClG,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,MAAM,aAAa,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAA;AACvH,MAAM,aAAa,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAA;AACvH,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAA;AA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,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG,oBAAoB,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC5B,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnC,MAAM,MAAM,GAAG,kBAAkB,CAAC;YAChC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE;SACvE,CAAC,CAAA;QAEF,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,wBAAwB,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC3B,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnC,MAAM,MAAM,GAAG,kBAAkB,CAAC;YAChC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE;SACxE,CAAC,CAAA;QAEF,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,2BAA2B,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport { createMemoryLogReporter, LogEntry, LogFilter, LogFormatter, logLevels } from './index.js'\nimport { assertSSF, logEntriesToString } from './testUtil.js'\nimport { filename } from 'dirname-filename-esm'\n\nconst mikuIsSinging = { id: 'test-log', level: logLevels.info, args: ['miku', 'is', 'singing'], timestamp: new Date() }\nconst lukaIsDancing = { id: 'test-log', level: logLevels.warn, args: ['luka', 'is', 'dancing'], timestamp: new Date() }\nconst reporter = createMemoryLogReporter()\n\ndescribe(createMemoryLogReporter.name, () => {\n it('filter is readonly', () => {\n const reporter = createMemoryLogReporter()\n const err = a.throws(() => { (reporter as any).filter = () => true }, err => /only a getter/.test(err))\n\n assertSSF(err, filename(import.meta))\n })\n\n test('log entries are saved in the `logs` property', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: ['some messages'], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.logs).toEqual([entry])\n })\n\n test('can override id', () => {\n const reporter = createMemoryLogReporter({ id: 'custom-id-mem' })\n expect(reporter.id).toBe('custom-id-mem')\n })\n\n test('can filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n const reporter = createMemoryLogReporter({ filter })\n expect(reporter.filter).toBe(filter)\n reporter.write({ id: 'ok', level: 1, args: ['some messages'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: 1, args: ['some messages'], timestamp: new Date() })\n expect(reporter.logs.length).toBe(1)\n })\n\n test('formatter can be used to pre-process the log', () => {\n const formatter: LogFormatter<LogEntry> = (entry) => ({\n ...entry,\n args: entry.args.map(arg => arg === 'secret' ? '<censored>' : arg)\n })\n const reporter = createMemoryLogReporter({ formatter })\n expect(reporter.formatter).toBe(formatter)\n\n const entry = { id: 'log', level: 1, args: ['a', 'secret', 'b'], timestamp: new Date() }\n reporter.write(entry)\n\n expect(reporter.logs[0].args[1]).toBe('<censored>')\n })\n\n describe(reporter.getLogMessages.name, () => {\n it('maps each log entries to string', () => {\n const r = createMemoryLogReporter()\n r.write(mikuIsSinging)\n r.write(lukaIsDancing)\n expect(r.getLogMessages()).toEqual([\n 'miku is singing',\n 'luka is dancing'\n ])\n })\n })\n\n describe(reporter.getLogMessage.name, () => {\n test('empty logs returns empty string', () => {\n const reporter = createMemoryLogReporter()\n\n expect(reporter.getLogMessage()).toEqual('')\n })\n\n test('print args', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: ['miku', 'is', 'singing'], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.getLogMessage()).toEqual('miku is singing')\n })\n\n test('print object arg', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: [{ 'miku': 'sing' }], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.getLogMessage()).toEqual(\"{ miku: 'sing' }\")\n })\n })\n\n describe(reporter.getLogMessageWithLevel.name, () => {\n test('print with level', () => {\n const reporter = createMemoryLogReporter()\n reporter.write({ id: 'log', level: logLevels.info, args: ['msg 1'], timestamp: new Date() })\n reporter.write({ id: 'log', level: logLevels.warn, args: ['msg 2'], timestamp: new Date() })\n expect(reporter.getLogMessageWithLevel()).toEqual(`(INFO) msg 1\\n(WARN) msg 2`)\n })\n })\n\n describe(reporter.getLogMessagesWithIdAndLevel.name, () => {\n it('does what the name says', () => {\n const r = createMemoryLogReporter()\n r.write(mikuIsSinging)\n r.write(lukaIsDancing)\n expect(r.getLogMessagesWithIdAndLevel()).toEqual([\n 'test-log (INFO) miku is singing',\n 'test-log (WARN) luka is dancing'\n ])\n })\n })\n\n describe(reporter.emit.name, () => {\n it('emit saved logs to console', () => {\n const r = createMemoryLogReporter()\n r.write(mikuIsSinging)\n r.write(lukaIsDancing)\n r.write({ id: 'test-log', level: logLevels.info, args: ['the two messages above are expected'], timestamp: new Date() })\n\n // inspect visually\n r.emit()\n })\n })\n})\n\ndescribe(logEntriesToString.name, () => {\n test('convert log entries to string', () => {\n const timestamp = new Date(2019, 6)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.emergency, args: ['emergency'], timestamp },\n { id: 'log', level: logLevels.critical, args: ['critical'], timestamp },\n { id: 'log', level: logLevels.alert, args: ['alert'], timestamp },\n { id: 'log', level: logLevels.error, args: ['error'], timestamp },\n { id: 'log', level: logLevels.warn, args: ['warn'], timestamp },\n { id: 'log', level: logLevels.notice, args: ['notice'], timestamp },\n { id: 'log', level: logLevels.info, args: ['info'], timestamp },\n { id: 'log', level: logLevels.debug, args: ['debug'], timestamp },\n { id: 'log', level: logLevels.trace, args: ['trace'], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(EMERGENCY),emergency\n${iso},log,(CRITICAL),critical\n${iso},log,(ALERT),alert\n${iso},log,(ERROR),error\n${iso},log,(WARN),warn\n${iso},log,(NOTICE),notice\n${iso},log,(INFO),info\n${iso},log,(DEBUG),debug\n${iso},log,(TRACE),trace`)\n })\n\n test('print out object', () => {\n const timestamp = new Date(2021, 4)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.info, args: ['a', { a: 1 }], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(INFO),a,{ a: 1 }`)\n })\n\n test('print out array', () => {\n const timestamp = new Date(2021, 4)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.info, args: ['a', [1, 2, 3]], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(INFO),a,[ 1, 2, 3 ]`)\n })\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standardLog.spec.d.ts","sourceRoot":"","sources":["../ts/standardLog.spec.ts"],"names":[],"mappings":""}
|