standard-log 12.1.2 → 13.0.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 +8 -8
- package/cjs/console.d.ts.map +1 -1
- package/cjs/console.js +8 -11
- package/cjs/console.js.map +1 -1
- package/cjs/errors.d.ts +1 -1
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js.map +1 -1
- package/cjs/formatter.d.ts.map +1 -1
- package/cjs/formatter.js +5 -7
- package/cjs/formatter.js.map +1 -1
- package/cjs/index.d.ts +2 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/log_levels.js +5 -5
- package/cjs/log_levels.js.map +1 -1
- package/cjs/log_store.js +2 -3
- package/cjs/log_store.js.map +1 -1
- package/cjs/logger.d.ts +1 -1
- package/cjs/logger.d.ts.map +1 -1
- package/cjs/logger.js +1 -2
- package/cjs/logger.js.map +1 -1
- package/cjs/memory.d.ts.map +1 -1
- package/cjs/memory.js +6 -9
- package/cjs/memory.js.map +1 -1
- package/cjs/platform.browser.d.ts.map +1 -1
- package/cjs/platform.d.ts.map +1 -1
- package/cjs/platform.js +2 -2
- package/cjs/platform.js.map +1 -1
- package/cjs/standard_log.d.ts +1 -1
- package/cjs/standard_log.d.ts.map +1 -1
- package/cjs/standard_log.js +5 -6
- package/cjs/standard_log.js.map +1 -1
- package/cjs/standard_log.testing.js +1 -2
- package/cjs/standard_log.testing.js.map +1 -1
- package/cjs/testing/index.d.ts +2 -2
- package/cjs/testing/index.d.ts.map +1 -1
- package/cjs/testing/index.js.map +1 -1
- package/cjs/types.d.ts +1 -1
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +1643 -1199
- 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 +273 -303
- 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/console.d.ts.map +1 -1
- package/esm/console.js +7 -9
- package/esm/console.js.map +1 -1
- package/esm/errors.d.ts +1 -1
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js.map +1 -1
- package/esm/formatter.d.ts.map +1 -1
- package/esm/formatter.js +1 -2
- package/esm/formatter.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/log_levels.js +2 -2
- package/esm/log_levels.js.map +1 -1
- package/esm/logger.d.ts +1 -1
- package/esm/logger.d.ts.map +1 -1
- package/esm/logger.js.map +1 -1
- package/esm/memory.d.ts.map +1 -1
- package/esm/memory.js +3 -5
- package/esm/memory.js.map +1 -1
- package/esm/platform.browser.d.ts.map +1 -1
- package/esm/platform.d.ts.map +1 -1
- package/esm/platform.js +1 -1
- package/esm/platform.js.map +1 -1
- package/esm/standard_log.d.ts +1 -1
- package/esm/standard_log.d.ts.map +1 -1
- package/esm/standard_log.js.map +1 -1
- package/esm/standard_log.testing.js.map +1 -1
- package/esm/testing/index.d.ts +2 -2
- package/esm/testing/index.d.ts.map +1 -1
- package/esm/testing/index.js.map +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +24 -36
- package/ts/console.ts +7 -8
- package/ts/errors.ts +5 -2
- package/ts/formatter.ts +1 -2
- package/ts/index.ts +3 -3
- package/ts/log_levels.ts +2 -2
- package/ts/logger.ts +14 -7
- package/ts/memory.ts +3 -5
- package/ts/platform.ts +1 -1
- package/ts/standard_log.ts +2 -2
- package/ts/testing/index.ts +3 -3
- package/ts/types.ts +1 -1
package/esm/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AAC,CAAC,CAAC,CAAA;QACrC,CAAC;KACD,CAAA;AACF,CAAC;AAED,MAAM,UAAU,kCAAkC,CACjD,OAAsC;IAEtC,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE;QACrF,iBAAiB,EAAE,IAAI;KACvB,CAAC,CACF,CAAA;AACF,CAAC","sourcesContent":["import { required, unpartial } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { formatLogLevel } from './formatter.js'\nimport { toInspectLogEntry } from './platform.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n\tlogs: LogEntry[]\n\t/**\n\t * Gets a simple log message for testing.\n\t * The message only contains arguments for each log entry.\n\t */\n\tgetLogMessage(): string\n\tgetLogMessages(): string[]\n\tgetLogMessageWithLevel(): string\n\tgetLogMessagesWithLevel(): string[]\n\tgetLogMessagesWithIdAndLevel(): string[]\n\temit(): void\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n\treturn (\n\t\tlogs\n\t\t\t.map(toInspectLogEntry)\n\t\t\t.map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t\t.join('\\n')\n\t\t\t// if it has more than this log,\n\t\t\t// we assume it is running under tests,\n\t\t\t// and remove this log to simplify testing.\n\t\t\t.replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n\t)\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n\treturn Object.freeze(buildMemoryReporter(unpartial({ id: 'memory' }, options)))\n}\n\nfunction buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {\n\tconst { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n\tconst logs: LogEntry[] = []\n\treturn {\n\t\tid,\n\t\tget formatter() {\n\t\t\treturn formatter\n\t\t},\n\t\tget filter() {\n\t\t\treturn filter\n\t\t},\n\t\tlogs,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tlogs.push(formatter(entry))\n\t\t},\n\t\tgetLogMessage() {\n\t\t\treturn this.getLogMessages().join('\\n')\n\t\t},\n\t\tgetLogMessages() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => log.args.join(' '))\n\t\t},\n\t\tgetLogMessagesWithLevel() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessagesWithIdAndLevel() {\n\t\t\treturn logs\n\t\t\t\t.map(toInspectLogEntry)\n\t\t\t\t.map(log => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessageWithLevel() {\n\t\t\treturn toMessageWithLevel(logs)\n\t\t},\n\t\t/**\n\t\t * emit the saved log to console for easy debugging\n\t\t */\n\t\temit() {\n\t\t\tconst reporter = createConsoleLogReporter()\n\t\t\tlogs.forEach(l => reporter.write(l))\n\t\t}\n\t}\n}\n\nexport function createMemoryWithConsoleLogReporter(\n\toptions?: LogReporterOptions<LogEntry>\n): MemoryLogReporter {\n\treturn Object.freeze(\n\t\tObject.assign(buildMemoryReporter(unpartial({ id: 'memory-with-console' }, options)), {\n\t\t\tisConsoleReporter: true\n\t\t})\n\t)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.browser.d.ts","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"platform.browser.d.ts","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,aAAM,CAAA;AAEnD,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAa,CAAA"}
|
package/esm/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,aAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAa,CAAA"}
|
package/esm/platform.js
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
|
export const toInspectLogEntry = (e) => ((e.args = e.args.map(value => (typeof value === 'object' && value !== null ? inspect(value) : value))), e);
|
|
4
4
|
export const polyfill = record();
|
|
5
5
|
//# sourceMappingURL=platform.js.map
|
package/esm/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGlC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,CACjD,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CACzG,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAA8B,MAAM,EAAE,CAAA","sourcesContent":["import { inspect } from 'node:util'\nimport { record } from 'type-plus'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n\t(e.args = e.args.map(value => (typeof value === 'object' && value !== null ? inspect(value) : value))), e\n)\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"]}
|
package/esm/standard_log.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LogStore } from './log_store.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Logger, LoggerOptions, LogMethodNames, StandardLogInstance, StandardLogOptions } from './types.js';
|
|
3
3
|
export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {
|
|
4
4
|
}
|
|
5
5
|
export declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.d.ts","sourceRoot":"","sources":["../ts/standard_log.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9D,OAAO,KAAK,EACX,
|
|
1
|
+
{"version":3,"file":"standard_log.d.ts","sourceRoot":"","sources":["../ts/standard_log.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 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.js","sourceRoot":"","sources":["../ts/standard_log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,cAAc,EAAiB,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAW3C,MAAM,UAAU,iBAAiB,CAChC,OAA+B;;IAE/B,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;IACjD,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"standard_log.js","sourceRoot":"","sources":["../ts/standard_log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,cAAc,EAAiB,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAW3C,MAAM,UAAU,iBAAiB,CAChC,OAA+B;;IAE/B,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;IACjD,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QAC1C,MAAM,GAAG,GA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,CAAA;IACF,CAAC;IAED,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;QACb,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACtB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAC1C,CAAC;QACD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAA;YACzC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;YACpB,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;QACrC,CAAC;IACF,CAAC;SAAM,CAAC;QACP,GAAG,CAAC,GAAG,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;IACD,GAAG,CAAC,UAAU,GAAG,IAAI,CAAA;AACtB,CAAC","sourcesContent":["import { record, required } from 'type-plus'\nimport { DEFAULT_LOG_METHOD_NAMES, logLevels } from './log_levels.js'\nimport { createLogStore, type LogStore } from './log_store.js'\nimport { createLogger } from './logger.js'\nimport { ctx } from './standard_log.ctx.js'\nimport type {\n\tLogger,\n\tLoggerOptions,\n\tLogMethodNames,\n\tStandardLogInstance,\n\tStandardLogOptions\n} from './types.js'\n\nexport interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}\n\nexport function createStandardLog<N extends string = LogMethodNames>(\n\toptions?: StandardLogOptions<N>\n): StandardLog<N> {\n\tconst closure = createStandardLogClosure(options)\n\tif (options?.reporters?.some(r => !r.id)) {\n\t\tconst log = closure.standardLog.getLogger('standard-log')\n\t\tlog.critical(\n\t\t\t`Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.`\n\t\t)\n\t}\n\n\tif (!ctx.gsl) ctx.gsl = closure as any\n\treturn closure.standardLog\n}\n\nfunction noop() {}\n\nexport function createStandardLogClosure<N extends string = LogMethodNames>(\n\toptions?: StandardLogOptions<N>\n): { store: LogStore; standardLog: StandardLog<N> } {\n\t// TODO reporter.id must not be empty\n\tconst store = createLogStore(required({ logLevel: logLevels.info }, options))\n\tconst nonConsoleReporters = options?.reporters?.filter(r => !r.isConsoleReporter).map(r => r.id) ?? []\n\tconst logMethods = DEFAULT_LOG_METHOD_NAMES.concat(Object.keys(options?.customLevels ?? {})).concat([\n\t\t'on',\n\t\t'count',\n\t\t'write'\n\t])\n\treturn {\n\t\tstore,\n\t\tstandardLog: {\n\t\t\tget logLevel() {\n\t\t\t\treturn store.logLevel\n\t\t\t},\n\n\t\t\ttoLogLevelName(level: number) {\n\t\t\t\treturn store.logLevelStore.getName(level)\n\t\t\t},\n\t\t\ttoLogLevel(name: string) {\n\t\t\t\treturn store.logLevelStore.getLevel(name)\n\t\t\t},\n\t\t\tgetLogger(id: string, options?: LoggerOptions) {\n\t\t\t\tif (store.loggers[id]) return store.loggers[id] as any\n\t\t\t\treturn (store.loggers[id] = createLogger(store, id, { ssf: this.getLogger, ...options }) as any)\n\t\t\t},\n\t\t\tgetNonConsoleLogger(id, options?) {\n\t\t\t\tif (store.nonConsoleLoggers[id]) return store.nonConsoleLoggers[id] as any\n\n\t\t\t\tif (store.loggers[id]) {\n\t\t\t\t\tconst log = this.getLogger('standard-log')\n\t\t\t\t\tlog.warn(`attempt to create a non-console logger with existing id ('${id}'), ignoring`)\n\t\t\t\t\treturn (store.nonConsoleLoggers[id] = createDummyLogger(logMethods))\n\t\t\t\t}\n\n\t\t\t\treturn (store.nonConsoleLoggers[id] =\n\t\t\t\t\tnonConsoleReporters.length === 0\n\t\t\t\t\t\t? createDummyLogger(logMethods)\n\t\t\t\t\t\t: createLogger(store, id, {\n\t\t\t\t\t\t\t\tssf: this.getNonConsoleLogger,\n\t\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t\t\twriteTo(reporterId) {\n\t\t\t\t\t\t\t\t\treturn nonConsoleReporters.indexOf(reporterId) >= 0\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}))\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction createDummyLogger(logMethods: string[]) {\n\treturn logMethods.reduce((p, m) => {\n\t\tp[m] = noop\n\t\treturn p\n\t}, record()) as Logger\n}\n\n/**\n * Suppress logging within the code block.\n */\nexport function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R\nexport function suppressLogs<R>(block: () => R, ...logs: Logger[]): R {\n\tconst origLevels = logs.map(l => l.level)\n\tlogs.forEach(l => (l.level = logLevels.none))\n\tconst result = block()\n\tlogs.forEach((l, i) => (l.level = origLevels[i]))\n\treturn result\n}\n\nexport type GetLogger<N extends string = LogMethodNames> = (\n\tid: string,\n\toptions?: LoggerOptions\n) => Logger<LogMethodNames | N>\n\nexport function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions) {\n\treturn getGlobalSL<N>().getLogger(id, options)\n}\n\nfunction getGlobalSL<N extends string = LogMethodNames>(): StandardLogInstance<N> {\n\tif (!ctx.gsl) ctx.gsl = createStandardLogClosure()\n\n\treturn ctx.gsl!.standardLog as StandardLogInstance<N>\n}\n\nexport function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>) {\n\tif (ctx.configured) {\n\t\tconst log = ctx.gsl!.standardLog.getLogger('standard-log')\n\t\tlog.warn(\n\t\t\t'configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.'\n\t\t)\n\t}\n\n\tif (ctx.gsl) {\n\t\tif (options.logLevel) {\n\t\t\tctx.gsl.store.logLevel = options.logLevel\n\t\t}\n\t\tif (options.reporters) {\n\t\t\tconst reporters = ctx.gsl.store.reporters\n\t\t\treporters.length = 0\n\t\t\treporters.push(...options.reporters)\n\t\t}\n\t} else {\n\t\tctx.gsl = createStandardLogClosure(options)\n\t}\n\tctx.configured = true\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.testing.js","sourceRoot":"","sources":["../ts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C;QAC1E,8BAA8B;QAC9B,oCAAoC;QACpC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAA;IACnD,CAAC;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,CAAC;QACvB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC;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"]}
|
package/esm/testing/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createStandardLogForTest, type
|
|
1
|
+
export type { MemoryLogReporter } from '../memory.js';
|
|
2
|
+
export { createStandardLogForTest, type StandardLogForTest, type StandardLogForTestOptions } 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EACN,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,MAAM,4BAA4B,CAAA"}
|
package/esm/testing/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,wBAAwB,EAGxB,MAAM,4BAA4B,CAAA","sourcesContent":["export {
|
|
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 StandardLogForTest,\n\ttype StandardLogForTestOptions\n} from '../standard_log.testing.js'\n"]}
|
package/esm/types.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export type LogEntry = {
|
|
|
52
52
|
timestamp: Date;
|
|
53
53
|
};
|
|
54
54
|
export type LogMethod = (...args: any[]) => void;
|
|
55
|
-
export type LogFunction = (log: LogMethod, logLevel: number) => string | void;
|
|
55
|
+
export type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
|
|
56
56
|
export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
|
|
57
57
|
export interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
58
58
|
/**
|
package/esm/types.d.ts.map
CHANGED
|
@@ -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,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,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;CAC3B"}
|
package/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"]}
|
|
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 | undefined | 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"]}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "standard-log",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "The standard log library",
|
|
5
|
-
"homepage": "https://github.com/
|
|
5
|
+
"homepage": "https://github.com/cyberuni/standard-log/tree/main/packages/log",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/cyberuni/standard-log/issues"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/
|
|
11
|
+
"url": "https://github.com/cyberuni/standard-log.git"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": {
|
|
@@ -61,41 +61,32 @@
|
|
|
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/
|
|
69
|
-
"@size-limit/preset-small-lib": "^
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/
|
|
72
|
-
"@types/
|
|
73
|
-
"@types/ramda": "^0.29.0",
|
|
67
|
+
"@repobuddy/vitest": "^2.1.1",
|
|
68
|
+
"@size-limit/preset-small-lib": "^13.0.0",
|
|
69
|
+
"@types/ms": "^2.0.0",
|
|
70
|
+
"@types/node": "^24.0.0",
|
|
71
|
+
"@types/ramda": "^0.32.0",
|
|
74
72
|
"assertron": "^11.0.0",
|
|
75
|
-
"compression-webpack-plugin": "^
|
|
76
|
-
"cross-env": "^7.0.3",
|
|
73
|
+
"compression-webpack-plugin": "^12.0.0",
|
|
77
74
|
"depcheck": "^1.4.3",
|
|
78
75
|
"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
76
|
"ncp": "^2.0.0",
|
|
86
|
-
"npm-run-
|
|
87
|
-
"param-case": "^
|
|
88
|
-
"pascal-case": "^
|
|
89
|
-
"ramda": "^0.
|
|
90
|
-
"rimraf": "^
|
|
91
|
-
"size-limit": "^
|
|
92
|
-
"ts-jest": "^29.0.3",
|
|
77
|
+
"npm-run-all2": "^9.0.0",
|
|
78
|
+
"param-case": "^4.0.0",
|
|
79
|
+
"pascal-case": "^4.0.0",
|
|
80
|
+
"ramda": "^0.32.0",
|
|
81
|
+
"rimraf": "^6.0.0",
|
|
82
|
+
"size-limit": "^13.0.0",
|
|
93
83
|
"ts-loader": "^9.4.1",
|
|
94
84
|
"tslib": "^2.4.0",
|
|
95
85
|
"typescript": "^5.0.0",
|
|
86
|
+
"vitest": "^4.1.0",
|
|
96
87
|
"webpack": "^5.74.0",
|
|
97
|
-
"webpack-bundle-analyzer": "^
|
|
98
|
-
"webpack-cli": "^
|
|
88
|
+
"webpack-bundle-analyzer": "^5.0.0",
|
|
89
|
+
"webpack-cli": "^7.0.0"
|
|
99
90
|
},
|
|
100
91
|
"size-limit": [
|
|
101
92
|
{
|
|
@@ -121,16 +112,13 @@
|
|
|
121
112
|
"bundle:es5": "webpack -c ./webpack.es5.cjs",
|
|
122
113
|
"bundle:esm": "webpack -c ./webpack.esm.cjs",
|
|
123
114
|
"clean": "rimraf cjs coverage dist esm lib libm tslib --glob *.tsbuildinfo",
|
|
124
|
-
"coverage": "
|
|
115
|
+
"coverage": "vitest run --coverage",
|
|
125
116
|
"depcheck": "depcheck",
|
|
126
|
-
"lint": "cross-env TIMING=1 eslint --ext=ts,js,cjs,mjs .",
|
|
127
117
|
"nuke": "run-s clean nuke:local",
|
|
128
118
|
"nuke:local": "rimraf node_modules",
|
|
129
119
|
"size": "size-limit",
|
|
130
|
-
"test": "
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch",
|
|
134
|
-
"w": "pnpm watch"
|
|
120
|
+
"test": "vitest run",
|
|
121
|
+
"verify": "npm-run-all -p build depcheck coverage -p size",
|
|
122
|
+
"w": "vitest"
|
|
135
123
|
}
|
|
136
124
|
}
|
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
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
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(
|
|
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 `(${
|
|
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
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 {
|
|
4
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 {
|
|
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
package/ts/standard_log.ts
CHANGED
|
@@ -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
|
}
|
package/ts/testing/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { MemoryLogReporter } from '../memory.js'
|
|
2
2
|
export {
|
|
3
3
|
createStandardLogForTest,
|
|
4
|
-
type
|
|
5
|
-
type
|
|
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
|
|