standard-log 12.1.2 → 13.0.1

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.
Files changed (144) hide show
  1. package/README.md +8 -8
  2. package/cjs/_virtual/_rolldown/runtime.js +23 -0
  3. package/cjs/console.d.ts +10 -7
  4. package/cjs/console.d.ts.map +1 -1
  5. package/cjs/console.js +53 -71
  6. package/cjs/console.js.map +1 -1
  7. package/cjs/errors.d.ts +9 -6
  8. package/cjs/errors.d.ts.map +1 -1
  9. package/cjs/errors.js +22 -45
  10. package/cjs/errors.js.map +1 -1
  11. package/cjs/formatter.d.ts +9 -6
  12. package/cjs/formatter.d.ts.map +1 -1
  13. package/cjs/formatter.js +41 -50
  14. package/cjs/formatter.js.map +1 -1
  15. package/cjs/index.d.ts +8 -9
  16. package/cjs/index.js +26 -28
  17. package/cjs/log_levels.d.ts +76 -73
  18. package/cjs/log_levels.d.ts.map +1 -1
  19. package/cjs/log_levels.js +104 -110
  20. package/cjs/log_levels.js.map +1 -1
  21. package/cjs/log_store.d.ts +20 -17
  22. package/cjs/log_store.d.ts.map +1 -1
  23. package/cjs/log_store.js +43 -39
  24. package/cjs/log_store.js.map +1 -1
  25. package/cjs/logger.d.ts +6 -3
  26. package/cjs/logger.d.ts.map +1 -1
  27. package/cjs/logger.js +66 -88
  28. package/cjs/logger.js.map +1 -1
  29. package/cjs/memory.d.ts +20 -17
  30. package/cjs/memory.d.ts.map +1 -1
  31. package/cjs/memory.js +54 -64
  32. package/cjs/memory.js.map +1 -1
  33. package/cjs/platform.browser.d.ts +7 -4
  34. package/cjs/platform.browser.d.ts.map +1 -1
  35. package/cjs/platform.browser.js +8 -6
  36. package/cjs/platform.browser.js.map +1 -1
  37. package/cjs/platform.d.ts +7 -4
  38. package/cjs/platform.d.ts.map +1 -1
  39. package/cjs/platform.js +9 -7
  40. package/cjs/platform.js.map +1 -1
  41. package/cjs/standard_log.ctx.d.ts +11 -8
  42. package/cjs/standard_log.ctx.d.ts.map +1 -1
  43. package/cjs/standard_log.ctx.js +6 -5
  44. package/cjs/standard_log.ctx.js.map +1 -1
  45. package/cjs/standard_log.d.ts +14 -12
  46. package/cjs/standard_log.d.ts.map +1 -1
  47. package/cjs/standard_log.js +83 -112
  48. package/cjs/standard_log.js.map +1 -1
  49. package/cjs/standard_log.testing.d.ts +16 -13
  50. package/cjs/standard_log.testing.d.ts.map +1 -1
  51. package/cjs/standard_log.testing.js +19 -35
  52. package/cjs/standard_log.testing.js.map +1 -1
  53. package/cjs/testing/index.d.ts +3 -3
  54. package/cjs/testing/index.js +3 -6
  55. package/cjs/types.d.ts +125 -124
  56. package/cjs/types.d.ts.map +1 -1
  57. package/cjs/types.js +0 -3
  58. package/dist/standard-log.esm.js +873 -1430
  59. package/dist/standard-log.esm.js.map +1 -1
  60. package/dist/standard-log.iife.js +952 -0
  61. package/dist/standard-log.iife.js.map +1 -0
  62. package/esm/console.d.ts +10 -7
  63. package/esm/console.d.ts.map +1 -1
  64. package/esm/console.js +54 -64
  65. package/esm/console.js.map +1 -1
  66. package/esm/errors.d.ts +9 -6
  67. package/esm/errors.d.ts.map +1 -1
  68. package/esm/errors.js +21 -21
  69. package/esm/errors.js.map +1 -1
  70. package/esm/formatter.d.ts +9 -6
  71. package/esm/formatter.d.ts.map +1 -1
  72. package/esm/formatter.js +38 -32
  73. package/esm/formatter.js.map +1 -1
  74. package/esm/index.d.ts +8 -9
  75. package/esm/index.js +7 -7
  76. package/esm/log_levels.d.ts +76 -73
  77. package/esm/log_levels.d.ts.map +1 -1
  78. package/esm/log_levels.js +102 -107
  79. package/esm/log_levels.js.map +1 -1
  80. package/esm/log_store.d.ts +20 -17
  81. package/esm/log_store.d.ts.map +1 -1
  82. package/esm/log_store.js +44 -37
  83. package/esm/log_store.js.map +1 -1
  84. package/esm/logger.d.ts +6 -3
  85. package/esm/logger.d.ts.map +1 -1
  86. package/esm/logger.js +66 -65
  87. package/esm/logger.js.map +1 -1
  88. package/esm/memory.d.ts +20 -17
  89. package/esm/memory.d.ts.map +1 -1
  90. package/esm/memory.js +55 -62
  91. package/esm/memory.js.map +1 -1
  92. package/esm/platform.browser.d.ts +7 -4
  93. package/esm/platform.browser.d.ts.map +1 -1
  94. package/esm/platform.browser.js +7 -3
  95. package/esm/platform.browser.js.map +1 -1
  96. package/esm/platform.d.ts +7 -4
  97. package/esm/platform.d.ts.map +1 -1
  98. package/esm/platform.js +8 -4
  99. package/esm/platform.js.map +1 -1
  100. package/esm/standard_log.ctx.d.ts +11 -8
  101. package/esm/standard_log.ctx.d.ts.map +1 -1
  102. package/esm/standard_log.ctx.js +6 -2
  103. package/esm/standard_log.ctx.js.map +1 -1
  104. package/esm/standard_log.d.ts +14 -12
  105. package/esm/standard_log.d.ts.map +1 -1
  106. package/esm/standard_log.js +83 -98
  107. package/esm/standard_log.js.map +1 -1
  108. package/esm/standard_log.testing.d.ts +16 -13
  109. package/esm/standard_log.testing.d.ts.map +1 -1
  110. package/esm/standard_log.testing.js +19 -20
  111. package/esm/standard_log.testing.js.map +1 -1
  112. package/esm/testing/index.d.ts +3 -3
  113. package/esm/testing/index.js +2 -2
  114. package/esm/types.d.ts +125 -124
  115. package/esm/types.d.ts.map +1 -1
  116. package/esm/types.js +0 -1
  117. package/package.json +21 -67
  118. package/ts/console.ts +7 -8
  119. package/ts/errors.ts +5 -2
  120. package/ts/formatter.ts +1 -2
  121. package/ts/index.ts +3 -3
  122. package/ts/log_levels.ts +2 -2
  123. package/ts/logger.ts +14 -7
  124. package/ts/memory.ts +3 -5
  125. package/ts/platform.ts +1 -1
  126. package/ts/standard_log.ts +2 -2
  127. package/ts/testing/index.ts +3 -3
  128. package/ts/types.ts +1 -1
  129. package/cjs/index.d.ts.map +0 -1
  130. package/cjs/index.js.map +0 -1
  131. package/cjs/testing/index.d.ts.map +0 -1
  132. package/cjs/testing/index.js.map +0 -1
  133. package/cjs/types.js.map +0 -1
  134. package/dist/standard-log.es5.js +0 -10184
  135. package/dist/standard-log.es5.js.gz +0 -0
  136. package/dist/standard-log.es5.js.map +0 -1
  137. package/dist/standard-log.es5.js.map.gz +0 -0
  138. package/dist/standard-log.esm.js.gz +0 -0
  139. package/dist/standard-log.esm.js.map.gz +0 -0
  140. package/esm/index.d.ts.map +0 -1
  141. package/esm/index.js.map +0 -1
  142. package/esm/testing/index.d.ts.map +0 -1
  143. package/esm/testing/index.js.map +0 -1
  144. package/esm/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,MAAM,MAAM,kBAAkB,CAAC,gBAAgB,SAAS,MAAM,GAAG,cAAc,IAAI;IAClF;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAA;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAA;CACtC;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI;IACvD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC3B,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAAA;IACrD;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;CAC5B,GAAG;KAAG,CAAC,IAAI,CAAC,GAAG,SAAS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C;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;UAGI,sBAAsB;EACtC;EACA,UAAU,cAAc;;KAGb,OAAO,mBAAmB;WAC5B;;;;EAIT;;;;;EAKA,SAAS;EACT,GAAG,gBAAgB,GAAG,aAAa;;;;EAInC,MAAM,OAAO;OACP,KAAK,IAAI;;;;KAKJ;KAYA;EACX;EACA;EAEA;EACA,WAAW;;KAGA,gBAAgB;KAEhB,eAAe,KAAK,WAAW;KAE/B,0BAA0B,WAAW;UAEhC,oBAAoB,mBAAmB;;;;EAIvD;;;;EAIA,eAAe;;;;EAIf,WAAW,MAAM;;;;;;;;;;EAUjB,UAAU,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;;;;;;EAY3D,oBAAoB,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;KAQ1D,aAAa,cAAc,OAAO,aAAa;;;;KAK/C,aAAa,OAAO;KAEpB;EAAkB;EAAc;;UAE3B,YAAY;WACnB;;;;;WAKA,WAAW,aAAa;;;;WAIxB,SAAS;;;;;WAKT;EACT,MAAM,OAAO;;KAGF,mBAAmB;EAC9B;;;;;EAKA,YAAY,aAAa;;;;EAIzB,SAAS;;KAGE;UAEK;EAChB,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,SAAS"}
