standard-log 13.3.0 → 13.3.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.
- package/cjs/console.d.ts +5 -6
- package/cjs/console.d.ts.map +1 -1
- package/cjs/console.js +2 -2
- package/cjs/console.js.map +1 -1
- package/cjs/errors.d.ts +2 -3
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/formatter.d.ts +5 -6
- package/cjs/formatter.d.ts.map +1 -1
- package/cjs/log_levels.d.ts +4 -5
- package/cjs/log_levels.d.ts.map +1 -1
- package/cjs/log_store.d.ts +4 -5
- package/cjs/log_store.d.ts.map +1 -1
- package/cjs/log_store.js +7 -7
- package/cjs/log_store.js.map +1 -1
- package/cjs/logger.d.ts +1 -2
- package/cjs/logger.d.ts.map +1 -1
- package/cjs/memory.d.ts +5 -6
- package/cjs/memory.d.ts.map +1 -1
- package/cjs/memory.js +4 -4
- package/cjs/memory.js.map +1 -1
- package/cjs/platform.browser.d.ts +2 -3
- package/cjs/platform.browser.d.ts.map +1 -1
- package/cjs/platform.browser.js +2 -2
- package/cjs/platform.browser.js.map +1 -1
- package/cjs/platform.d.ts +2 -3
- package/cjs/platform.d.ts.map +1 -1
- package/cjs/platform.js +2 -2
- package/cjs/platform.js.map +1 -1
- package/cjs/record.d.ts +9 -0
- package/cjs/record.d.ts.map +1 -0
- package/cjs/record.js +15 -0
- package/cjs/record.js.map +1 -0
- package/cjs/standard_log.ctx.d.ts +1 -2
- package/cjs/standard_log.ctx.d.ts.map +1 -1
- package/cjs/standard_log.ctx.js +1 -1
- package/cjs/standard_log.ctx.js.map +1 -1
- package/cjs/standard_log.d.ts +7 -8
- package/cjs/standard_log.d.ts.map +1 -1
- package/cjs/standard_log.js +4 -3
- package/cjs/standard_log.js.map +1 -1
- package/cjs/standard_log.testing.d.ts +3 -4
- package/cjs/standard_log.testing.d.ts.map +1 -1
- package/cjs/types.d.ts +20 -18
- package/cjs/types.d.ts.map +1 -1
- package/dist/standard-log.esm.js +15 -31
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.iife.js +15 -31
- package/dist/standard-log.iife.js.map +1 -1
- package/esm/console.d.ts +5 -6
- package/esm/console.d.ts.map +1 -1
- package/esm/console.js +1 -1
- package/esm/console.js.map +1 -1
- package/esm/errors.d.ts +2 -3
- package/esm/errors.d.ts.map +1 -1
- package/esm/formatter.d.ts +5 -6
- package/esm/formatter.d.ts.map +1 -1
- package/esm/log_levels.d.ts +4 -5
- package/esm/log_levels.d.ts.map +1 -1
- package/esm/log_store.d.ts +4 -5
- package/esm/log_store.d.ts.map +1 -1
- package/esm/log_store.js +4 -4
- package/esm/log_store.js.map +1 -1
- package/esm/logger.d.ts +1 -2
- package/esm/logger.d.ts.map +1 -1
- package/esm/memory.d.ts +5 -6
- package/esm/memory.d.ts.map +1 -1
- package/esm/memory.js +1 -1
- package/esm/memory.js.map +1 -1
- package/esm/platform.browser.d.ts +2 -3
- package/esm/platform.browser.d.ts.map +1 -1
- package/esm/platform.browser.js +1 -1
- package/esm/platform.browser.js.map +1 -1
- package/esm/platform.d.ts +2 -3
- package/esm/platform.d.ts.map +1 -1
- package/esm/platform.js +1 -1
- package/esm/platform.js.map +1 -1
- package/esm/record.d.ts +9 -0
- package/esm/record.d.ts.map +1 -0
- package/esm/record.js +14 -0
- package/esm/record.js.map +1 -0
- package/esm/standard_log.ctx.d.ts +1 -2
- package/esm/standard_log.ctx.d.ts.map +1 -1
- package/esm/standard_log.ctx.js +1 -1
- package/esm/standard_log.ctx.js.map +1 -1
- package/esm/standard_log.d.ts +7 -8
- package/esm/standard_log.d.ts.map +1 -1
- package/esm/standard_log.js +2 -1
- package/esm/standard_log.js.map +1 -1
- package/esm/standard_log.testing.d.ts +3 -4
- package/esm/standard_log.testing.d.ts.map +1 -1
- package/esm/types.d.ts +20 -18
- package/esm/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/ts/console.ts +1 -1
- package/ts/log_store.ts +4 -6
- package/ts/memory.ts +1 -1
- package/ts/platform.browser.ts +1 -1
- package/ts/platform.ts +1 -1
- package/ts/record.ts +9 -0
- package/ts/standard_log.ctx.ts +1 -1
- package/ts/standard_log.ts +2 -1
- package/ts/types.ts +5 -3
package/esm/platform.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ConsoleLike, LogEntry } from "./types.js";
|
|
2
2
|
//#region ts/platform.d.ts
|
|
3
|
-
declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
|
|
4
|
-
declare const polyfill: {
|
|
3
|
+
export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
|
|
4
|
+
export declare const polyfill: {
|
|
5
5
|
console?: ConsoleLike;
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
|
8
|
-
export { polyfill, toInspectLogEntry };
|
|
9
8
|
//# sourceMappingURL=platform.d.ts.map
|
package/esm/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","names":[],"sources":["../ts/platform.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","names":[],"sources":["../ts/platform.ts"],"mappings":";;qBAIa,oBAAiB,GAAO,aAAQ;qBAIhC;EAAY,UAAU"}
|
package/esm/platform.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { record } from "
|
|
1
|
+
import { record } from "./record.js";
|
|
2
2
|
import { inspect } from "node:util";
|
|
3
3
|
//#region ts/platform.ts
|
|
4
4
|
const toInspectLogEntry = (e) => (e.args = e.args.map((value) => typeof value === "object" && value !== null ? inspect(value) : value), e);
|
package/esm/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","names":[],"sources":["../ts/platform.ts"],"sourcesContent":["import { inspect } from 'node:util'\nimport { record } from '
|
|
1
|
+
{"version":3,"file":"platform.js","names":[],"sources":["../ts/platform.ts"],"sourcesContent":["import { inspect } from 'node:util'\nimport { record } from './record.js'\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"],"mappings":";;;AAIA,MAAa,qBAAqB,OAChC,EAAE,OAAO,EAAE,KAAK,KAAI,UAAU,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,KAAK,IAAI,KAAM,GAAI;AAGzG,MAAa,WAAsC,OAAO"}
|
package/esm/record.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region ts/record.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a prototype-less object, optionally seeded with `value`.
|
|
4
|
+
*
|
|
5
|
+
* Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function record<R extends Record<any, any>>(value?: R): R;
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","names":[],"sources":["../ts/record.ts"],"mappings":";;;;;;wBAKgB,OAAO,UAAU,kBAAkB,QAAQ,IAAI"}
|
package/esm/record.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region ts/record.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a prototype-less object, optionally seeded with `value`.
|
|
4
|
+
*
|
|
5
|
+
* Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
|
|
6
|
+
*/
|
|
7
|
+
function record(value) {
|
|
8
|
+
const r = Object.create(null);
|
|
9
|
+
return value ? Object.assign(r, value) : r;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { record };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","names":[],"sources":["../ts/record.ts"],"sourcesContent":["/**\n * Creates a prototype-less object, optionally seeded with `value`.\n *\n * Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.\n */\nexport function record<R extends Record<any, any>>(value?: R): R {\n\tconst r = Object.create(null)\n\treturn value ? Object.assign(r, value) : r\n}\n"],"mappings":";;;;;;AAKA,SAAgB,OAAmC,OAAc;CAChE,MAAM,IAAI,OAAO,OAAO,IAAI;CAC5B,OAAO,QAAQ,OAAO,OAAO,GAAG,KAAK,IAAI;AAC1C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LogMethodNames, StandardLogInstance } from "./types.js";
|
|
2
2
|
import { LogStore } from "./log_store.js";
|
|
3
3
|
//#region ts/standard_log.ctx.d.ts
|
|
4
|
-
declare const ctx: {
|
|
4
|
+
export declare const ctx: {
|
|
5
5
|
configured?: boolean;
|
|
6
6
|
gsl?: {
|
|
7
7
|
store: LogStore;
|
|
@@ -9,5 +9,4 @@ declare const ctx: {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
12
|
-
export { ctx };
|
|
13
12
|
//# sourceMappingURL=standard_log.ctx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.ctx.d.ts","names":[],"sources":["../ts/standard_log.ctx.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"standard_log.ctx.d.ts","names":[],"sources":["../ts/standard_log.ctx.ts"],"mappings":";;;qBAIa;EACZ;EACA;IAAQ,OAAO;IAAU,aAAa,oBAAoB"}
|
package/esm/standard_log.ctx.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.ctx.js","names":[],"sources":["../ts/standard_log.ctx.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"standard_log.ctx.js","names":[],"sources":["../ts/standard_log.ctx.ts"],"sourcesContent":["import type { LogStore } from './log_store.js'\nimport { record } from './record.js'\nimport type { LogMethodNames, StandardLogInstance } from './types.js'\n\nexport const ctx: {\n\tconfigured?: boolean\n\tgsl?: { store: LogStore; standardLog: StandardLogInstance<LogMethodNames> }\n} = record()\n"],"mappings":";;AAIA,MAAa,MAGT,OAAO"}
|
package/esm/standard_log.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { LogMethodNames, Logger, LoggerOptions, StandardLogInstance, StandardLogOptions } from "./types.js";
|
|
2
2
|
import { LogStore } from "./log_store.js";
|
|
3
3
|
//#region ts/standard_log.d.ts
|
|
4
|
-
interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}
|
|
5
|
-
declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
|
|
6
|
-
declare function createStandardLogClosure<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): {
|
|
4
|
+
export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}
|
|
5
|
+
export declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
|
|
6
|
+
export declare function createStandardLogClosure<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): {
|
|
7
7
|
store: LogStore;
|
|
8
8
|
standardLog: StandardLog<N>;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
11
|
* Suppress logging within the code block.
|
|
12
12
|
*/
|
|
13
|
-
declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
|
|
14
|
-
type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
|
|
15
|
-
declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
|
|
16
|
-
declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
|
|
13
|
+
export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
|
|
14
|
+
export type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
|
|
15
|
+
export declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
|
|
16
|
+
export declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
|
|
17
17
|
//#endregion
|
|
18
|
-
export { GetLogger, StandardLog, configGlobal, createStandardLog, createStandardLogClosure, getLogger, suppressLogs };
|
|
19
18
|
//# sourceMappingURL=standard_log.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.d.ts","names":[],"sources":["../ts/standard_log.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"standard_log.d.ts","names":[],"sources":["../ts/standard_log.ts"],"mappings":";;;iBAciB,YAAY,mBAAmB,wBAAwB,SAAS,oBAAoB;wBAErF,kBAAkB,mBAAmB,gBACpD,UAAU,mBAAmB,KAC3B,YAAY;wBAeC,yBAAyB,mBAAmB,gBAC3D,UAAU,mBAAmB;EACzB,OAAO;EAAU,aAAa,YAAY;;;;;wBA4D/B,aAAa,GAAG,aAAa,GAAG,KAAK,WAAW,MAAM,WAAW;YASrE,UAAU,mBAAmB,mBACxC,YACA,UAAU,kBACN,OAAO,iBAAiB;wBAEb,UAAU,mBAAmB,gBAAgB,YAAY,UAAU,gBAAa,OAAA,IAAA;wBAUhF,aAAa,SAAS,KAAK"}
|
package/esm/standard_log.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_LOG_METHOD_NAMES, logLevels } from "./log_levels.js";
|
|
2
|
+
import { record } from "./record.js";
|
|
2
3
|
import { createLogStore } from "./log_store.js";
|
|
3
4
|
import { createLogger } from "./logger.js";
|
|
4
5
|
import { ctx } from "./standard_log.ctx.js";
|
|
5
|
-
import {
|
|
6
|
+
import { required } from "unpartial";
|
|
6
7
|
//#region ts/standard_log.ts
|
|
7
8
|
function createStandardLog(options) {
|
|
8
9
|
const closure = createStandardLogClosure(options);
|
package/esm/standard_log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.js","names":[],"sources":["../ts/standard_log.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"standard_log.js","names":[],"sources":["../ts/standard_log.ts"],"sourcesContent":["import { required } from 'unpartial'\nimport { DEFAULT_LOG_METHOD_NAMES, logLevels } from './log_levels.js'\nimport { createLogStore, type LogStore } from './log_store.js'\nimport { createLogger } from './logger.js'\nimport { record } from './record.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"],"mappings":";;;;;;;AAgBA,SAAgB,kBACf,SACiB;CACjB,MAAM,UAAU,yBAAyB,OAAO;CAChD,IAAI,SAAS,WAAW,MAAK,MAAK,CAAC,EAAE,EAAE,GAEtC,QADoB,YAAY,UAAU,cACxC,CAAC,CAAC,SACH,+JACD;CAGD,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM;CACxB,OAAO,QAAQ;AAChB;AAEA,SAAS,OAAO,CAAC;AAEjB,SAAgB,yBACf,SACmD;CAEnD,MAAM,QAAQ,eAAe,SAAS,EAAE,UAAU,UAAU,KAAK,GAAG,OAAO,CAAC;CAC5E,MAAM,sBAAsB,SAAS,WAAW,QAAO,MAAK,CAAC,EAAE,iBAAiB,CAAC,CAAC,KAAI,MAAK,EAAE,EAAE,KAAK,CAAC;CACrG,MAAM,aAAa,yBAAyB,OAAO,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;EACnG;EACA;EACA;CACD,CAAC;CACD,OAAO;EACN;EACA,aAAa;GACZ,IAAI,WAAW;IACd,OAAO,MAAM;GACd;GAEA,eAAe,OAAe;IAC7B,OAAO,MAAM,cAAc,QAAQ,KAAK;GACzC;GACA,WAAW,MAAc;IACxB,OAAO,MAAM,cAAc,SAAS,IAAI;GACzC;GACA,UAAU,IAAY,SAAyB;IAC9C,IAAI,MAAM,QAAQ,KAAK,OAAO,MAAM,QAAQ;IAC5C,OAAQ,MAAM,QAAQ,MAAM,aAAa,OAAO,IAAI;KAAE,KAAK,KAAK;KAAW,GAAG;IAAQ,CAAC;GACxF;GACA,oBAAoB,IAAI,SAAU;IACjC,IAAI,MAAM,kBAAkB,KAAK,OAAO,MAAM,kBAAkB;IAEhE,IAAI,MAAM,QAAQ,KAAK;KAEtB,KADiB,UAAU,cACzB,CAAC,CAAC,KAAK,6DAA6D,GAAG,aAAa;KACtF,OAAQ,MAAM,kBAAkB,MAAM,kBAAkB,UAAU;IACnE;IAEA,OAAQ,MAAM,kBAAkB,MAC/B,oBAAoB,WAAW,IAC5B,kBAAkB,UAAU,IAC5B,aAAa,OAAO,IAAI;KACxB,KAAK,KAAK;KACV,GAAG;KACH,QAAQ,YAAY;MACnB,OAAO,oBAAoB,QAAQ,UAAU,KAAK;KACnD;IACD,CAAC;GACL;EACD;CACD;AACD;AAEA,SAAS,kBAAkB,YAAsB;CAChD,OAAO,WAAW,QAAQ,GAAG,MAAM;EAClC,EAAE,KAAK;EACP,OAAO;CACR,GAAG,OAAO,CAAC;AACZ;AAMA,SAAgB,aAAgB,OAAgB,GAAG,MAAmB;CACrE,MAAM,aAAa,KAAK,KAAI,MAAK,EAAE,KAAK;CACxC,KAAK,SAAQ,MAAM,EAAE,QAAQ,UAAU,IAAK;CAC5C,MAAM,SAAS,MAAM;CACrB,KAAK,SAAS,GAAG,MAAO,EAAE,QAAQ,WAAW,EAAG;CAChD,OAAO;AACR;AAOA,SAAgB,UAA6C,IAAY,SAAyB;CACjG,OAAO,YAAe,CAAC,CAAC,UAAU,IAAI,OAAO;AAC9C;AAEA,SAAS,cAAyE;CACjF,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,yBAAyB;CAEjD,OAAO,IAAI,IAAK;AACjB;AAEA,SAAgB,aAAa,SAAmD;CAC/E,IAAI,IAAI,YAEP,IADgB,IAAK,YAAY,UAAU,cACzC,CAAC,CAAC,KACH,kJACD;CAGD,IAAI,IAAI,KAAK;EACZ,IAAI,QAAQ,UACX,IAAI,IAAI,MAAM,WAAW,QAAQ;EAElC,IAAI,QAAQ,WAAW;GACtB,MAAM,YAAY,IAAI,IAAI,MAAM;GAChC,UAAU,SAAS;GACnB,UAAU,KAAK,GAAG,QAAQ,SAAS;EACpC;CACD,OACC,IAAI,MAAM,yBAAyB,OAAO;CAE3C,IAAI,aAAa;AAClB"}
|
|
@@ -2,7 +2,7 @@ import { LogMethodNames, StandardLogOptions } from "./types.js";
|
|
|
2
2
|
import { MemoryLogReporter } from "./memory.js";
|
|
3
3
|
import { StandardLog } from "./standard_log.js";
|
|
4
4
|
//#region ts/standard_log.testing.d.ts
|
|
5
|
-
type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {
|
|
5
|
+
export type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {
|
|
6
6
|
/**
|
|
7
7
|
* Send the logs to console for easy debugging.
|
|
8
8
|
*
|
|
@@ -10,10 +10,9 @@ type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogO
|
|
|
10
10
|
*/
|
|
11
11
|
emitLog?: boolean;
|
|
12
12
|
};
|
|
13
|
-
type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
|
|
13
|
+
export type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
|
|
14
14
|
reporter: MemoryLogReporter;
|
|
15
15
|
};
|
|
16
|
-
declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogForTestOptions<N>): StandardLogForTest<N>;
|
|
16
|
+
export declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogForTestOptions<N>): StandardLogForTest<N>;
|
|
17
17
|
//#endregion
|
|
18
|
-
export { StandardLogForTest, StandardLogForTestOptions, createStandardLogForTest };
|
|
19
18
|
//# sourceMappingURL=standard_log.testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.testing.d.ts","names":[],"sources":["../ts/standard_log.testing.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"standard_log.testing.d.ts","names":[],"sources":["../ts/standard_log.testing.ts"],"mappings":";;;;YAMY,0BAA0B,mBAAmB,kBAAkB,mBAAmB;;;;;;EAM7F;;YAGW,mBAAmB,mBAAmB,kBAAkB,YAAY;EAC/E,UAAU;;wBAGK,yBAAyB,mBAAmB,gBAC3D,UAAS,0BAA0B,KACjC,mBAAmB"}
|
package/esm/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { StackTraceMeta } from "@just-func/types";
|
|
2
1
|
//#region ts/types.d.ts
|
|
3
|
-
type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
2
|
+
export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
4
3
|
/**
|
|
5
4
|
* A map of custom log levels.
|
|
6
5
|
*
|
|
@@ -19,11 +18,15 @@ type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
|
19
18
|
logLevel?: number;
|
|
20
19
|
reporters?: LogReporter[];
|
|
21
20
|
};
|
|
22
|
-
interface LoggerOptions
|
|
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;
|
|
23
26
|
level?: number;
|
|
24
27
|
writeTo?: LogReporter | ReporterFilter;
|
|
25
28
|
}
|
|
26
|
-
type Logger<N extends string = LogMethodNames> = {
|
|
29
|
+
export type Logger<N extends string = LogMethodNames> = {
|
|
27
30
|
readonly id: string;
|
|
28
31
|
/**
|
|
29
32
|
* Logger local log level.
|
|
@@ -43,17 +46,17 @@ type Logger<N extends string = LogMethodNames> = {
|
|
|
43
46
|
/**
|
|
44
47
|
* Names of the standard log methods.
|
|
45
48
|
*/
|
|
46
|
-
type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
|
|
47
|
-
type LogEntry = {
|
|
49
|
+
export type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
|
|
50
|
+
export type LogEntry = {
|
|
48
51
|
id: string;
|
|
49
52
|
level: number;
|
|
50
53
|
args: any[];
|
|
51
54
|
timestamp: Date;
|
|
52
55
|
};
|
|
53
|
-
type LogMethod = (...args: any[]) => void;
|
|
54
|
-
type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
|
|
55
|
-
type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
|
|
56
|
-
interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
56
|
+
export type LogMethod = (...args: any[]) => void;
|
|
57
|
+
export type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
|
|
58
|
+
export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
|
|
59
|
+
export interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
57
60
|
/**
|
|
58
61
|
* The current log level.
|
|
59
62
|
*/
|
|
@@ -94,16 +97,16 @@ interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
|
94
97
|
* Depends on the reporter, it can expect a different return type.
|
|
95
98
|
* By default the return type is `any[]` which the `console` accepts.
|
|
96
99
|
*/
|
|
97
|
-
type LogFormatter<T = any[]> = (entry: LogEntry) => T;
|
|
100
|
+
export type LogFormatter<T = any[]> = (entry: LogEntry) => T;
|
|
98
101
|
/**
|
|
99
102
|
* Determines whether the entry should be written.
|
|
100
103
|
*/
|
|
101
|
-
type LogFilter = (entry: LogEntry) => boolean;
|
|
102
|
-
type LogLevelEntry = {
|
|
104
|
+
export type LogFilter = (entry: LogEntry) => boolean;
|
|
105
|
+
export type LogLevelEntry = {
|
|
103
106
|
name: string;
|
|
104
107
|
level: number;
|
|
105
108
|
};
|
|
106
|
-
interface LogReporter<T = any> {
|
|
109
|
+
export interface LogReporter<T = any> {
|
|
107
110
|
readonly id: string;
|
|
108
111
|
/**
|
|
109
112
|
* Specifies the formatter to be used by the reporter.
|
|
@@ -121,7 +124,7 @@ interface LogReporter<T = any> {
|
|
|
121
124
|
readonly isConsoleReporter?: boolean;
|
|
122
125
|
write(entry: LogEntry): void;
|
|
123
126
|
}
|
|
124
|
-
type LogReporterOptions<T = any> = {
|
|
127
|
+
export type LogReporterOptions<T = any> = {
|
|
125
128
|
id?: string;
|
|
126
129
|
/**
|
|
127
130
|
* Specifies the formatter to be used by the reporter.
|
|
@@ -133,13 +136,12 @@ type LogReporterOptions<T = any> = {
|
|
|
133
136
|
*/
|
|
134
137
|
filter?: LogFilter;
|
|
135
138
|
};
|
|
136
|
-
type LogLevel = number;
|
|
137
|
-
interface ConsoleLike {
|
|
139
|
+
export type LogLevel = number;
|
|
140
|
+
export interface ConsoleLike {
|
|
138
141
|
debug(...args: any[]): void;
|
|
139
142
|
info(...args: any[]): void;
|
|
140
143
|
warn(...args: any[]): void;
|
|
141
144
|
error(...args: any[]): void;
|
|
142
145
|
}
|
|
143
146
|
//#endregion
|
|
144
|
-
export { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, Logger, LoggerOptions, ReporterFilter, StandardLogInstance, StandardLogOptions };
|
|
145
147
|
//# sourceMappingURL=types.d.ts.map
|
package/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":";YAAY,mBAAmB,kCAAkC;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;iBAGI;;;;EAIhB,UAAU;EACV;EACA,UAAU,cAAc;;YAGb,OAAO,mBAAmB;WAC5B;;;;EAIT;;;;;EAKA,SAAS;EACT,GAAG,gBAAgB,GAAG,aAAa;;;;EAInC,MAAM,OAAO;OACP,KAAK,IAAI;;;;YAKJ;YAYA;EACX;EACA;EAEA;EACA,WAAW;;YAGA,gBAAgB;YAEhB,eAAe,KAAK,WAAW;YAE/B,0BAA0B,WAAW;iBAEhC,oBAAoB,mBAAmB;;;;EAIvD;;;;EAIA,eAAe;;;;EAIf,WAAW,MAAM;;;;;;;;;;EAUjB,UAAU,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;;;;;;EAY3D,oBAAoB,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;YAQ1D,aAAa,cAAc,OAAO,aAAa;;;;YAK/C,aAAa,OAAO;YAEpB;EAAkB;EAAc;;iBAE3B,YAAY;WACnB;;;;;WAKA,WAAW,aAAa;;;;WAIxB,SAAS;;;;;WAKT;EACT,MAAM,OAAO;;YAGF,mBAAmB;EAC9B;;;;;EAKA,YAAY,aAAa;;;;EAIzB,SAAS;;YAGE;iBAEK;EAChB,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "standard-log",
|
|
3
|
-
"version": "13.3.
|
|
3
|
+
"version": "13.3.2",
|
|
4
4
|
"description": "The standard log library",
|
|
5
5
|
"homepage": "https://github.com/cyberuni/standard-log/tree/main/packages/log",
|
|
6
6
|
"bugs": {
|
|
@@ -58,24 +58,24 @@
|
|
|
58
58
|
"!**/test_utils.*"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@just-func/types": "^0.6.0",
|
|
62
61
|
"iso-error": "^7.0.0",
|
|
63
62
|
"ms": "^2.1.3",
|
|
64
|
-
"
|
|
63
|
+
"unpartial": "^1.0.8"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
|
-
"@repobuddy/vitest": "^
|
|
66
|
+
"@repobuddy/vitest": "^3.0.0",
|
|
68
67
|
"@types/ms": "^2.0.0",
|
|
69
68
|
"@types/node": "^24.0.0",
|
|
70
69
|
"@types/ramda": "^0.32.0",
|
|
71
|
-
"assertron": "^11.
|
|
70
|
+
"assertron": "^11.7.2",
|
|
72
71
|
"depcheck": "^1.4.3",
|
|
73
72
|
"dirname-filename-esm": "^1.1.1",
|
|
74
73
|
"ramda": "^0.32.0",
|
|
75
74
|
"rimraf": "^6.0.0",
|
|
76
|
-
"tsdown": "^0.
|
|
75
|
+
"tsdown": "^0.23.0",
|
|
76
|
+
"type-plus": "8.0.0",
|
|
77
77
|
"typescript": "^7.0.2",
|
|
78
|
-
"vitest": "^
|
|
78
|
+
"vitest": "^5.0.0"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsdown",
|
package/ts/console.ts
CHANGED
package/ts/log_store.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mapKey, record, reduceByKey, reduceKey } 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:
|
|
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
|
|
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
|
-
|
|
57
|
+
Object.keys(store.customLevels).map(name => ({ name, level: store.customLevels[name] }))
|
|
60
58
|
)
|
|
61
59
|
}
|
|
62
60
|
}
|
package/ts/memory.ts
CHANGED
package/ts/platform.browser.ts
CHANGED
package/ts/platform.ts
CHANGED
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
|
+
}
|
package/ts/standard_log.ctx.ts
CHANGED
package/ts/standard_log.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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
|
}
|