standard-log 13.3.0 → 13.3.1
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 +1 -1
- 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 +3 -2
- 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.d.ts +2 -3
- package/cjs/platform.d.ts.map +1 -1
- package/cjs/platform.js +1 -1
- package/cjs/standard_log.ctx.d.ts +1 -2
- package/cjs/standard_log.ctx.d.ts.map +1 -1
- package/cjs/standard_log.d.ts +7 -8
- package/cjs/standard_log.d.ts.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 +16 -17
- package/cjs/types.d.ts.map +1 -1
- package/dist/standard-log.esm.js +104 -45
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.iife.js +104 -45
- 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 +2 -2
- 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 +2 -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.d.ts +2 -3
- package/esm/platform.d.ts.map +1 -1
- package/esm/platform.js +1 -1
- package/esm/standard_log.ctx.d.ts +1 -2
- package/esm/standard_log.ctx.d.ts.map +1 -1
- package/esm/standard_log.d.ts +7 -8
- package/esm/standard_log.d.ts.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 +16 -17
- package/esm/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/ts/console.ts +1 -1
- package/ts/log_store.ts +2 -2
- package/ts/memory.ts +2 -1
package/cjs/console.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ConsoleLike, LogFormatter, LogReporter, LogReporterOptions } from "./types.js";
|
|
2
2
|
//#region ts/console.d.ts
|
|
3
|
-
declare function toConsoleMethod(level: number): "debug" | "error" | "info" | "warn";
|
|
4
|
-
type ConsoleLogFormatter = LogFormatter<any[]>;
|
|
5
|
-
type ConsoleLogReporter = LogReporter<any[]> & {
|
|
3
|
+
export declare function toConsoleMethod(level: number): "debug" | "error" | "info" | "warn";
|
|
4
|
+
export type ConsoleLogFormatter = LogFormatter<any[]>;
|
|
5
|
+
export type ConsoleLogReporter = LogReporter<any[]> & {
|
|
6
6
|
console: ConsoleLike;
|
|
7
7
|
};
|
|
8
|
-
type ConsoleLogReporterOptions = LogReporterOptions<any[]>;
|
|
9
|
-
declare function createConsoleLogReporter(options?: ConsoleLogReporterOptions): ConsoleLogReporter;
|
|
8
|
+
export type ConsoleLogReporterOptions = LogReporterOptions<any[]>;
|
|
9
|
+
export declare function createConsoleLogReporter(options?: ConsoleLogReporterOptions): ConsoleLogReporter;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { ConsoleLogFormatter, ConsoleLogReporter, ConsoleLogReporterOptions, createConsoleLogReporter, toConsoleMethod };
|
|
12
11
|
//# sourceMappingURL=console.d.ts.map
|
package/cjs/console.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.ts","names":[],"sources":["../ts/console.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"console.d.ts","names":[],"sources":["../ts/console.ts"],"mappings":";;wBAMgB,gBAAgB;YA8CpB,sBAAsB;YACtB,qBAAqB;EAAuB,SAAS;;YACrD,4BAA4B;wBAExB,yBAAyB,UAAU,4BAA4B"}
|
package/cjs/console.js
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_log_levels = require("./log_levels.js");
|
|
3
3
|
const require_formatter = require("./formatter.js");
|
|
4
4
|
const require_platform = require("./platform.js");
|
|
5
|
-
let
|
|
5
|
+
let unpartial = require("unpartial");
|
|
6
6
|
//#region ts/console.ts
|
|
7
7
|
function toConsoleMethod(level) {
|
|
8
8
|
switch (true) {
|
|
@@ -35,7 +35,7 @@ function buildFn(name) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function createConsoleLogReporter(options) {
|
|
38
|
-
const { id, formatter, filter } = (0,
|
|
38
|
+
const { id, formatter, filter } = (0, unpartial.unpartial)({
|
|
39
39
|
id: "console",
|
|
40
40
|
formatter: require_formatter.consoleFormatter
|
|
41
41
|
}, options);
|
package/cjs/console.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","names":["logLevels","
|
|
1
|
+
{"version":3,"file":"console.js","names":["logLevels","consoleFormatter","polyfill"],"sources":["../ts/console.ts"],"sourcesContent":["import { unpartial } from 'unpartial'\nimport { consoleFormatter } from './formatter.js'\nimport { logLevels } from './log_levels.js'\nimport { polyfill } from './platform.js'\nimport type { ConsoleLike, LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport function toConsoleMethod(level: number) {\n\tswitch (true) {\n\t\t// edge case in case none is somehow written\n\t\tcase level <= 0:\n\t\t\treturn 'debug'\n\t\tcase level <= logLevels.error:\n\t\t\treturn 'error'\n\t\tcase level <= logLevels.warn:\n\t\t\treturn 'warn'\n\t\tcase level <= logLevels.info:\n\t\t\treturn 'info'\n\t\tdefault:\n\t\t\treturn 'debug'\n\t}\n}\n\n// istanbul ignore next\n/* eslint-disable no-console */\nfunction buildPolyfillConsole() {\n\t// old phantomjs does not have bind function\n\tconst hasBind = !!console.log.bind as boolean\n\tif (hasBind) {\n\t\treturn {\n\t\t\t// the `typeof` guards against IE where `console.log.apply()`\n\t\t\t// results in error `Object doesn't support property or method 'apply'`\n\t\t\tdebug: (typeof console.info === 'function' ? console.debug : console.log).bind(console),\n\t\t\tinfo: (typeof console.info === 'function' ? console.info : console.log).bind(console),\n\t\t\twarn: (typeof console.warn === 'function' ? console.warn : console.log).bind(console),\n\t\t\terror: (typeof console.error === 'function' ? console.error : console.log).bind(console)\n\t\t}\n\t}\n\treturn {\n\t\tdebug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),\n\t\tinfo: buildFn(typeof console.info === 'function' ? 'info' : 'log'),\n\t\twarn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),\n\t\terror: buildFn(typeof console.error === 'function' ? 'error' : 'log')\n\t}\n}\n\n// istanbul ignore next\nfunction buildFn(name: 'debug' | 'info' | 'warn' | 'error' | 'log') {\n\treturn (...args: any[]) => {\n\t\tconsole[name](...args)\n\t}\n}\n\nexport type ConsoleLogFormatter = LogFormatter<any[]>\nexport type ConsoleLogReporter = LogReporter<any[]> & { console: ConsoleLike }\nexport type ConsoleLogReporterOptions = LogReporterOptions<any[]>\n\nexport function createConsoleLogReporter(options?: ConsoleLogReporterOptions): ConsoleLogReporter {\n\tconst { id, formatter, filter } = unpartial({ id: 'console', formatter: consoleFormatter }, options)\n\tif (!polyfill.console) polyfill.console = buildPolyfillConsole()\n\n\treturn Object.freeze({\n\t\tid,\n\t\tisConsoleReporter: true,\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\tconsole: polyfill.console,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tconst values = formatter(entry)\n\t\t\tconst method = toConsoleMethod(entry.level)\n\t\t\tthis.console[method](...values)\n\t\t}\n\t})\n}\n"],"mappings":";;;;;;AAMA,SAAgB,gBAAgB,OAAe;CAC9C,QAAQ,MAAR;EAEC,KAAK,SAAS,GACb,OAAO;EACR,KAAK,SAASA,mBAAAA,UAAU,OACvB,OAAO;EACR,KAAK,SAASA,mBAAAA,UAAU,MACvB,OAAO;EACR,KAAK,SAASA,mBAAAA,UAAU,MACvB,OAAO;EACR,SACC,OAAO;CACT;AACD;;AAIA,SAAS,uBAAuB;CAG/B,IAAI,CADa,CAAC,QAAQ,IAAI,MAE7B,OAAO;EAGN,QAAQ,OAAO,QAAQ,SAAS,aAAa,QAAQ,QAAQ,QAAQ,IAAA,CAAK,KAAK,OAAO;EACtF,OAAO,OAAO,QAAQ,SAAS,aAAa,QAAQ,OAAO,QAAQ,IAAA,CAAK,KAAK,OAAO;EACpF,OAAO,OAAO,QAAQ,SAAS,aAAa,QAAQ,OAAO,QAAQ,IAAA,CAAK,KAAK,OAAO;EACpF,QAAQ,OAAO,QAAQ,UAAU,aAAa,QAAQ,QAAQ,QAAQ,IAAA,CAAK,KAAK,OAAO;CACxF;CAED,OAAO;EACN,OAAO,QAAQ,OAAO,QAAQ,UAAU,aAAa,UAAU,KAAK;EACpE,MAAM,QAAQ,OAAO,QAAQ,SAAS,aAAa,SAAS,KAAK;EACjE,MAAM,QAAQ,OAAO,QAAQ,SAAS,aAAa,SAAS,KAAK;EACjE,OAAO,QAAQ,OAAO,QAAQ,UAAU,aAAa,UAAU,KAAK;CACrE;AACD;;AAGA,SAAS,QAAQ,MAAmD;CACnE,QAAQ,GAAG,SAAgB;EAC1B,QAAQ,KAAK,CAAC,GAAG,IAAI;CACtB;AACD;AAMA,SAAgB,yBAAyB,SAAyD;CACjG,MAAM,EAAE,IAAI,WAAW,YAAA,GAAW,UAAA,UAAA,CAAU;EAAE,IAAI;EAAW,WAAWC,kBAAAA;CAAiB,GAAG,OAAO;CACnG,IAAI,CAACC,iBAAAA,SAAS,SAAS,iBAAA,SAAS,UAAU,qBAAqB;CAE/D,OAAO,OAAO,OAAO;EACpB;EACA,mBAAmB;EACnB,IAAI,YAAY;GACf,OAAO;EACR;EACA,IAAI,SAAS;GACZ,OAAO;EACR;EACA,SAASA,iBAAAA,SAAS;EAClB,MAAM,OAAiB;GACtB,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG;GAC9B,MAAM,SAAS,UAAU,KAAK;GAC9B,MAAM,SAAS,gBAAgB,MAAM,KAAK;GAC1C,KAAK,QAAQ,OAAO,CAAC,GAAG,MAAM;EAC/B;CACD,CAAC;AACF"}
|
package/cjs/errors.d.ts
CHANGED
|
@@ -3,16 +3,15 @@ import { IsoError, ModuleError } from "iso-error";
|
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated No longer used since 11.2.0
|
|
5
5
|
*/
|
|
6
|
-
declare class StandardLogError extends ModuleError {
|
|
6
|
+
export declare class StandardLogError extends ModuleError {
|
|
7
7
|
constructor(description: string, options?: IsoError.Options);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* @deprecated no longer used since 11.2.0
|
|
11
11
|
*/
|
|
12
|
-
declare class InvalidId extends StandardLogError {
|
|
12
|
+
export declare class InvalidId extends StandardLogError {
|
|
13
13
|
id: string;
|
|
14
14
|
constructor(id: string, options?: IsoError.Options);
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
|
-
export { InvalidId, StandardLogError };
|
|
18
17
|
//# sourceMappingURL=errors.d.ts.map
|
package/cjs/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../ts/errors.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../ts/errors.ts"],"mappings":";;;;;qBAKa,yBAAyB;EACrC,YAAY,qBAAqB,UAAU,SAAS;;;;;qBAQxC,kBAAkB;EAEtB;EADR,YACQ,YACP,UAAU,SAAS"}
|
package/cjs/formatter.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { LogEntry } from "./types.js";
|
|
2
2
|
//#region ts/formatter.d.ts
|
|
3
|
-
type TimestampFormat = 'none' | 'iso' | 'elapsed';
|
|
4
|
-
declare function createTimestampFormatter(format: TimestampFormat): (timestamp: Date) => string | undefined;
|
|
5
|
-
declare function formatLogLevel(level: number): string;
|
|
3
|
+
export type TimestampFormat = 'none' | 'iso' | 'elapsed';
|
|
4
|
+
export declare function createTimestampFormatter(format: TimestampFormat): (timestamp: Date) => string | undefined;
|
|
5
|
+
export declare function formatLogLevel(level: number): string;
|
|
6
6
|
/**
|
|
7
7
|
* Formats log entry as plain text with the following format:
|
|
8
8
|
* `timestamp id level ...args`
|
|
9
9
|
*
|
|
10
10
|
* This is typically useful for writing logs to file
|
|
11
11
|
*/
|
|
12
|
-
declare function plainLogFormatter({ id, level, args, timestamp }: LogEntry): any[];
|
|
12
|
+
export declare function plainLogFormatter({ id, level, args, timestamp }: LogEntry): any[];
|
|
13
13
|
/**
|
|
14
14
|
* Formats log entry like default console log.
|
|
15
15
|
*/
|
|
16
|
-
declare function consoleFormatter({ args }: LogEntry): any[];
|
|
16
|
+
export declare function consoleFormatter({ args }: LogEntry): any[];
|
|
17
17
|
//#endregion
|
|
18
|
-
export { TimestampFormat, consoleFormatter, createTimestampFormatter, formatLogLevel, plainLogFormatter };
|
|
19
18
|
//# sourceMappingURL=formatter.d.ts.map
|
package/cjs/formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../ts/formatter.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../ts/formatter.ts"],"mappings":";;YAIY;wBAEI,yBAAyB,QAAQ,mBAAmB,WAAW;wBAkB/D,eAAe;;;;;;;wBAUf,oBAAoB,IAAI,OAAO,MAAM,aAAa;;;;wBAOlD,mBAAmB,QAAQ"}
|
package/cjs/log_levels.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ts/log_levels.d.ts
|
|
2
|
-
declare const logLevels: {
|
|
2
|
+
export declare const logLevels: {
|
|
3
3
|
/**
|
|
4
4
|
* none: 0
|
|
5
5
|
*/
|
|
@@ -73,12 +73,11 @@ declare const logLevels: {
|
|
|
73
73
|
/**
|
|
74
74
|
* Convert default log level value to log level name.
|
|
75
75
|
*/
|
|
76
|
-
declare function toLogLevelName(level: number): "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "planck" | "trace" | "warn";
|
|
76
|
+
export declare function toLogLevelName(level: number): "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "planck" | "trace" | "warn";
|
|
77
77
|
/**
|
|
78
78
|
* Convert default log level name to log level value.
|
|
79
79
|
*/
|
|
80
|
-
declare function toLogLevel(name: string): number | undefined;
|
|
81
|
-
declare const DEFAULT_LOG_METHOD_NAMES: string[];
|
|
80
|
+
export declare function toLogLevel(name: string): number | undefined;
|
|
81
|
+
export declare const DEFAULT_LOG_METHOD_NAMES: string[];
|
|
82
82
|
//#endregion
|
|
83
|
-
export { DEFAULT_LOG_METHOD_NAMES, logLevels, toLogLevel, toLogLevelName };
|
|
84
83
|
//# sourceMappingURL=log_levels.d.ts.map
|
package/cjs/log_levels.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_levels.d.ts","names":[],"sources":["../ts/log_levels.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"log_levels.d.ts","names":[],"sources":["../ts/log_levels.ts"],"mappings":";qBAAa;;;;EAIZ;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA;;;;EAIA;;;;;wBAMe,eAAe;;;;wBAgBf,WAAW;qBAId"}
|
package/cjs/log_store.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { LogLevel, LogMethodNames, LogReporter, Logger, StandardLogOptions } from "./types.js";
|
|
2
2
|
//#region ts/log_store.d.ts
|
|
3
|
-
declare function createLogStore<N extends string = LogMethodNames>(options: Required<StandardLogOptions<N>>): LogStore;
|
|
4
|
-
interface LogStore {
|
|
3
|
+
export declare function createLogStore<N extends string = LogMethodNames>(options: Required<StandardLogOptions<N>>): LogStore;
|
|
4
|
+
export interface LogStore {
|
|
5
5
|
loggers: Record<string, Logger>;
|
|
6
6
|
nonConsoleLoggers: Record<string, Logger>;
|
|
7
7
|
reporters: LogReporter[];
|
|
8
8
|
logLevel: LogLevel;
|
|
9
9
|
logLevelStore: ReturnType<typeof logLevelStore>;
|
|
10
10
|
}
|
|
11
|
-
interface LogLevelStoreOptions {
|
|
11
|
+
export interface LogLevelStoreOptions {
|
|
12
12
|
customLevels?: Record<string, number>;
|
|
13
13
|
}
|
|
14
|
-
declare function logLevelStore(options: LogLevelStoreOptions): {
|
|
14
|
+
export declare function logLevelStore(options: LogLevelStoreOptions): {
|
|
15
15
|
getName(level: number): string;
|
|
16
16
|
getLevel(name: string): number;
|
|
17
17
|
getAllLevels(): {
|
|
@@ -20,5 +20,4 @@ declare function logLevelStore(options: LogLevelStoreOptions): {
|
|
|
20
20
|
}[];
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
23
|
-
export { LogLevelStoreOptions, LogStore, createLogStore, logLevelStore };
|
|
24
23
|
//# sourceMappingURL=log_store.d.ts.map
|
package/cjs/log_store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_store.d.ts","names":[],"sources":["../ts/log_store.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"log_store.d.ts","names":[],"sources":["../ts/log_store.ts"],"mappings":";;wBAKgB,eAAe,mBAAmB,gBACjD,SAAS,SAAS,mBAAmB,MACnC;iBAUc;EAChB,SAAS,eAAe;EACxB,mBAAmB,eAAe;EAClC,WAAW;EACX,UAAU;EACV,eAAe,kBAAkB;;iBAGjB;EAChB,eAAe;;wBAGA,cAAc,SAAS;EAerC,QAAO;EAGP,SAAQ;EAGR"}
|
package/cjs/log_store.js
CHANGED
|
@@ -29,7 +29,7 @@ function logLevelStore(options) {
|
|
|
29
29
|
return store.customLevels[name] ?? require_log_levels.toLogLevel(name);
|
|
30
30
|
},
|
|
31
31
|
getAllLevels() {
|
|
32
|
-
return (0, type_plus.
|
|
32
|
+
return (0, type_plus.reduceByKey)(require_log_levels.logLevels, (result, name) => {
|
|
33
33
|
if (name !== "none" && name !== "all") result.push({
|
|
34
34
|
name,
|
|
35
35
|
level: require_log_levels.logLevels[name]
|
package/cjs/log_store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_store.js","names":["record","createConsoleLogReporter","reduceByKey","toLogLevelName","toLogLevel","
|
|
1
|
+
{"version":3,"file":"log_store.js","names":["record","createConsoleLogReporter","reduceByKey","toLogLevelName","toLogLevel","logLevels","mapKey"],"sources":["../ts/log_store.ts"],"sourcesContent":["import { mapKey, record, reduceByKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: reduceByKey(\n\t\t\tcustomLevels,\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn reduceByKey(\n\t\t\t\tlogLevels,\n\t\t\t\t(result, name) => {\n\t\t\t\t\tif (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t\tmapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))\n\t\t\t)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAKA,SAAgB,eACf,SACW;CACX,OAAO;EACN,UAAA,GAASA,UAAAA,OAAAA,CAAO;EAChB,oBAAA,GAAmBA,UAAAA,OAAAA,CAAO;EAC1B,WAAW,QAAQ,aAAa,CAACC,gBAAAA,yBAAyB,CAAC;EAC3D,UAAU,QAAQ;EAClB,eAAe,cAAc,OAAO;CACrC;AACD;AAcA,SAAgB,cAAc,SAA+B;CAC5D,MAAM,eAAe,QAAQ,iBAAA,GAAgBD,UAAAA,OAAAA,CAAO;CAEpD,MAAM,QAAQ;EACb;EACA,sBAAA,GAAqBE,UAAAA,YAAAA,CACpB,eACC,GAAG,MAAM;GACT,EAAE,aAAa,MAAM;GACrB,OAAO;EACR,GACA,CAAC,CACF;CACD;CACA,OAAO;EACN,QAAQ,OAAe;GACtB,OAAO,MAAM,oBAAoB,UAAUC,mBAAAA,eAAe,KAAK;EAChE;EACA,SAAS,MAAc;GACtB,OAAO,MAAM,aAAa,SAASC,mBAAAA,WAAW,IAAI;EACnD;EACA,eAAe;GACd,QAAA,GAAOF,UAAAA,YAAAA,CACNG,mBAAAA,YACC,QAAQ,SAAS;IACjB,IAAI,SAAS,UAAU,SAAS,OAAO,OAAO,KAAK;KAAE;KAAM,OAAOA,mBAAAA,UAAU;IAAM,CAAC;IAEnF,OAAO;GACR,IAAA,GACAC,UAAAA,OAAAA,CAAO,MAAM,eAAc,UAAS;IAAE;IAAM,OAAO,MAAM,aAAa;GAAM,EAAE,CAC/E;EACD;CACD;AACD"}
|
package/cjs/logger.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LogMethodNames, Logger, LoggerOptions } from "./types.js";
|
|
2
2
|
import { LogStore } from "./log_store.js";
|
|
3
3
|
//#region ts/logger.d.ts
|
|
4
|
-
declare function createLogger<N extends string = LogMethodNames>(store: LogStore, id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
|
|
4
|
+
export declare function createLogger<N extends string = LogMethodNames>(store: LogStore, id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { createLogger };
|
|
7
6
|
//# sourceMappingURL=logger.d.ts.map
|
package/cjs/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","names":[],"sources":["../ts/logger.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","names":[],"sources":["../ts/logger.ts"],"mappings":";;;wBAYgB,aAAa,mBAAmB,gBAC/C,OAAO,UACP,YACA,UAAU,gBACR,OAAO,IAAI"}
|
package/cjs/memory.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from "./types.js";
|
|
2
2
|
//#region ts/memory.d.ts
|
|
3
|
-
type MemoryLogReporter = LogReporter<LogEntry> & {
|
|
3
|
+
export type MemoryLogReporter = LogReporter<LogEntry> & {
|
|
4
4
|
logs: LogEntry[];
|
|
5
5
|
/**
|
|
6
6
|
* Gets a simple log message for testing.
|
|
@@ -13,10 +13,9 @@ type MemoryLogReporter = LogReporter<LogEntry> & {
|
|
|
13
13
|
getLogMessagesWithIdAndLevel(): string[];
|
|
14
14
|
emit(): void;
|
|
15
15
|
};
|
|
16
|
-
type MemoryLogFormatter = LogFormatter<LogEntry>;
|
|
17
|
-
declare function toMessageWithLevel(logs: LogEntry[]): string;
|
|
18
|
-
declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
|
|
19
|
-
declare function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
|
|
16
|
+
export type MemoryLogFormatter = LogFormatter<LogEntry>;
|
|
17
|
+
export declare function toMessageWithLevel(logs: LogEntry[]): string;
|
|
18
|
+
export declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
|
|
19
|
+
export declare function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
|
|
20
20
|
//#endregion
|
|
21
|
-
export { MemoryLogFormatter, MemoryLogReporter, createMemoryLogReporter, createMemoryWithConsoleLogReporter, toMessageWithLevel };
|
|
22
21
|
//# sourceMappingURL=memory.d.ts.map
|
package/cjs/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","names":[],"sources":["../ts/memory.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","names":[],"sources":["../ts/memory.ts"],"mappings":";;YAOY,oBAAoB,YAAY;EAC3C,MAAM;;;;;EAKN;EACA;EACA;EACA;EACA;EACA;;YAGW,qBAAqB,aAAa;wBAE9B,mBAAmB,MAAM;wBAazB,wBAAwB,UAAU,mBAAmB,YAAY;wBA+CjE,mCACf,UAAU,mBAAmB,YAC3B"}
|
package/cjs/memory.js
CHANGED
|
@@ -2,13 +2,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_formatter = require("./formatter.js");
|
|
3
3
|
const require_platform = require("./platform.js");
|
|
4
4
|
const require_console = require("./console.js");
|
|
5
|
+
let unpartial = require("unpartial");
|
|
5
6
|
let type_plus = require("type-plus");
|
|
6
7
|
//#region ts/memory.ts
|
|
7
8
|
function toMessageWithLevel(logs) {
|
|
8
9
|
return logs.map(require_platform.toInspectLogEntry).map((log) => `${require_formatter.formatLogLevel(log.level)} ${log.args.join(" ")}`).join("\n").replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, "");
|
|
9
10
|
}
|
|
10
11
|
function createMemoryLogReporter(options) {
|
|
11
|
-
return Object.freeze(buildMemoryReporter((0,
|
|
12
|
+
return Object.freeze(buildMemoryReporter((0, unpartial.unpartial)({ id: "memory" }, options)));
|
|
12
13
|
}
|
|
13
14
|
function buildMemoryReporter(options) {
|
|
14
15
|
const { id, formatter, filter } = (0, type_plus.required)({
|
|
@@ -54,7 +55,7 @@ function buildMemoryReporter(options) {
|
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
function createMemoryWithConsoleLogReporter(options) {
|
|
57
|
-
return Object.freeze(Object.assign(buildMemoryReporter((0,
|
|
58
|
+
return Object.freeze(Object.assign(buildMemoryReporter((0, unpartial.unpartial)({ id: "memory-with-console" }, options)), { isConsoleReporter: true }));
|
|
58
59
|
}
|
|
59
60
|
//#endregion
|
|
60
61
|
exports.createMemoryLogReporter = createMemoryLogReporter;
|
package/cjs/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","names":["toInspectLogEntry","formatLogLevel","
|
|
1
|
+
{"version":3,"file":"memory.js","names":["toInspectLogEntry","formatLogLevel","required","createConsoleLogReporter"],"sources":["../ts/memory.ts"],"sourcesContent":["import { required } from 'type-plus'\nimport { unpartial } from 'unpartial'\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"],"mappings":";;;;;;;AAuBA,SAAgB,mBAAmB,MAAkB;CACpD,OACC,KACE,IAAIA,iBAAAA,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC,CAChE,KAAK,IAAI,CAAC,CAIV,QAAQ,qEAAqE,EAAE;AAEnF;AAEA,SAAgB,wBAAwB,SAA2D;CAClG,OAAO,OAAO,OAAO,qBAAA,GAAoB,UAAA,UAAA,CAAU,EAAE,IAAI,SAAS,GAAG,OAAO,CAAC,CAAC;AAC/E;AAEA,SAAS,oBAAoB,SAAwC;CACpE,MAAM,EAAE,IAAI,WAAW,YAAA,GAAWC,UAAAA,SAAAA,CAAS;EAAE,IAAI;EAAU,YAAY,MAAgB;CAAE,GAAG,OAAO;CACnG,MAAM,OAAmB,CAAC;CAC1B,OAAO;EACN;EACA,IAAI,YAAY;GACf,OAAO;EACR;EACA,IAAI,SAAS;GACZ,OAAO;EACR;EACA;EACA,MAAM,OAAiB;GACtB,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG;GAC9B,KAAK,KAAK,UAAU,KAAK,CAAC;EAC3B;EACA,gBAAgB;GACf,OAAO,KAAK,eAAe,CAAC,CAAC,KAAK,IAAI;EACvC;EACA,iBAAiB;GAChB,OAAO,KAAK,IAAIF,iBAAAA,iBAAiB,CAAC,CAAC,KAAI,QAAO,IAAI,KAAK,KAAK,GAAG,CAAC;EACjE;EACA,0BAA0B;GACzB,OAAO,KAAK,IAAIA,iBAAAA,iBAAiB,CAAC,CAAC,KAAI,QAAO,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EACnG;EACA,+BAA+B;GAC9B,OAAO,KACL,IAAID,iBAAAA,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAG,IAAI,GAAG,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EAC5E;EACA,yBAAyB;GACxB,OAAO,mBAAmB,IAAI;EAC/B;;;;EAIA,OAAO;GACN,MAAM,WAAWE,gBAAAA,yBAAyB;GAC1C,KAAK,SAAQ,MAAK,SAAS,MAAM,CAAC,CAAC;EACpC;CACD;AACD;AAEA,SAAgB,mCACf,SACoB;CACpB,OAAO,OAAO,OACb,OAAO,OAAO,qBAAA,GAAoB,UAAA,UAAA,CAAU,EAAE,IAAI,sBAAsB,GAAG,OAAO,CAAC,GAAG,EACrF,mBAAmB,KACpB,CAAC,CACF;AACD"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ConsoleLike, LogEntry } from "./types.js";
|
|
2
2
|
//#region ts/platform.browser.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.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.browser.d.ts","names":[],"sources":["../ts/platform.browser.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"platform.browser.d.ts","names":[],"sources":["../ts/platform.browser.ts"],"mappings":";;qBAGa,oBAAiB,GAAO,aAAQ;qBAEhC;EAAY,UAAU"}
|
package/cjs/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/cjs/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/cjs/platform.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
let type_plus = require("type-plus");
|
|
3
2
|
let node_util = require("node:util");
|
|
3
|
+
let type_plus = require("type-plus");
|
|
4
4
|
//#region ts/platform.ts
|
|
5
5
|
const toInspectLogEntry = (e) => (e.args = e.args.map((value) => typeof value === "object" && value !== null ? (0, node_util.inspect)(value) : value), e);
|
|
6
6
|
const polyfill = (0, type_plus.record)();
|
|
@@ -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/cjs/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":";;;iBAaiB,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"}
|
|
@@ -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/cjs/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StackTraceMeta } from "@just-func/types";
|
|
2
2
|
//#region ts/types.d.ts
|
|
3
|
-
type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
3
|
+
export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
4
4
|
/**
|
|
5
5
|
* A map of custom log levels.
|
|
6
6
|
*
|
|
@@ -19,11 +19,11 @@ type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
|
19
19
|
logLevel?: number;
|
|
20
20
|
reporters?: LogReporter[];
|
|
21
21
|
};
|
|
22
|
-
interface LoggerOptions extends StackTraceMeta {
|
|
22
|
+
export interface LoggerOptions extends StackTraceMeta {
|
|
23
23
|
level?: number;
|
|
24
24
|
writeTo?: LogReporter | ReporterFilter;
|
|
25
25
|
}
|
|
26
|
-
type Logger<N extends string = LogMethodNames> = {
|
|
26
|
+
export type Logger<N extends string = LogMethodNames> = {
|
|
27
27
|
readonly id: string;
|
|
28
28
|
/**
|
|
29
29
|
* Logger local log level.
|
|
@@ -43,17 +43,17 @@ type Logger<N extends string = LogMethodNames> = {
|
|
|
43
43
|
/**
|
|
44
44
|
* Names of the standard log methods.
|
|
45
45
|
*/
|
|
46
|
-
type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
|
|
47
|
-
type LogEntry = {
|
|
46
|
+
export type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
|
|
47
|
+
export type LogEntry = {
|
|
48
48
|
id: string;
|
|
49
49
|
level: number;
|
|
50
50
|
args: any[];
|
|
51
51
|
timestamp: Date;
|
|
52
52
|
};
|
|
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> {
|
|
53
|
+
export type LogMethod = (...args: any[]) => void;
|
|
54
|
+
export type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
|
|
55
|
+
export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
|
|
56
|
+
export interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
57
57
|
/**
|
|
58
58
|
* The current log level.
|
|
59
59
|
*/
|
|
@@ -94,16 +94,16 @@ interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
|
94
94
|
* Depends on the reporter, it can expect a different return type.
|
|
95
95
|
* By default the return type is `any[]` which the `console` accepts.
|
|
96
96
|
*/
|
|
97
|
-
type LogFormatter<T = any[]> = (entry: LogEntry) => T;
|
|
97
|
+
export type LogFormatter<T = any[]> = (entry: LogEntry) => T;
|
|
98
98
|
/**
|
|
99
99
|
* Determines whether the entry should be written.
|
|
100
100
|
*/
|
|
101
|
-
type LogFilter = (entry: LogEntry) => boolean;
|
|
102
|
-
type LogLevelEntry = {
|
|
101
|
+
export type LogFilter = (entry: LogEntry) => boolean;
|
|
102
|
+
export type LogLevelEntry = {
|
|
103
103
|
name: string;
|
|
104
104
|
level: number;
|
|
105
105
|
};
|
|
106
|
-
interface LogReporter<T = any> {
|
|
106
|
+
export interface LogReporter<T = any> {
|
|
107
107
|
readonly id: string;
|
|
108
108
|
/**
|
|
109
109
|
* Specifies the formatter to be used by the reporter.
|
|
@@ -121,7 +121,7 @@ interface LogReporter<T = any> {
|
|
|
121
121
|
readonly isConsoleReporter?: boolean;
|
|
122
122
|
write(entry: LogEntry): void;
|
|
123
123
|
}
|
|
124
|
-
type LogReporterOptions<T = any> = {
|
|
124
|
+
export type LogReporterOptions<T = any> = {
|
|
125
125
|
id?: string;
|
|
126
126
|
/**
|
|
127
127
|
* Specifies the formatter to be used by the reporter.
|
|
@@ -133,13 +133,12 @@ type LogReporterOptions<T = any> = {
|
|
|
133
133
|
*/
|
|
134
134
|
filter?: LogFilter;
|
|
135
135
|
};
|
|
136
|
-
type LogLevel = number;
|
|
137
|
-
interface ConsoleLike {
|
|
136
|
+
export type LogLevel = number;
|
|
137
|
+
export interface ConsoleLike {
|
|
138
138
|
debug(...args: any[]): void;
|
|
139
139
|
info(...args: any[]): void;
|
|
140
140
|
warn(...args: any[]): void;
|
|
141
141
|
error(...args: any[]): void;
|
|
142
142
|
}
|
|
143
143
|
//#endregion
|
|
144
|
-
export { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, Logger, LoggerOptions, ReporterFilter, StandardLogInstance, StandardLogOptions };
|
|
145
144
|
//# sourceMappingURL=types.d.ts.map
|
package/cjs/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":";;YAEY,mBAAmB,kCAAkC;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;iBAGI,sBAAsB;EACtC;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"}
|