standard-log 11.5.0 → 11.5.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.
Files changed (89) hide show
  1. package/cjs/console.d.ts +3 -3
  2. package/cjs/console.d.ts.map +1 -1
  3. package/cjs/console.js +17 -8
  4. package/cjs/console.js.map +1 -1
  5. package/cjs/errors.d.ts.map +1 -1
  6. package/cjs/errors.js.map +1 -1
  7. package/cjs/formatter.d.ts +1 -1
  8. package/cjs/formatter.d.ts.map +1 -1
  9. package/cjs/formatter.js.map +1 -1
  10. package/cjs/index.d.ts.map +1 -1
  11. package/cjs/index.js.map +1 -1
  12. package/cjs/logLevels.d.ts.map +1 -1
  13. package/cjs/logLevels.js.map +1 -1
  14. package/cjs/logStore.d.ts.map +1 -1
  15. package/cjs/logStore.js.map +1 -1
  16. package/cjs/logger.d.ts.map +1 -1
  17. package/cjs/logger.js +15 -13
  18. package/cjs/logger.js.map +1 -1
  19. package/cjs/memory.d.ts +2 -2
  20. package/cjs/memory.d.ts.map +1 -1
  21. package/cjs/memory.js +15 -8
  22. package/cjs/memory.js.map +1 -1
  23. package/cjs/platform.d.ts.map +1 -1
  24. package/cjs/platform.js +1 -2
  25. package/cjs/platform.js.map +1 -1
  26. package/cjs/standardLog.ctx.d.ts.map +1 -1
  27. package/cjs/standardLog.ctx.js.map +1 -1
  28. package/cjs/standardLog.d.ts +2 -2
  29. package/cjs/standardLog.d.ts.map +1 -1
  30. package/cjs/standardLog.js +19 -14
  31. package/cjs/standardLog.js.map +1 -1
  32. package/cjs/types.d.ts +12 -12
  33. package/cjs/types.d.ts.map +1 -1
  34. package/cjs/types.js.map +1 -1
  35. package/dist/standard-log.es5.js +1190 -801
  36. package/dist/standard-log.es5.js.gz +0 -0
  37. package/dist/standard-log.es5.js.map +1 -1
  38. package/dist/standard-log.es5.js.map.gz +0 -0
  39. package/dist/standard-log.esm.js +173 -119
  40. package/dist/standard-log.esm.js.gz +0 -0
  41. package/dist/standard-log.esm.js.map +1 -1
  42. package/dist/standard-log.esm.js.map.gz +0 -0
  43. package/esm/console.d.ts +3 -3
  44. package/esm/console.d.ts.map +1 -1
  45. package/esm/console.js +20 -9
  46. package/esm/console.js.map +1 -1
  47. package/esm/errors.d.ts.map +1 -1
  48. package/esm/errors.js.map +1 -1
  49. package/esm/formatter.d.ts +1 -1
  50. package/esm/formatter.d.ts.map +1 -1
  51. package/esm/formatter.js.map +1 -1
  52. package/esm/index.d.ts.map +1 -1
  53. package/esm/index.js.map +1 -1
  54. package/esm/logLevels.d.ts.map +1 -1
  55. package/esm/logLevels.js.map +1 -1
  56. package/esm/logStore.d.ts.map +1 -1
  57. package/esm/logStore.js.map +1 -1
  58. package/esm/logger.d.ts.map +1 -1
  59. package/esm/logger.js +1 -1
  60. package/esm/logger.js.map +1 -1
  61. package/esm/memory.d.ts +2 -2
  62. package/esm/memory.d.ts.map +1 -1
  63. package/esm/memory.js +15 -8
  64. package/esm/memory.js.map +1 -1
  65. package/esm/platform.d.ts.map +1 -1
  66. package/esm/platform.js +1 -2
  67. package/esm/platform.js.map +1 -1
  68. package/esm/standardLog.ctx.d.ts.map +1 -1
  69. package/esm/standardLog.ctx.js.map +1 -1
  70. package/esm/standardLog.d.ts +2 -2
  71. package/esm/standardLog.d.ts.map +1 -1
  72. package/esm/standardLog.js +23 -18
  73. package/esm/standardLog.js.map +1 -1
  74. package/esm/types.d.ts +12 -12
  75. package/esm/types.d.ts.map +1 -1
  76. package/esm/types.js.map +1 -1
  77. package/package.json +17 -9
  78. package/ts/console.ts +54 -45
  79. package/ts/errors.ts +6 -6
  80. package/ts/formatter.ts +18 -18
  81. package/ts/index.ts +21 -6
  82. package/ts/logLevels.ts +90 -91
  83. package/ts/logStore.ts +46 -37
  84. package/ts/logger.ts +67 -57
  85. package/ts/memory.ts +66 -54
  86. package/ts/platform.ts +2 -2
  87. package/ts/standardLog.ctx.ts +2 -2
  88. package/ts/standardLog.ts +113 -94
  89. package/ts/types.ts +72 -62
package/ts/types.ts CHANGED
@@ -1,45 +1,55 @@
1
1
  import type { StackTraceMeta } from '@just-func/types'
2
2
 
3
3
  export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
4
- customLevels?: Record<CustomLevelNames, number>,
5
- logLevel?: number,
6
- reporters?: LogReporter[]
4
+ customLevels?: Record<CustomLevelNames, number>
5
+ logLevel?: number
6
+ reporters?: LogReporter[]
7
7
  }
8
8
 
