standard-log 12.1.0 → 12.1.2

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.
@@ -1,8 +1,16 @@
1
1
  import { type MemoryLogReporter } from './memory.js';
2
2
  import { type StandardLog } from './standard_log.js';
3
3
  import type { LogMethodNames, StandardLogOptions } from './types.js';
4
+ export type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {
5
+ /**
6
+ * Send the logs to console for easy debugging.
7
+ *
8
+ * @default false
9
+ */
10
+ emitLog?: boolean;
11
+ };
4
12
  export type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
5
13
  reporter: MemoryLogReporter;
6
14
  };
7
- export declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLogForTest<N>;
8
- //# sourceMappingURL=standard_log.mocks.d.ts.map
15
+ export declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogForTestOptions<N>): StandardLogForTest<N>;
16
+ //# sourceMappingURL=standard_log.testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard_log.testing.d.ts","sourceRoot":"","sources":["../ts/standard_log.testing.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpE,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAClG;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACpF,QAAQ,EAAE,iBAAiB,CAAA;CAC3B,CAAA;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EACzE,OAAO,GAAE,yBAAyB,CAAC,CAAC,CAAM,GACxC,kBAAkB,CAAC,CAAC,CAAC,CAiBvB"}
@@ -1,3 +1,4 @@
1
+ import { createConsoleLogReporter } from './console.js';
1
2
  import { logLevels } from './log_levels.js';
2
3
  import { createMemoryLogReporter } from './memory.js';
3
4
  import { createStandardLogClosure } from './standard_log.js';
