standard-log 12.1.2 → 13.0.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/README.md +8 -8
- package/cjs/_virtual/_rolldown/runtime.js +23 -0
- package/cjs/console.d.ts +10 -7
- package/cjs/console.d.ts.map +1 -1
- package/cjs/console.js +53 -71
- package/cjs/console.js.map +1 -1
- package/cjs/errors.d.ts +9 -6
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +22 -45
- package/cjs/errors.js.map +1 -1
- package/cjs/formatter.d.ts +9 -6
- package/cjs/formatter.d.ts.map +1 -1
- package/cjs/formatter.js +41 -50
- package/cjs/formatter.js.map +1 -1
- package/cjs/index.d.ts +8 -9
- package/cjs/index.js +26 -28
- package/cjs/log_levels.d.ts +76 -73
- package/cjs/log_levels.d.ts.map +1 -1
- package/cjs/log_levels.js +104 -110
- package/cjs/log_levels.js.map +1 -1
- package/cjs/log_store.d.ts +20 -17
- package/cjs/log_store.d.ts.map +1 -1
- package/cjs/log_store.js +43 -39
- package/cjs/log_store.js.map +1 -1
- package/cjs/logger.d.ts +6 -3
- package/cjs/logger.d.ts.map +1 -1
- package/cjs/logger.js +66 -88
- package/cjs/logger.js.map +1 -1
- package/cjs/memory.d.ts +20 -17
- package/cjs/memory.d.ts.map +1 -1
- package/cjs/memory.js +54 -64
- package/cjs/memory.js.map +1 -1
- package/cjs/platform.browser.d.ts +7 -4
- package/cjs/platform.browser.d.ts.map +1 -1
- package/cjs/platform.browser.js +8 -6
- package/cjs/platform.browser.js.map +1 -1
- package/cjs/platform.d.ts +7 -4
- package/cjs/platform.d.ts.map +1 -1
- package/cjs/platform.js +9 -7
- package/cjs/platform.js.map +1 -1
- package/cjs/standard_log.ctx.d.ts +11 -8
- package/cjs/standard_log.ctx.d.ts.map +1 -1
- package/cjs/standard_log.ctx.js +6 -5
- package/cjs/standard_log.ctx.js.map +1 -1
- package/cjs/standard_log.d.ts +14 -12
- package/cjs/standard_log.d.ts.map +1 -1
- package/cjs/standard_log.js +83 -112
- package/cjs/standard_log.js.map +1 -1
- package/cjs/standard_log.testing.d.ts +16 -13
- package/cjs/standard_log.testing.d.ts.map +1 -1
- package/cjs/standard_log.testing.js +19 -35
- package/cjs/standard_log.testing.js.map +1 -1
- package/cjs/testing/index.d.ts +3 -3
- package/cjs/testing/index.js +3 -6
- package/cjs/types.d.ts +125 -124
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js +0 -3
- package/dist/standard-log.esm.js +873 -1430
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.iife.js +952 -0
- package/dist/standard-log.iife.js.map +1 -0
- package/esm/console.d.ts +10 -7
- package/esm/console.d.ts.map +1 -1
- package/esm/console.js +54 -64
- package/esm/console.js.map +1 -1
- package/esm/errors.d.ts +9 -6
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +21 -21
- package/esm/errors.js.map +1 -1
- package/esm/formatter.d.ts +9 -6
- package/esm/formatter.d.ts.map +1 -1
- package/esm/formatter.js +38 -32
- package/esm/formatter.js.map +1 -1
- package/esm/index.d.ts +8 -9
- package/esm/index.js +7 -7
- package/esm/log_levels.d.ts +76 -73
- package/esm/log_levels.d.ts.map +1 -1
- package/esm/log_levels.js +102 -107
- package/esm/log_levels.js.map +1 -1
- package/esm/log_store.d.ts +20 -17
- package/esm/log_store.d.ts.map +1 -1
- package/esm/log_store.js +44 -37
- package/esm/log_store.js.map +1 -1
- package/esm/logger.d.ts +6 -3
- package/esm/logger.d.ts.map +1 -1
- package/esm/logger.js +66 -65
- package/esm/logger.js.map +1 -1
- package/esm/memory.d.ts +20 -17
- package/esm/memory.d.ts.map +1 -1
- package/esm/memory.js +55 -62
- package/esm/memory.js.map +1 -1
- package/esm/platform.browser.d.ts +7 -4
- package/esm/platform.browser.d.ts.map +1 -1
- package/esm/platform.browser.js +7 -3
- package/esm/platform.browser.js.map +1 -1
- package/esm/platform.d.ts +7 -4
- package/esm/platform.d.ts.map +1 -1
- package/esm/platform.js +8 -4
- package/esm/platform.js.map +1 -1
- package/esm/standard_log.ctx.d.ts +11 -8
- package/esm/standard_log.ctx.d.ts.map +1 -1
- package/esm/standard_log.ctx.js +6 -2
- package/esm/standard_log.ctx.js.map +1 -1
- package/esm/standard_log.d.ts +14 -12
- package/esm/standard_log.d.ts.map +1 -1
- package/esm/standard_log.js +83 -98
- package/esm/standard_log.js.map +1 -1
- package/esm/standard_log.testing.d.ts +16 -13
- package/esm/standard_log.testing.d.ts.map +1 -1
- package/esm/standard_log.testing.js +19 -20
- package/esm/standard_log.testing.js.map +1 -1
- package/esm/testing/index.d.ts +3 -3
- package/esm/testing/index.js +2 -2
- package/esm/types.d.ts +125 -124
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js +0 -1
- package/package.json +21 -67
- 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/cjs/index.d.ts.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/testing/index.d.ts.map +0 -1
- package/cjs/testing/index.js.map +0 -1
- package/cjs/types.js.map +0 -1
- package/dist/standard-log.es5.js +0 -10184
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +0 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/testing/index.d.ts.map +0 -1
- package/esm/testing/index.js.map +0 -1
- package/esm/types.js.map +0 -1
package/cjs/standard_log.js
CHANGED
|
@@ -1,127 +1,98 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.configGlobal = exports.getLogger = exports.suppressLogs = exports.createStandardLogClosure = exports.createStandardLog = void 0;
|
|
15
|
-
var type_plus_1 = require("type-plus");
|
|
16
|
-
var log_levels_js_1 = require("./log_levels.js");
|
|
17
|
-
var log_store_js_1 = require("./log_store.js");
|
|
18
|
-
var logger_js_1 = require("./logger.js");
|
|
19
|
-
var standard_log_ctx_js_1 = require("./standard_log.ctx.js");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_log_levels = require("./log_levels.js");
|
|
3
|
+
const require_log_store = require("./log_store.js");
|
|
4
|
+
const require_logger = require("./logger.js");
|
|
5
|
+
const require_standard_log_ctx = require("./standard_log.ctx.js");
|
|
6
|
+
let type_plus = require("type-plus");
|
|
7
|
+
//#region ts/standard_log.ts
|
|
20
8
|
function createStandardLog(options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
log.critical("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.");
|
|
26
|
-
}
|
|
27
|
-
if (!standard_log_ctx_js_1.ctx.gsl)
|
|
28
|
-
standard_log_ctx_js_1.ctx.gsl = closure;
|
|
29
|
-
return closure.standardLog;
|
|
9
|
+
const closure = createStandardLogClosure(options);
|
|
10
|
+
if (options?.reporters?.some((r) => !r.id)) closure.standardLog.getLogger("standard-log").critical(`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.`);
|
|
11
|
+
if (!require_standard_log_ctx.ctx.gsl) require_standard_log_ctx.ctx.gsl = closure;
|
|
12
|
+
return closure.standardLog;
|
|
30
13
|
}
|
|
31
|
-
|
|
32
|
-
function noop() { }
|
|
14
|
+
function noop() {}
|
|
33
15
|
function createStandardLogClosure(options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
16
|
+
const store = require_log_store.createLogStore((0, type_plus.required)({ logLevel: require_log_levels.logLevels.info }, options));
|
|
17
|
+
const nonConsoleReporters = options?.reporters?.filter((r) => !r.isConsoleReporter).map((r) => r.id) ?? [];
|
|
18
|
+
const logMethods = require_log_levels.DEFAULT_LOG_METHOD_NAMES.concat(Object.keys(options?.customLevels ?? {})).concat([
|
|
19
|
+
"on",
|
|
20
|
+
"count",
|
|
21
|
+
"write"
|
|
22
|
+
]);
|
|
23
|
+
return {
|
|
24
|
+
store,
|
|
25
|
+
standardLog: {
|
|
26
|
+
get logLevel() {
|
|
27
|
+
return store.logLevel;
|
|
28
|
+
},
|
|
29
|
+
toLogLevelName(level) {
|
|
30
|
+
return store.logLevelStore.getName(level);
|
|
31
|
+
},
|
|
32
|
+
toLogLevel(name) {
|
|
33
|
+
return store.logLevelStore.getLevel(name);
|
|
34
|
+
},
|
|
35
|
+
getLogger(id, options) {
|
|
36
|
+
if (store.loggers[id]) return store.loggers[id];
|
|
37
|
+
return store.loggers[id] = require_logger.createLogger(store, id, {
|
|
38
|
+
ssf: this.getLogger,
|
|
39
|
+
...options
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
getNonConsoleLogger(id, options) {
|
|
43
|
+
if (store.nonConsoleLoggers[id]) return store.nonConsoleLoggers[id];
|
|
44
|
+
if (store.loggers[id]) {
|
|
45
|
+
this.getLogger("standard-log").warn(`attempt to create a non-console logger with existing id ('${id}'), ignoring`);
|
|
46
|
+
return store.nonConsoleLoggers[id] = createDummyLogger(logMethods);
|
|
47
|
+
}
|
|
48
|
+
return store.nonConsoleLoggers[id] = nonConsoleReporters.length === 0 ? createDummyLogger(logMethods) : require_logger.createLogger(store, id, {
|
|
49
|
+
ssf: this.getNonConsoleLogger,
|
|
50
|
+
...options,
|
|
51
|
+
writeTo(reporterId) {
|
|
52
|
+
return nonConsoleReporters.indexOf(reporterId) >= 0;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
77
58
|
}
|
|
78
|
-
exports.createStandardLogClosure = createStandardLogClosure;
|
|
79
59
|
function createDummyLogger(logMethods) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
return logMethods.reduce((p, m) => {
|
|
61
|
+
p[m] = noop;
|
|
62
|
+
return p;
|
|
63
|
+
}, (0, type_plus.record)());
|
|
84
64
|
}
|
|
85
|
-
function suppressLogs(block) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
logs.forEach(function (l) { return (l.level = log_levels_js_1.logLevels.none); });
|
|
92
|
-
var result = block();
|
|
93
|
-
logs.forEach(function (l, i) { return (l.level = origLevels[i]); });
|
|
94
|
-
return result;
|
|
65
|
+
function suppressLogs(block, ...logs) {
|
|
66
|
+
const origLevels = logs.map((l) => l.level);
|
|
67
|
+
logs.forEach((l) => l.level = require_log_levels.logLevels.none);
|
|
68
|
+
const result = block();
|
|
69
|
+
logs.forEach((l, i) => l.level = origLevels[i]);
|
|
70
|
+
return result;
|
|
95
71
|
}
|
|
96
|
-
exports.suppressLogs = suppressLogs;
|
|
97
72
|
function getLogger(id, options) {
|
|
98
|
-
|
|
73
|
+
return getGlobalSL().getLogger(id, options);
|
|
99
74
|
}
|
|
100
|
-
exports.getLogger = getLogger;
|
|
101
75
|
function getGlobalSL() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return standard_log_ctx_js_1.ctx.gsl.standardLog;
|
|
76
|
+
if (!require_standard_log_ctx.ctx.gsl) require_standard_log_ctx.ctx.gsl = createStandardLogClosure();
|
|
77
|
+
return require_standard_log_ctx.ctx.gsl.standardLog;
|
|
105
78
|
}
|
|
106
79
|
function configGlobal(options) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
reporters.length = 0;
|
|
118
|
-
reporters.push.apply(reporters, options.reporters);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
standard_log_ctx_js_1.ctx.gsl = createStandardLogClosure(options);
|
|
123
|
-
}
|
|
124
|
-
standard_log_ctx_js_1.ctx.configured = true;
|
|
80
|
+
if (require_standard_log_ctx.ctx.configured) require_standard_log_ctx.ctx.gsl.standardLog.getLogger("standard-log").warn("configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.");
|
|
81
|
+
if (require_standard_log_ctx.ctx.gsl) {
|
|
82
|
+
if (options.logLevel) require_standard_log_ctx.ctx.gsl.store.logLevel = options.logLevel;
|
|
83
|
+
if (options.reporters) {
|
|
84
|
+
const reporters = require_standard_log_ctx.ctx.gsl.store.reporters;
|
|
85
|
+
reporters.length = 0;
|
|
86
|
+
reporters.push(...options.reporters);
|
|
87
|
+
}
|
|
88
|
+
} else require_standard_log_ctx.ctx.gsl = createStandardLogClosure(options);
|
|
89
|
+
require_standard_log_ctx.ctx.configured = true;
|
|
125
90
|
}
|
|
91
|
+
//#endregion
|
|
126
92
|
exports.configGlobal = configGlobal;
|
|
93
|
+
exports.createStandardLog = createStandardLog;
|
|
94
|
+
exports.createStandardLogClosure = createStandardLogClosure;
|
|
95
|
+
exports.getLogger = getLogger;
|
|
96
|
+
exports.suppressLogs = suppressLogs;
|
|
97
|
+
|
|
127
98
|
//# sourceMappingURL=standard_log.js.map
|
package/cjs/standard_log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.js","
|
|
1
|
+
{"version":3,"file":"standard_log.js","names":["ctx","createLogStore","required","logLevels","DEFAULT_LOG_METHOD_NAMES","createLogger","record"],"sources":["../ts/standard_log.ts"],"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"],"mappings":";;;;;;;AAeA,SAAgB,kBACf,SACiB;CACjB,MAAM,UAAU,yBAAyB,OAAO;CAChD,IAAI,SAAS,WAAW,MAAK,MAAK,CAAC,EAAE,EAAE,GAEtC,QADoB,YAAY,UAAU,cAC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|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { LogMethodNames, StandardLogOptions } from "./types.js";
|
|
2
|
+
import { MemoryLogReporter } from "./memory.js";
|
|
3
|
+
import { StandardLog } from "./standard_log.js";
|
|
4
|
+
//#region ts/standard_log.testing.d.ts
|
|
5
|
+
type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {
|
|
6
|
+
/**
|
|
7
|
+
* Send the logs to console for easy debugging.
|
|
8
|
+
*
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
emitLog?: boolean;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
|
|
14
|
+
reporter: MemoryLogReporter;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogForTestOptions<N>): StandardLogForTest<N>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { StandardLogForTest, StandardLogForTestOptions, createStandardLogForTest };
|
|
16
19
|
//# sourceMappingURL=standard_log.testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.testing.d.ts","
|
|
1
|
+
{"version":3,"file":"standard_log.testing.d.ts","names":[],"sources":["../ts/standard_log.testing.ts"],"mappings":";;;;KAMY,0BAA0B,mBAAmB,kBAAkB,mBAAmB;;;;;;EAM7F;;KAGW,mBAAmB,mBAAmB,kBAAkB,YAAY;EAC/E,UAAU;;iBAGK,yBAAyB,mBAAmB,gBAC3D,UAAS,0BAA0B,KACjC,mBAAmB"}
|
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var standard_log_js_1 = require("./standard_log.js");
|
|
19
|
-
function createStandardLogForTest(options) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
if (options === void 0) { options = {}; }
|
|
22
|
-
options.logLevel = (_a = options.logLevel) !== null && _a !== void 0 ? _a : log_levels_js_1.logLevels.debug;
|
|
23
|
-
options.reporters = (_b = options.reporters) !== null && _b !== void 0 ? _b : [];
|
|
24
|
-
if (options.emitLog && !options.reporters.some(function (r) { return r.isConsoleReporter; })) {
|
|
25
|
-
// this is used for debugging,
|
|
26
|
-
// so no need to use color reporter.
|
|
27
|
-
options.reporters.push((0, console_js_1.createConsoleLogReporter)());
|
|
28
|
-
}
|
|
29
|
-
var existingReporter = options.reporters.find(function (r) { return r.id === 'memory'; });
|
|
30
|
-
var reporter = existingReporter !== null && existingReporter !== void 0 ? existingReporter : (0, memory_js_1.createMemoryLogReporter)();
|
|
31
|
-
if (!existingReporter) {
|
|
32
|
-
options.reporters.push(reporter);
|
|
33
|
-
}
|
|
34
|
-
var closure = (0, standard_log_js_1.createStandardLogClosure)(options);
|
|
35
|
-
return __assign(__assign({}, closure.standardLog), { reporter: reporter });
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_log_levels = require("./log_levels.js");
|
|
3
|
+
const require_console = require("./console.js");
|
|
4
|
+
const require_memory = require("./memory.js");
|
|
5
|
+
const require_standard_log = require("./standard_log.js");
|
|
6
|
+
//#region ts/standard_log.testing.ts
|
|
7
|
+
function createStandardLogForTest(options = {}) {
|
|
8
|
+
options.logLevel = options.logLevel ?? require_log_levels.logLevels.debug;
|
|
9
|
+
options.reporters = options.reporters ?? [];
|
|
10
|
+
if (options.emitLog && !options.reporters.some((r) => r.isConsoleReporter)) options.reporters.push(require_console.createConsoleLogReporter());
|
|
11
|
+
const existingReporter = options.reporters.find((r) => r.id === "memory");
|
|
12
|
+
const reporter = existingReporter ?? require_memory.createMemoryLogReporter();
|
|
13
|
+
if (!existingReporter) options.reporters.push(reporter);
|
|
14
|
+
return {
|
|
15
|
+
...require_standard_log.createStandardLogClosure(options).standardLog,
|
|
16
|
+
reporter
|
|
17
|
+
};
|
|
36
18
|
}
|
|
19
|
+
//#endregion
|
|
37
20
|
exports.createStandardLogForTest = createStandardLogForTest;
|
|
21
|
+
|
|
38
22
|
//# sourceMappingURL=standard_log.testing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.testing.js","
|
|
1
|
+
{"version":3,"file":"standard_log.testing.js","names":["logLevels","createConsoleLogReporter","createMemoryLogReporter","createStandardLogClosure"],"sources":["../ts/standard_log.testing.ts"],"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"],"mappings":";;;;;;AAmBA,SAAgB,yBACf,UAAwC,CAAC,GACjB;CACxB,QAAQ,WAAW,QAAQ,YAAYA,mBAAAA,UAAU;CACjD,QAAQ,YAAY,QAAQ,aAAa,CAAC;CAE1C,IAAI,QAAQ,WAAW,CAAC,QAAQ,UAAU,MAAK,MAAK,EAAE,iBAAiB,GAGtE,QAAQ,UAAU,KAAKC,gBAAAA,yBAAyB,CAAC;CAGlD,MAAM,mBAAmB,QAAQ,UAAU,MAAK,MAAK,EAAE,OAAO,QAAQ;CACtE,MAAM,WAAW,oBAAoBC,eAAAA,wBAAwB;CAC7D,IAAI,CAAC,kBACJ,QAAQ,UAAU,KAAK,QAAQ;CAGhC,OAAO;EAAE,GADOC,qBAAAA,yBAA4B,OAC1B,CAAC,CAAC;EAAa;CAAS;AAC3C"}
|
package/cjs/testing/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { MemoryLogReporter } from "../memory.js";
|
|
2
|
+
import { StandardLogForTest, StandardLogForTestOptions, createStandardLogForTest } from "../standard_log.testing.js";
|
|
3
|
+
export { type MemoryLogReporter, type StandardLogForTest, type StandardLogForTestOptions, createStandardLogForTest };
|
package/cjs/testing/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
exports.createStandardLogForTest =
|
|
4
|
-
var standard_log_testing_js_1 = require("../standard_log.testing.js");
|
|
5
|
-
Object.defineProperty(exports, "createStandardLogForTest", { enumerable: true, get: function () { return standard_log_testing_js_1.createStandardLogForTest; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_standard_log_testing = require("../standard_log.testing.js");
|
|
3
|
+
exports.createStandardLogForTest = require_standard_log_testing.createStandardLogForTest;
|