9
9
  export interface LoggerOptions extends StackTraceMeta {
10
- level?: number,
11
- writeTo?: LogReporter | ReporterFilter
10
+ level?: number
11
+ writeTo?: LogReporter | ReporterFilter
12
12
  }
13
13
 
14
14
  export type Logger<N extends string = LogMethodNames> = {
15
- readonly id: string,
16
- /**
17
- * Logger local log level.
18
- */
19
- level?: number,
20
- /**
21
- * Logs with an increment counter.
22
- * This is useful during debugging to check for steps executed.
23
- */
24
- count(...args: any[]): void,
25
- on(level: number | N, logFunction: LogFunction): void,
26
- /**
27
- * Write custom log entries.
28
- */
29
- write(entry: LogEntry): void
15
+ readonly id: string
16
+ /**
17
+ * Logger local log level.
18
+ */
19
+ level?: number
20
+ /**
21
+ * Logs with an increment counter.
22
+ * This is useful during debugging to check for steps executed.
23
+ */
24
+ count(...args: any[]): void
25
+ on(level: number | N, logFunction: LogFunction): void
26
+ /**
27
+ * Write custom log entries.
28
+ */
29
+ write(entry: LogEntry): void
30
30
  } & { [k in N]: LogMethod }
31
31
 
32
32
  /**
33
33
  * Names of the standard log methods.
34
34
  */
35
- export type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck'
35
+ export type LogMethodNames =
36
+ | 'emergency'
37
+ | 'alert'
38
+ | 'critical'
39
+ | 'error'
40
+ | 'warn'
41
+ | 'notice'
42
+ | 'info'
43
+ | 'debug'
44
+ | 'trace'
45
+ | 'planck'
36
46
 
37
47
  export type LogEntry = {
38
- id: string,
39
- level: number,
40
- // args instead of messages because it is `any[]` instead of `string[]`
41
- args: any[],
42
- timestamp: Date
48
+ id: string
49
+ level: number
50
+ // args instead of messages because it is `any[]` instead of `string[]`
51
+ args: any[]
52
+ timestamp: Date
43
53
  }
44
54
 
45
55
  export type LogMethod = (...args: any[]) => void
@@ -49,11 +59,11 @@ export type LogFunction = (log: LogMethod, logLevel: number) => string | void
49
59
  export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)
50
60
 
51
61
  export interface StandardLogInstance<N extends string = LogMethodNames> {
52
- logLevel: number,
53
- toLogLevelName(level: number): string,
54
- toLogLevel(name: N): number,
55
- getLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>,
56
- getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>
62
+ logLevel: number
63
+ toLogLevelName(level: number): string
64
+ toLogLevel(name: N): number
65
+ getLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>
66
+ getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>
57
67
  }
58
68
 
59
69
  /**
@@ -68,45 +78,45 @@ export type LogFormatter<T = any[]> = (entry: LogEntry) => T
68
78
  */
69
79
  export type LogFilter = (entry: LogEntry) => boolean
70
80
 
71
- export type LogLevelEntry = { name: string, level: number }
81
+ export type LogLevelEntry = { name: string; level: number }
72
82
 
73
83
  export interface LogReporter<T = any> {
74
- readonly id: string,
75
- /**
76
- * Specifies the formatter to be used by the reporter.
77
- * Using this you can customize how the reporter writes the log entry.
78
- */
79
- readonly formatter: LogFormatter<T>,
80
- /**
81
- * Specifies a filter to determine should the log be written.
82
- */
83
- readonly filter?: LogFilter,
84
- /**
85
- * Indicate if this is a console reporter.
86
- * There is only one console reporter can be present in the system.
87
- */
88
- readonly isConsoleReporter?: boolean,
89
- write(entry: LogEntry): void
84
+ readonly id: string
85
+ /**
86
+ * Specifies the formatter to be used by the reporter.
87
+ * Using this you can customize how the reporter writes the log entry.
88
+ */
89
+ readonly formatter: LogFormatter<T>
90
+ /**
91
+ * Specifies a filter to determine should the log be written.
92
+ */
93
+ readonly filter?: LogFilter
94
+ /**
95
+ * Indicate if this is a console reporter.
96
+ * There is only one console reporter can be present in the system.
97
+ */
98
+ readonly isConsoleReporter?: boolean
99
+ write(entry: LogEntry): void
90
100
  }
91
101
 
92
102
  export type LogReporterOptions<T = any> = {
93
- id?: string,
94
- /**
95
- * Specifies the formatter to be used by the reporter.
96
- * Using this you can customize how the reporter writes the log entry.
97
- */
98
- formatter?: LogFormatter<T>,
99
- /**
100
- * Specifies a filter to determine should the log be written.
101
- */
102
- filter?: LogFilter
103
+ id?: string
104
+ /**
105
+ * Specifies the formatter to be used by the reporter.
106
+ * Using this you can customize how the reporter writes the log entry.
107
+ */
108
+ formatter?: LogFormatter<T>
109
+ /**
110
+ * Specifies a filter to determine should the log be written.
111
+ */
112
+ filter?: LogFilter
103
113
  }
104
114
 
105
115
  export type LogLevel = number
106
116
 
107
117
  export interface ConsoleLike {
108
- debug(...args: any[]): void,
109
- info(...args: any[]): void,
110
- warn(...args: any[]): void,
111
- error(...args: any[]): void,
118
+ debug(...args: any[]): void
119
+ info(...args: any[]): void
120
+ warn(...args: any[]): void
121
+ error(...args: any[]): void
112
122
  }