package/esm/types.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "standard-log",
3
- "version": "12.1.2",
3
+ "version": "13.0.1",
4
4
  "description": "The standard log library",
5
- "homepage": "https://github.com/unional/standard-log/tree/main/packages/log",
5
+ "homepage": "https://github.com/cyberuni/standard-log/tree/main/packages/log",
6
6
  "bugs": {
7
- "url": "https://github.com/unional/standard-log/issues"
7
+ "url": "https://github.com/cyberuni/standard-log/issues"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/unional/standard-log.git"
11
+ "url": "https://github.com/cyberuni/standard-log.git"
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": {
@@ -61,76 +61,30 @@
61
61
  "@just-func/types": "^0.5.0",
62
62
  "iso-error": "^6.0.0",
63
63
  "ms": "^2.1.3",
64
- "type-plus": "^7.0.0",
65
- "upper-case": "^2.0.2"
64
+ "type-plus": "^7.0.0"
66
65
  },
67
66
  "devDependencies": {
68
- "@repobuddy/jest": "^3.0.0",
69
- "@size-limit/preset-small-lib": "^8.1.0",
70
- "@types/jest": "^29.1.1",
71
- "@types/ms": "^0.7.31",
72
- "@types/node": "^18.0.0",
73
- "@types/ramda": "^0.29.0",
67
+ "@repobuddy/vitest": "^2.1.1",
68
+ "@types/ms": "^2.0.0",
69
+ "@types/node": "^24.0.0",
70
+ "@types/ramda": "^0.32.0",
74
71
  "assertron": "^11.0.0",
75
- "compression-webpack-plugin": "^10.0.0",
76
- "cross-env": "^7.0.3",
77
72
  "depcheck": "^1.4.3",
78
73
  "dirname-filename-esm": "^1.1.1",
79
- "eslint": "^8.24.0",
80
- "jest": "^29.1.2",
81
- "jest-validate": "^29.1.2",
82
- "jest-watch-suspend": "^1.1.2",
83
- "jest-watch-toggle-config-2": "^2.1.0",
84
- "jest-watch-typeahead": "^2.2.0",
85
- "ncp": "^2.0.0",
86
- "npm-run-all": "^4.1.5",
87
- "param-case": "^3.0.4",
88
- "pascal-case": "^3.1.2",
89
- "ramda": "^0.29.0",
90
- "rimraf": "^5.0.0",
91
- "size-limit": "^8.1.0",
92
- "ts-jest": "^29.0.3",
93
- "ts-loader": "^9.4.1",
94
- "tslib": "^2.4.0",
95
- "typescript": "^5.0.0",
96
- "webpack": "^5.74.0",
97
- "webpack-bundle-analyzer": "^4.6.1",
98
- "webpack-cli": "^5.0.0"
74
+ "ramda": "^0.32.0",
75
+ "rimraf": "^6.0.0",
76
+ "tsdown": "^0.22.14",
77
+ "typescript": "^7.0.2",
78
+ "vitest": "^4.1.0"
99
79
  },