@@ -5,6 +6,11 @@ export function createStandardLogForTest(options = {}) {
5
6
  var _a, _b;
6
7
  options.logLevel = (_a = options.logLevel) !== null && _a !== void 0 ? _a : logLevels.debug;
7
8
  options.reporters = (_b = options.reporters) !== null && _b !== void 0 ? _b : [];
9
+ if (options.emitLog && !options.reporters.some(r => r.isConsoleReporter)) {
10
+ // this is used for debugging,
11
+ // so no need to use color reporter.
12
+ options.reporters.push(createConsoleLogReporter());
13
+ }
8
14
  const existingReporter = options.reporters.find(r => r.id === 'memory');
9
15
  const reporter = existingReporter !== null && existingReporter !== void 0 ? existingReporter : createMemoryLogReporter();
10
16
  if (!existingReporter) {
@@ -13,4 +19,4 @@ export function createStandardLogForTest(options = {}) {
13
19
  const closure = createStandardLogClosure(options);
14
20
  return { ...closure.standardLog, reporter };
15
21
  }
16
- //# sourceMappingURL=standard_log.mocks.js.map
22
+ //# sourceMappingURL=standard_log.testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard_log.testing.js","sourceRoot":"","sources":["../ts/standard_log.testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,uBAAuB,EAA0B,MAAM,aAAa,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAoB,MAAM,mBAAmB,CAAA;AAgB9E,MAAM,UAAU,wBAAwB,CACvC,UAAwC,EAAE;;IAE1C,OAAO,CAAC,QAAQ,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,SAAS,CAAC,KAAK,CAAA;IACtD,OAAO,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,EAAE,CAAA;IAE3C,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE;QACzE,8BAA8B;QAC9B,oCAAoC;QACpC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAA;KAClD;IAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAsB,CAAA;IAC5F,MAAM,QAAQ,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,uBAAuB,EAAE,CAAA;IAC9D,IAAI,CAAC,gBAAgB,EAAE;QACtB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,GAAG,wBAAwB,CAAI,OAAO,CAAC,CAAA;IACpD,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAA;AAC5C,CAAC","sourcesContent":["import { createConsoleLogReporter } from './console.js'\nimport { logLevels } from './log_levels.js'\nimport { createMemoryLogReporter, type MemoryLogReporter } from './memory.js'\nimport { createStandardLogClosure, type StandardLog } from './standard_log.js'\nimport type { LogMethodNames, StandardLogOptions } from './types.js'\n\nexport type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {\n\t/**\n\t * Send the logs to console for easy debugging.\n\t *\n\t * @default false\n\t */\n\temitLog?: boolean\n}\n\nexport type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {\n\treporter: MemoryLogReporter\n}\n\nexport function createStandardLogForTest<N extends string = LogMethodNames>(\n\toptions: StandardLogForTestOptions<N> = {}\n): StandardLogForTest<N> {\n\toptions.logLevel = options.logLevel ?? logLevels.debug\n\toptions.reporters = options.reporters ?? []\n\n\tif (options.emitLog && !options.reporters.some(r => r.isConsoleReporter)) {\n\t\t// this is used for debugging,\n\t\t// so no need to use color reporter.\n\t\toptions.reporters.push(createConsoleLogReporter())\n\t}\n\n\tconst existingReporter = options.reporters.find(r => r.id === 'memory') as MemoryLogReporter\n\tconst reporter = existingReporter ?? createMemoryLogReporter()\n\tif (!existingReporter) {\n\t\toptions.reporters.push(reporter)\n\t}\n\tconst closure = createStandardLogClosure<N>(options)\n\treturn { ...closure.standardLog, reporter }\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  export { type MemoryLogReporter } from '../memory.js';
2
- export { createStandardLogForTest, type StandardLogForTest } from '../standard_log.mocks.js';
2
+ export { createStandardLogForTest, type StandardLogForTestOptions, type StandardLogForTest } from '../standard_log.testing.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,wBAAwB,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EACN,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,MAAM,4BAA4B,CAAA"}
@@ -1,2 +1,2 @@
1
- export { createStandardLogForTest } from '../standard_log.mocks.js';
1
+ export { createStandardLogForTest } from '../standard_log.testing.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAA2B,MAAM,0BAA0B,CAAA","sourcesContent":["export { type MemoryLogReporter } from '../memory.js'\nexport { createStandardLogForTest, type StandardLogForTest } from '../standard_log.mocks.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,wBAAwB,EAGxB,MAAM,4BAA4B,CAAA","sourcesContent":["export { type MemoryLogReporter } from '../memory.js'\nexport {\n\tcreateStandardLogForTest,\n\ttype StandardLogForTestOptions,\n\ttype StandardLogForTest\n} from '../standard_log.testing.js'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "standard-log",
3
- "version": "12.1.0",
3
+ "version": "12.1.2",
4
4
  "description": "The standard log library",
5
5
  "homepage": "https://github.com/unional/standard-log/tree/main/packages/log",
6
6
  "bugs": {
@@ -61,7 +61,7 @@
61
61
  "@just-func/types": "^0.5.0",
62
62
  "iso-error": "^6.0.0",
63
63
  "ms": "^2.1.3",
64
- "type-plus": "^6.5.0",
64
+ "type-plus": "^7.0.0",
65
65
  "upper-case": "^2.0.2"
66
66
  },
67
67
  "devDependencies": {
@@ -130,6 +130,7 @@
130
130
  "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
131
131
  "test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch",
132
132
  "verify": "npm-run-all -p build depcheck lint coverage -p size",
133
- "watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch"
133
+ "watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch",
134
+ "w": "pnpm watch"
134
135
  }
135
136
  }
@@ -1,17 +1,34 @@
1
+ import { createConsoleLogReporter } from './console.js'
1
2
  import { logLevels } from './log_levels.js'
2
3
  import { createMemoryLogReporter, type MemoryLogReporter } from './memory.js'
3
4
  import { createStandardLogClosure, type StandardLog } from './standard_log.js'
4
5
  import type { LogMethodNames, StandardLogOptions } from './types.js'
5
6
 
7
+ export type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {
8
+ /**
9
+ * Send the logs to console for easy debugging.
10
+ *
11
+ * @default false
12
+ */
13
+ emitLog?: boolean
14
+ }
15
+
6
16
  export type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
7
17
  reporter: MemoryLogReporter
8
18
  }
9
19
 
