standard-log 11.4.0 → 11.5.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 +5 -0
- package/cjs/index.d.ts +2 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +0 -1
- package/cjs/index.js.map +1 -1
- package/cjs/logger.d.ts.map +1 -1
- package/cjs/logger.js +4 -4
- package/cjs/logger.js.map +1 -1
- package/cjs/standardLog.ctx.d.ts +10 -0
- package/cjs/standardLog.ctx.d.ts.map +1 -0
- package/cjs/standardLog.ctx.js +6 -0
- package/cjs/standardLog.ctx.js.map +1 -0
- package/cjs/standardLog.d.ts +1 -15
- package/cjs/standardLog.d.ts.map +1 -1
- package/cjs/standardLog.js +14 -14
- package/cjs/standardLog.js.map +1 -1
- package/cjs/types.d.ts +9 -2
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +201 -269
- 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 +200 -163
- 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/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +1 -1
- package/esm/logger.d.ts.map +1 -1
- package/esm/logger.js +4 -4
- package/esm/logger.js.map +1 -1
- package/esm/standardLog.ctx.d.ts +10 -0
- package/esm/standardLog.ctx.d.ts.map +1 -0
- package/esm/standardLog.ctx.js +3 -0
- package/esm/standardLog.ctx.js.map +1 -0
- package/esm/standardLog.d.ts +1 -15
- package/esm/standardLog.d.ts.map +1 -1
- package/esm/standardLog.js +1 -1
- package/esm/standardLog.js.map +1 -1
- package/esm/types.d.ts +9 -2
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +3 -3
- package/ts/index.ts +7 -2
- package/ts/logger.ts +3 -4
- package/ts/standardLog.ctx.ts +8 -0
- package/ts/standardLog.ts +2 -14
- package/ts/types.ts +10 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "standard-log",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.0",
|
|
4
4
|
"description": "The standard log library",
|
|
5
5
|
"homepage": "https://github.com/unional/standard-log/tree/main/packages/log",
|
|
6
6
|
"bugs": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@just-func/types": "^0.5.0",
|
|
42
|
-
"iso-error": "^
|
|
42
|
+
"iso-error": "^5.0.0",
|
|
43
43
|
"ms": "^2.1.3",
|
|
44
44
|
"type-plus": "^4.16.0",
|
|
45
45
|
"upper-case": "^2.0.2"
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"build:clean": "rimraf *.tsbuildinfo",
|
|
96
96
|
"build:cjs": "tsc -p ./tsconfig.cjs.json && ncp package.cjs.json cjs/package.json",
|
|
97
97
|
"build:esm": "tsc -p ./tsconfig.esm.json",
|
|
98
|
-
"build:tslib": "tsc -p ./tsconfig.tslib.json",
|
|
98
|
+
"build:tslib": "tsc -p ./tsconfig.tslib.json && ncp package.cjs.json tslib/package.json",
|
|
99
99
|
"bundle": "run-p bundle:es5 bundle:esm",
|
|
100
100
|
"bundle:es5": "webpack -c ./webpack.es5.cjs",
|
|
101
101
|
"bundle:esm": "webpack -c ./webpack.esm.cjs",
|
package/ts/index.ts
CHANGED
|
@@ -7,5 +7,10 @@ export {
|
|
|
7
7
|
configGlobal, createStandardLog, createStandardLogForTest,
|
|
8
8
|
getLogger, suppressLogs
|
|
9
9
|
} from './standardLog.js'
|
|
10
|
-
export type { StandardLog, StandardLogForTest
|
|
11
|
-
export
|
|
10
|
+
export type { GetLogger, StandardLog, StandardLogForTest } from './standardLog.js'
|
|
11
|
+
export type {
|
|
12
|
+
ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, Logger, LoggerOptions, LogLevel,
|
|
13
|
+
LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, ReporterFilter,
|
|
14
|
+
StandardLogInstance, StandardLogOptions
|
|
15
|
+
} from './types.js'
|
|
16
|
+
|
package/ts/logger.ts
CHANGED
|
@@ -30,11 +30,10 @@ export function createLogger<N extends string = LogMethodNames>(
|
|
|
30
30
|
count: {
|
|
31
31
|
writable: false,
|
|
32
32
|
value: ((counter) => (...args: any[]) => {
|
|
33
|
-
|
|
34
|
-
if (shouldLog(store, level, logger.level))
|
|
33
|
+
if (shouldLog(store, logLevels.debug, logger.level))
|
|
35
34
|
write({
|
|
36
35
|
id,
|
|
37
|
-
level,
|
|
36
|
+
level: logLevels.debug,
|
|
38
37
|
args: [++counter, ...args],
|
|
39
38
|
timestamp: new Date()
|
|
40
39
|
})
|
|
@@ -47,7 +46,7 @@ export function createLogger<N extends string = LogMethodNames>(
|
|
|
47
46
|
if (shouldLog(store, logLevel, logger.level)) {
|
|
48
47
|
const methodName = store.logLevelStore.getName(logLevel)
|
|
49
48
|
const bindedMethod = logger[methodName].bind(logger)
|
|
50
|
-
const result = logFn(bindedMethod)
|
|
49
|
+
const result = logFn(bindedMethod, logger.level ?? store.logLevel)
|
|
51
50
|
if (result) bindedMethod(result)
|
|
52
51
|
}
|
|
53
52
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { record } from 'type-plus'
|
|
2
|
+
import type { LogStore } from './logStore.js'
|
|
3
|
+
import type { LogMethodNames, StandardLogInstance } from './types.js'
|
|
4
|
+
|
|
5
|
+
export const ctx: {
|
|
6
|
+
configured?: boolean,
|
|
7
|
+
gsl?: { store: LogStore, standardLog: StandardLogInstance<LogMethodNames> }
|
|
8
|
+
} = record()
|
package/ts/standardLog.ts
CHANGED
|
@@ -3,15 +3,8 @@ import { createLogger } from './logger.js'
|
|
|
3
3
|
import { DEFAULT_LOG_METHOD_NAMES, logLevels } from './logLevels.js'
|
|
4
4
|
import { createLogStore, LogStore } from './logStore.js'
|
|
5
5
|
import { createMemoryLogReporter, MemoryLogReporter } from './memory.js'
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
export interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
9
|
-
logLevel: number,
|
|
10
|
-
toLogLevelName(level: number): string,
|
|
11
|
-
toLogLevel(name: N): number,
|
|
12
|
-
getLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>,
|
|
13
|
-
getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>
|
|
14
|
-
}
|
|
6
|
+
import { ctx } from './standardLog.ctx.js'
|
|
7
|
+
import type { Logger, LoggerOptions, LogLevel, LogMethodNames, StandardLogInstance, StandardLogOptions } from './types.js'
|
|
15
8
|
|
|
16
9
|
export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {
|
|
17
10
|
}
|
|
@@ -113,11 +106,6 @@ export function getLogger<N extends string = LogMethodNames>(id: string, options
|
|
|
113
106
|
return getGlobalSL<N>().getLogger(id, options)
|
|
114
107
|
}
|
|
115
108
|
|
|
116
|
-
export const ctx: {
|
|
117
|
-
configured?: boolean,
|
|
118
|
-
gsl?: { store: LogStore, standardLog: StandardLogInstance<LogMethodNames> }
|
|
119
|
-
} = record()
|
|
120
|
-
|
|
121
109
|
function getGlobalSL<N extends string = LogMethodNames>(): StandardLogInstance<N> {
|
|
122
110
|
if (!ctx.gsl) ctx.gsl = createStandardLogClosure()
|
|
123
111
|
|
package/ts/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StackTraceMeta } from '@just-func/types'
|
|
1
|
+
import type { StackTraceMeta } from '@just-func/types'
|
|
2
2
|
|
|
3
3
|
export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
4
4
|
customLevels?: Record<CustomLevelNames, number>,
|
|
@@ -44,10 +44,18 @@ export type LogEntry = {
|
|
|
44
44
|
|
|
45
45
|
export type LogMethod = (...args: any[]) => void
|
|
46
46
|
|
|
47
|
-
export type LogFunction = (
|
|
47
|
+
export type LogFunction = (log: LogMethod, logLevel: number) => string | void
|
|
48
48
|
|
|
49
49
|
export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)
|
|
50
50
|
|
|
51
|
+
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>
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
/**
|
|
52
60
|
* Formats a log entry.
|
|
53
61
|
* Depends on the reporter, it can expect a different return type.
|