standard-log 13.3.1 → 13.3.3

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 (56) hide show
  1. package/CHANGELOG.md +989 -0
  2. package/cjs/log_store.d.ts.map +1 -1
  3. package/cjs/log_store.js +7 -7
  4. package/cjs/log_store.js.map +1 -1
  5. package/cjs/memory.d.ts.map +1 -1
  6. package/cjs/memory.js +1 -2
  7. package/cjs/memory.js.map +1 -1
  8. package/cjs/platform.browser.js +2 -2
  9. package/cjs/platform.browser.js.map +1 -1
  10. package/cjs/platform.js +2 -2
  11. package/cjs/platform.js.map +1 -1
  12. package/cjs/record.d.ts +9 -0
  13. package/cjs/record.d.ts.map +1 -0
  14. package/cjs/record.js +15 -0
  15. package/cjs/record.js.map +1 -0
  16. package/cjs/standard_log.ctx.js +1 -1
  17. package/cjs/standard_log.ctx.js.map +1 -1
  18. package/cjs/standard_log.d.ts.map +1 -1
  19. package/cjs/standard_log.js +4 -3
  20. package/cjs/standard_log.js.map +1 -1
  21. package/cjs/types.d.ts +5 -2
  22. package/cjs/types.d.ts.map +1 -1
  23. package/dist/standard-log.esm.js +22 -97
  24. package/dist/standard-log.esm.js.map +1 -1
  25. package/dist/standard-log.iife.js +22 -97
  26. package/dist/standard-log.iife.js.map +1 -1
  27. package/esm/log_store.d.ts.map +1 -1
  28. package/esm/log_store.js +4 -4
  29. package/esm/log_store.js.map +1 -1
  30. package/esm/memory.d.ts.map +1 -1
  31. package/esm/memory.js +1 -2
  32. package/esm/memory.js.map +1 -1
  33. package/esm/platform.browser.js +1 -1
  34. package/esm/platform.browser.js.map +1 -1
  35. package/esm/platform.js +1 -1
  36. package/esm/platform.js.map +1 -1
  37. package/esm/record.d.ts +9 -0
  38. package/esm/record.d.ts.map +1 -0
  39. package/esm/record.js +14 -0
  40. package/esm/record.js.map +1 -0
  41. package/esm/standard_log.ctx.js +1 -1
  42. package/esm/standard_log.ctx.js.map +1 -1
  43. package/esm/standard_log.d.ts.map +1 -1
  44. package/esm/standard_log.js +2 -1
  45. package/esm/standard_log.js.map +1 -1
  46. package/esm/types.d.ts +5 -2
  47. package/esm/types.d.ts.map +1 -1
  48. package/package.json +7 -7
  49. package/ts/log_store.ts +4 -6
  50. package/ts/memory.ts +1 -2
  51. package/ts/platform.browser.ts +1 -1
  52. package/ts/platform.ts +1 -1
  53. package/ts/record.ts +9 -0
  54. package/ts/standard_log.ctx.ts +1 -1
  55. package/ts/standard_log.ts +2 -1
  56. package/ts/types.ts +5 -3
package/ts/log_store.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { mapKey, record, reduceByKey } from 'type-plus'
2
1
  import { createConsoleLogReporter } from './console.js'
3
2
  import { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'
3
+ import { record } from './record.js'
4
4
  import type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'
5
5
 
6
6
  export function createLogStore<N extends string = LogMethodNames>(
@@ -32,8 +32,7 @@ export function logLevelStore(options: LogLevelStoreOptions) {
32
32
 
33
33
  const store = {
34
34
  customLevels,
35
- customLevelsReverse: reduceByKey(
36
- customLevels,
35
+ customLevelsReverse: Object.keys(customLevels).reduce(
37
36
  (p, k) => {
38
37
  p[customLevels[k]] = k
39
38
  return p
@@ -49,14 +48,13 @@ export function logLevelStore(options: LogLevelStoreOptions) {
49
48
  return store.customLevels[name] ?? toLogLevel(name)
50
49
  },
51
50
  getAllLevels() {
52
- return reduceByKey(
53
- logLevels,
51
+ return (Object.keys(logLevels) as Array<keyof typeof logLevels>).reduce(
54
52
  (result, name) => {
55
53
  if (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })
56
54
 
57
55
  return result
58
56
  },
59
- mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))
57
+ Object.keys(store.customLevels).map(name => ({ name, level: store.customLevels[name] }))
60
58
  )
61
59
  }
62
60
  }
package/ts/memory.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { required } from 'type-plus'
2
- import { unpartial } from 'unpartial'
1
+ import { required, unpartial } from 'unpartial'
3
2
  import { createConsoleLogReporter } from './console.js'
4
3
  import { formatLogLevel } from './formatter.js'
5
4
  import { toInspectLogEntry } from './platform.js'
@@ -1,4 +1,4 @@
1
- import { record } from 'type-plus'
1
+ import { record } from './record.js'
2
2
  import type { ConsoleLike, LogEntry } from './types.js'
3
3
 
4
4
  export const toInspectLogEntry = (e: LogEntry) => e
package/ts/platform.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { inspect } from 'node:util'
2
- import { record } from 'type-plus'
2
+ import { record } from './record.js'
3
3
  import type { ConsoleLike, LogEntry } from './types.js'
4
4
 
5
5
  export const toInspectLogEntry = (e: LogEntry) => (
package/ts/record.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates a prototype-less object, optionally seeded with `value`.
3
+ *
4
+ * Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
5
+ */
6
+ export function record<R extends Record<any, any>>(value?: R): R {
7
+ const r = Object.create(null)
8
+ return value ? Object.assign(r, value) : r
9
+ }
@@ -1,5 +1,5 @@
1
- import { record } from 'type-plus'
2
1
  import type { LogStore } from './log_store.js'
2
+ import { record } from './record.js'
3
3
  import type { LogMethodNames, StandardLogInstance } from './types.js'
4
4
 
5
5
  export const ctx: {
@@ -1,7 +1,8 @@
1
- import { record, required } from 'type-plus'
1
+ import { required } from 'unpartial'
2
2
  import { DEFAULT_LOG_METHOD_NAMES, logLevels } from './log_levels.js'
3
3
  import { createLogStore, type LogStore } from './log_store.js'
4
4
  import { createLogger } from './logger.js'
5
+ import { record } from './record.js'
5
6
  import { ctx } from './standard_log.ctx.js'
6
7
  import type {
7
8
  Logger,
package/ts/types.ts CHANGED
@@ -1,5 +1,3 @@
1
- import type { StackTraceMeta } from '@just-func/types'
2
-
3
1
  export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
4
2
  /**
5
3
  * A map of custom log levels.
@@ -20,7 +18,11 @@ export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames>
20
18
  reporters?: LogReporter[]
21
19
  }
22
20
 
23
- export interface LoggerOptions extends StackTraceMeta {
21
+ export interface LoggerOptions {
22
+ /**
23
+ * Stack start function: the stack trace is adjusted to start from this function.
24
+ */
25
+ ssf?: (...args: any[]) => any
24
26
  level?: number
25
27
  writeTo?: LogReporter | ReporterFilter
26
28
  }