10
20
  export function createStandardLogForTest<N extends string = LogMethodNames>(
11
- options: StandardLogOptions<N> = {}
21
+ options: StandardLogForTestOptions<N> = {}
12
22
  ): StandardLogForTest<N> {
13
23
  options.logLevel = options.logLevel ?? logLevels.debug
14
24
  options.reporters = options.reporters ?? []
25
+
26
+ if (options.emitLog && !options.reporters.some(r => r.isConsoleReporter)) {
27
+ // this is used for debugging,
28
+ // so no need to use color reporter.
29
+ options.reporters.push(createConsoleLogReporter())
30
+ }
31
+
15
32
  const existingReporter = options.reporters.find(r => r.id === 'memory') as MemoryLogReporter
16
33
  const reporter = existingReporter ?? createMemoryLogReporter()
17
34
  if (!existingReporter) {
@@ -1,2 +1,6 @@
1
1
  export { type MemoryLogReporter } from '../memory.js'
2
- export { createStandardLogForTest, type StandardLogForTest } from '../standard_log.mocks.js'
2
+ export {
3
+ createStandardLogForTest,
4
+ type StandardLogForTestOptions,
5
+ type StandardLogForTest
6
+ } from '../standard_log.testing.js'
@@ -1 +0,0 @@
1
- {"version":3,"file":"standard_log.mocks.d.ts","sourceRoot":"","sources":["../ts/standard_log.mocks.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACpF,QAAQ,EAAE,iBAAiB,CAAA;CAC3B,CAAA;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EACzE,OAAO,GAAE,kBAAkB,CAAC,CAAC,CAAM,GACjC,kBAAkB,CAAC,CAAC,CAAC,CAUvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"standard_log.mocks.js","sourceRoot":"","sources":["../ts/standard_log.mocks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAA2C;AAC3C,yCAA6E;AAC7E,qDAA8E;AAO9E,SAAgB,wBAAwB,CACvC,OAAmC;;IAAnC,wBAAA,EAAA,YAAmC;IAEnC,OAAO,CAAC,QAAQ,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,yBAAS,CAAC,KAAK,CAAA;IACtD,OAAO,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,EAAE,CAAA;IAC3C,IAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAjB,CAAiB,CAAsB,CAAA;IAC5F,IAAM,QAAQ,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,IAAA,mCAAuB,GAAE,CAAA;IAC9D,IAAI,CAAC,gBAAgB,EAAE;QACtB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KAChC;IACD,IAAM,OAAO,GAAG,IAAA,0CAAwB,EAAI,OAAO,CAAC,CAAA;IACpD,6BAAY,OAAO,CAAC,WAAW,KAAE,QAAQ,UAAA,IAAE;AAC5C,CAAC;AAZD,4DAYC","sourcesContent":["import { logLevels } from './log_levels.js'\nimport { createMemoryLogReporter, type MemoryLogReporter } from './memory.js'\nimport { createStandardLogClosure, type StandardLog } from './standard_log.js'\nimport type { LogMethodNames, StandardLogOptions } from './types.js'\n\nexport type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {\n\treporter: MemoryLogReporter\n}\n\nexport function createStandardLogForTest<N extends string = LogMethodNames>(\n\toptions: StandardLogOptions<N> = {}\n): StandardLogForTest<N> {\n\toptions.logLevel = options.logLevel ?? logLevels.debug\n\toptions.reporters = options.reporters ?? []\n\tconst existingReporter = options.reporters.find(r => r.id === 'memory') as MemoryLogReporter\n\tconst reporter = existingReporter ?? createMemoryLogReporter()\n\tif (!existingReporter) {\n\t\toptions.reporters.push(reporter)\n\t}\n\tconst closure = createStandardLogClosure<N>(options)\n\treturn { ...closure.standardLog, reporter }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"standard_log.mocks.d.ts","sourceRoot":"","sources":["../ts/standard_log.mocks.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACpF,QAAQ,EAAE,iBAAiB,CAAA;CAC3B,CAAA;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EACzE,OAAO,GAAE,kBAAkB,CAAC,CAAC,CAAM,GACjC,kBAAkB,CAAC,CAAC,CAAC,CAUvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"standard_log.mocks.js","sourceRoot":"","sources":["../ts/standard_log.mocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,uBAAuB,EAA0B,MAAM,aAAa,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAoB,MAAM,mBAAmB,CAAA;AAO9E,MAAM,UAAU,wBAAwB,CACvC,UAAiC,EAAE;;IAEnC,OAAO,CAAC,QAAQ,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,SAAS,CAAC,KAAK,CAAA;IACtD,OAAO,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,EAAE,CAAA;IAC3C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAsB,CAAA;IAC5F,MAAM,QAAQ,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,uBAAuB,EAAE,CAAA;IAC9D,IAAI,CAAC,gBAAgB,EAAE;QACtB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,GAAG,wBAAwB,CAAI,OAAO,CAAC,CAAA;IACpD,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAA;AAC5C,CAAC","sourcesContent":["import { logLevels } from './log_levels.js'\nimport { createMemoryLogReporter, type MemoryLogReporter } from './memory.js'\nimport { createStandardLogClosure, type StandardLog } from './standard_log.js'\nimport type { LogMethodNames, StandardLogOptions } from './types.js'\n\nexport type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {\n\treporter: MemoryLogReporter\n}\n\nexport function createStandardLogForTest<N extends string = LogMethodNames>(\n\toptions: StandardLogOptions<N> = {}\n): StandardLogForTest<N> {\n\toptions.logLevel = options.logLevel ?? logLevels.debug\n\toptions.reporters = options.reporters ?? []\n\tconst existingReporter = options.reporters.find(r => r.id === 'memory') as MemoryLogReporter\n\tconst reporter = existingReporter ?? createMemoryLogReporter()\n\tif (!existingReporter) {\n\t\toptions.reporters.push(reporter)\n\t}\n\tconst closure = createStandardLogClosure<N>(options)\n\treturn { ...closure.standardLog, reporter }\n}\n"]}