100
- "size-limit": [
101
- {
102
- "path": "./cjs/index.js",
103
- "limit": "20 kB"
104
- },
105
- {
106
- "path": "./esm/index.js",
107
- "limit": "10 kB"
108
- },
109
- {
110
- "path": "./tslib/index.js",
111
- "limit": "20 kB"
112
- }
113
- ],
114
80
  "scripts": {
115
- "build": "run-p build:cjs build:esm build:tslib bundle:es5 bundle:esm",
116
- "build:clean": "rimraf *.tsbuildinfo",
117
- "build:cjs": "tsc -p ./tsconfig.cjs.json && ncp package.cjs.json cjs/package.json",
118
- "build:esm": "tsc -p ./tsconfig.esm.json",
119
- "build:tslib": "tsc -p ./tsconfig.tslib.json && ncp package.cjs.json tslib/package.json",
120
- "bundle": "run-p bundle:es5 bundle:esm",
121
- "bundle:es5": "webpack -c ./webpack.es5.cjs",
122
- "bundle:esm": "webpack -c ./webpack.esm.cjs",
123
- "clean": "rimraf cjs coverage dist esm lib libm tslib --glob *.tsbuildinfo",
124
- "coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
81
+ "build": "tsdown",
82
+ "clean": "rimraf cjs coverage dist esm --glob *.tsbuildinfo",
83
+ "coverage": "vitest run --coverage",
125
84
  "depcheck": "depcheck",
126
- "lint": "cross-env TIMING=1 eslint --ext=ts,js,cjs,mjs .",
127
- "nuke": "run-s clean nuke:local",
128
- "nuke:local": "rimraf node_modules",
129
- "size": "size-limit",
130
- "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
131
- "test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch",
132
- "verify": "npm-run-all -p build depcheck lint coverage -p size",
133
- "watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch",
134
- "w": "pnpm watch"
85
+ "nuke": "pnpm clean && rimraf node_modules",
86
+ "test": "vitest run",
87
+ "typecheck": "tsc",
88
+ "w": "vitest"
135
89
  }
136
90
  }
package/ts/console.ts CHANGED
@@ -34,19 +34,18 @@ function buildPolyfillConsole() {
34
34
  warn: (typeof console.warn === 'function' ? console.warn : console.log).bind(console),
35
35
  error: (typeof console.error === 'function' ? console.error : console.log).bind(console)
36
36
  }
37
- } else {
38
- return {
39
- debug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),
40
- info: buildFn(typeof console.info === 'function' ? 'info' : 'log'),
41
- warn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),
42
- error: buildFn(typeof console.error === 'function' ? 'error' : 'log')
43
- }
37
+ }
38
+ return {
39
+ debug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),
40
+ info: buildFn(typeof console.info === 'function' ? 'info' : 'log'),
41
+ warn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),
42
+ error: buildFn(typeof console.error === 'function' ? 'error' : 'log')
44
43
  }
45
44
  }
46
45
 
47
46
  // istanbul ignore next
48
47
  function buildFn(name: 'debug' | 'info' | 'warn' | 'error' | 'log') {
49
- return function (...args: any[]) {
48
+ return (...args: any[]) => {
50
49
  console[name](...args)
51
50
  }
52
51
  }
package/ts/errors.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IsoError, ModuleError } from 'iso-error'
1
+ import { type IsoError, ModuleError } from 'iso-error'
2
2
 
3
3
  /**
4
4
  * @deprecated No longer used since 11.2.0
@@ -13,7 +13,10 @@ export class StandardLogError extends ModuleError {
13
13
  * @deprecated no longer used since 11.2.0
14
14
  */
15
15
  export class InvalidId extends StandardLogError {
16
- constructor(public id: string, options?: IsoError.Options) {
16
+ constructor(
17
+ public id: string,
18
+ options?: IsoError.Options
19
+ ) {
17
20
  super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options)
18
21
  }
19
22
  }
package/ts/formatter.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import ms from 'ms'
2
- import { upperCase } from 'upper-case'
3
2
  import { toLogLevelName } from './log_levels.js'
4
3
  import type { LogEntry } from './types.js'
5
4
 
@@ -24,7 +23,7 @@ export function createTimestampFormatter(format: TimestampFormat): (timestamp: D
24
23
  }
25
24
 
26
25
  export function formatLogLevel(level: number) {
27
- return `(${upperCase(toLogLevelName(level))})`
26
+ return `(${toLogLevelName(level).toUpperCase()})`
28
27
  }
29
28
 
30
29
  /**
package/ts/index.ts CHANGED
@@ -3,22 +3,22 @@ export * from './errors.js'
3
3
  export * from './formatter.js'
4
4
  export * from './log_levels.js'
5
5
  export * from './memory.js'
6
- export { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js'
7
6
  export type { GetLogger, StandardLog } from './standard_log.js'
7
+ export { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js'
8
8
  export type {
9
9
  ConsoleLike,
10
10
  LogEntry,
11
11
  LogFilter,
12
12
  LogFormatter,
13
13
  LogFunction,
14
+ Logger,
15
+ LoggerOptions,
14
16
  LogLevel,
15
17
  LogLevelEntry,
16
18
  LogMethod,
17
19
  LogMethodNames,
18
20
  LogReporter,
19
21
  LogReporterOptions,
20
- Logger,
21
- LoggerOptions,
22
22
  ReporterFilter,
23
23
  StandardLogInstance,
24
24
  StandardLogOptions
package/ts/log_levels.ts CHANGED
@@ -63,11 +63,11 @@ export const logLevels = {
63
63
  *
64
64
  * trace -> planck
65
65
  */
66
- planck: Infinity,
66
+ planck: Number.POSITIVE_INFINITY,
67
67
  /**
68
68
  * all: Infinity
69
69
  */
70
- all: Infinity
70
+ all: Number.POSITIVE_INFINITY
71
71
  }
72
72
 
73
73
  /**
package/ts/logger.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  import { logLevels } from './log_levels.js'
2
- import { LogStore } from './log_store.js'
3
- import type { LogEntry, LogFunction, Logger, LoggerOptions, LogMethodNames, LogReporter } from './types.js'
4
- import { LogLevel } from './types.js'
2
+ import type { LogStore } from './log_store.js'
3
+ import type {
4
+ LogEntry,
5
+ LogFunction,
6
+ Logger,
7
+ LoggerOptions,
8
+ LogLevel,
9
+ LogMethodNames,
10
+ LogReporter
11
+ } from './types.js'
5
12
 
6
13
  export function createLogger<N extends string = LogMethodNames>(
7
14
  store: LogStore,
@@ -14,10 +21,10 @@ export function createLogger<N extends string = LogMethodNames>(
14
21
  typeof writeTo === 'string'
15
22
  ? [id => id === writeTo, store.reporters]
16
23
  : writeTo instanceof RegExp
17
- ? [id => writeTo.test(id), store.reporters]
18
- : typeof writeTo === 'function'
19
- ? [writeTo, store.reporters]
20
- : [() => true, [writeTo]]
24
+ ? [id => writeTo.test(id), store.reporters]
25
+ : typeof writeTo === 'function'
26
+ ? [writeTo, store.reporters]
27
+ : [() => true, [writeTo]]
21
28
 
22
29
  function write(entry: LogEntry) {
23
30
  writeToReporters(reporters, entry, filter)
package/ts/memory.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { required, unpartial } from 'type-plus'
2
- import { toInspectLogEntry } from './platform.js'
2
+ import { createConsoleLogReporter } from './console.js'
3
3
  import { formatLogLevel } from './formatter.js'
4
+ import { toInspectLogEntry } from './platform.js'
4
5
  import type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'
5
- import { createConsoleLogReporter } from './console.js'
6
6
 
7
7
  export type MemoryLogReporter = LogReporter<LogEntry> & {
8
8
  logs: LogEntry[]
@@ -60,9 +60,7 @@ function buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {
60
60
  return logs.map(toInspectLogEntry).map(log => log.args.join(' '))
61
61
  },
62
62
  getLogMessagesWithLevel() {
63
- return logs
64
- .map(toInspectLogEntry)
65
- .map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)
63
+ return logs.map(toInspectLogEntry).map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)
66
64
  },
67
65
  getLogMessagesWithIdAndLevel() {
68
66
  return logs
package/ts/platform.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { inspect } from 'node:util'
1
2
  import { record } from 'type-plus'
2
- import { inspect } from 'util'
3
3
  import type { ConsoleLike, LogEntry } from './types.js'
4
4
 
5
5
  export const toInspectLogEntry = (e: LogEntry) => (
@@ -4,9 +4,9 @@ import { createLogStore, type LogStore } from './log_store.js'
4
4
  import { createLogger } from './logger.js'
5
5
  import { ctx } from './standard_log.ctx.js'
6
6
  import type {
7
- LogMethodNames,
8
7
  Logger,
9
8
  LoggerOptions,
9
+ LogMethodNames,
10
10
  StandardLogInstance,
11
11
  StandardLogOptions
12
12
  } from './types.js'
@@ -76,7 +76,7 @@ export function createStandardLogClosure<N extends string = LogMethodNames>(
76
76
  writeTo(reporterId) {
77
77
  return nonConsoleReporters.indexOf(reporterId) >= 0
78
78
  }
79
- }))
79
+ }))
80
80
  }
81
81
  }
82
82
  }
@@ -1,6 +1,6 @@
1
- export { type MemoryLogReporter } from '../memory.js'
1
+ export type { MemoryLogReporter } from '../memory.js'
2
2
  export {
3
3
  createStandardLogForTest,
4
- type StandardLogForTestOptions,
5
- type StandardLogForTest
4
+ type StandardLogForTest,
5
+ type StandardLogForTestOptions
6
6
  } from '../standard_log.testing.js'
package/ts/types.ts CHANGED
@@ -68,7 +68,7 @@ export type LogEntry = {
68
68
 
69
69
  export type LogMethod = (...args: any[]) => void
70
70
 
71
- export type LogFunction = (log: LogMethod, logLevel: number) => string | void
71
+ export type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void
72
72
 
73
73
  export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)
74
74
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC5F,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/D,YAAY,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,SAAS,EACT,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,MAAM,EACN,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,YAAY,CAAA"}
package/cjs/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,8CAA2B;AAC3B,iDAA8B;AAC9B,kDAA+B;AAC/B,8CAA2B;AAC3B,qDAA4F;AAAnF,+GAAA,YAAY,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,4GAAA,SAAS,OAAA;AAAE,+GAAA,YAAY,OAAA","sourcesContent":["export * from './console.js'\nexport * from './errors.js'\nexport * from './formatter.js'\nexport * from './log_levels.js'\nexport * from './memory.js'\nexport { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js'\nexport type { GetLogger, StandardLog } from './standard_log.js'\nexport type {\n\tConsoleLike,\n\tLogEntry,\n\tLogFilter,\n\tLogFormatter,\n\tLogFunction,\n\tLogLevel,\n\tLogLevelEntry,\n\tLogMethod,\n\tLogMethodNames,\n\tLogReporter,\n\tLogReporterOptions,\n\tLogger,\n\tLoggerOptions,\n\tReporterFilter,\n\tStandardLogInstance,\n\tStandardLogOptions\n} from './types.js'\n"]}
@@ -1 +0,0 @@
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 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":";;;AACA,sEAImC;AAHlC,mIAAA,wBAAwB,OAAA","sourcesContent":["export { type MemoryLogReporter } from '../memory.js'\nexport {\n\tcreateStandardLogForTest,\n\ttype StandardLogForTestOptions,\n\ttype StandardLogForTest\n} from '../standard_log.testing.js'\n"]}
package/cjs/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StackTraceMeta } from '@just-func/types'\n\nexport type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {\n\t/**\n\t * A map of custom log levels.\n\t *\n\t * Each logger created will have a method for each custom level.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog({ customLevels: { foo: 100 } })\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.foo('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (FOO) Hello world!\n\t * ```\n\t */\n\tcustomLevels?: Record<CustomLevelNames, number>\n\tlogLevel?: number\n\treporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n\tlevel?: number\n\twriteTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n\treadonly id: string\n\t/**\n\t * Logger local log level.\n\t */\n\tlevel?: number\n\t/**\n\t * Logs with an increment counter.\n\t * This is useful during debugging to check for steps executed.\n\t */\n\tcount(...args: any[]): void\n\ton(level: number | N, logFunction: LogFunction): void\n\t/**\n\t * Write custom log entries.\n\t */\n\twrite(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames =\n\t| 'emergency'\n\t| 'alert'\n\t| 'critical'\n\t| 'error'\n\t| 'warn'\n\t| 'notice'\n\t| 'info'\n\t| 'debug'\n\t| 'trace'\n\t| 'planck'\n\nexport type LogEntry = {\n\tid: string\n\tlevel: number\n\t// args instead of messages because it is `any[]` instead of `string[]`\n\targs: any[]\n\ttimestamp: Date\n}\n\nexport type LogMethod = (...args: any[]) => void\n\nexport type LogFunction = (log: LogMethod, logLevel: number) => string | void\n\nexport type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)\n\nexport interface StandardLogInstance<N extends string = LogMethodNames> {\n\t/**\n\t * The current log level.\n\t */\n\tlogLevel: number\n\t/**\n\t * Convert log level number to log level name.\n\t */\n\ttoLogLevelName(level: number): string\n\t/**\n\t * Convert log level name to log level number.\n\t */\n\ttoLogLevel(name: N): number\n\t/**\n\t * Get a logger instance with the specified id.\n\t *\n\t * ```ts\n\t * const logger = getLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!\n\t * ```\n\t */\n\tgetLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n\t/**\n\t * Get a non-console logger instance with the specified id.\n\t *\n\t * The resulting logger will only send to the reporters that are not console reporters.\n\t *\n\t * ```ts\n\t * const logger = getNonConsoleLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // will not send to any console reporter\n\t * ```\n\t */\n\tgetNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n}\n\n/**\n * Formats a log entry.\n * Depends on the reporter, it can expect a different return type.\n * By default the return type is `any[]` which the `console` accepts.\n */\nexport type LogFormatter<T = any[]> = (entry: LogEntry) => T\n\n/**\n * Determines whether the entry should be written.\n */\nexport type LogFilter = (entry: LogEntry) => boolean\n\nexport type LogLevelEntry = { name: string; level: number }\n\nexport interface LogReporter<T = any> {\n\treadonly id: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\treadonly formatter: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\treadonly filter?: LogFilter\n\t/**\n\t * Indicates if this is a console reporter.\n\t * There is only one console reporter can be present in the system.\n\t */\n\treadonly isConsoleReporter?: boolean\n\twrite(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n\tid?: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\tformatter?: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\tfilter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n\tdebug(...args: any[]): void\n\tinfo(...args: any[]): void\n\twarn(...args: any[]): void\n\terror(...args: any[]): void\n}\n"]}