@fgv/ts-utils 5.0.0-21 → 5.0.0-23
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/dist/ts-utils.d.ts +307 -33
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/packlets/base/index.d.ts +0 -2
- package/lib/packlets/base/index.js +1 -25
- package/lib/packlets/base/result.d.ts +49 -0
- package/lib/packlets/base/result.js +36 -0
- package/lib/packlets/collections/collector.d.ts +9 -0
- package/lib/packlets/collections/collector.js +6 -0
- package/lib/packlets/collections/validatingCollector.d.ts +5 -1
- package/lib/packlets/hash/hashingNormalizer.js +4 -3
- package/lib/packlets/logging/index.d.ts +3 -0
- package/{src/packlets/hash/index.ts → lib/packlets/logging/index.js} +19 -3
- package/lib/packlets/logging/logReporter.d.ts +69 -0
- package/lib/packlets/logging/logReporter.js +72 -0
- package/lib/packlets/logging/logger.d.ts +183 -0
- package/lib/packlets/logging/logger.js +237 -0
- package/lib/test/unit/consoleLogger.test.d.ts +2 -0
- package/lib/test/unit/hashingNormalizerCollisions.test.d.ts +2 -0
- package/package.json +1 -1
- package/lib/packlets/base/logger.d.ts +0 -52
- package/lib/packlets/base/logger.js +0 -128
- package/src/index.ts +0 -63
- package/src/packlets/base/brand.ts +0 -28
- package/src/packlets/base/index.ts +0 -31
- package/src/packlets/base/logger.ts +0 -156
- package/src/packlets/base/mapResults.ts +0 -302
- package/src/packlets/base/messageAggregator.ts +0 -120
- package/src/packlets/base/normalize.ts +0 -144
- package/src/packlets/base/result.ts +0 -961
- package/src/packlets/base/utils.ts +0 -236
- package/src/packlets/collections/collectible.ts +0 -238
- package/src/packlets/collections/collector.ts +0 -273
- package/src/packlets/collections/collectorValidator.ts +0 -178
- package/src/packlets/collections/common.ts +0 -27
- package/src/packlets/collections/convertingCollector.ts +0 -223
- package/src/packlets/collections/convertingCollectorValidator.ts +0 -164
- package/src/packlets/collections/index.ts +0 -39
- package/src/packlets/collections/keyValueConverters.ts +0 -142
- package/src/packlets/collections/readonlyResultMap.ts +0 -99
- package/src/packlets/collections/resultMap.ts +0 -322
- package/src/packlets/collections/resultMapValidator.ts +0 -188
- package/src/packlets/collections/utils.ts +0 -33
- package/src/packlets/collections/validatingCollector.ts +0 -123
- package/src/packlets/collections/validatingConvertingCollector.ts +0 -113
- package/src/packlets/collections/validatingResultMap.ts +0 -94
- package/src/packlets/conversion/baseConverter.ts +0 -330
- package/src/packlets/conversion/converter.ts +0 -260
- package/src/packlets/conversion/converters.ts +0 -1039
- package/src/packlets/conversion/defaultingConverter.ts +0 -188
- package/src/packlets/conversion/index.ts +0 -30
- package/src/packlets/conversion/objectConverter.ts +0 -259
- package/src/packlets/conversion/stringConverter.ts +0 -165
- package/src/packlets/file-tree/directoryItem.ts +0 -84
- package/src/packlets/file-tree/fileItem.ts +0 -119
- package/src/packlets/file-tree/fileTree.ts +0 -152
- package/src/packlets/file-tree/fileTreeAccessors.ts +0 -176
- package/src/packlets/file-tree/fsTree.ts +0 -118
- package/src/packlets/file-tree/in-memory/inMemoryTree.ts +0 -171
- package/src/packlets/file-tree/in-memory/index.ts +0 -23
- package/src/packlets/file-tree/in-memory/treeBuilder.ts +0 -203
- package/src/packlets/file-tree/index.ts +0 -31
- package/src/packlets/hash/crcNormalizer.ts +0 -81
- package/src/packlets/hash/hashingNormalizer.ts +0 -102
- package/src/packlets/validation/array.ts +0 -84
- package/src/packlets/validation/boolean.ts +0 -63
- package/src/packlets/validation/classes.ts +0 -38
- package/src/packlets/validation/common.ts +0 -28
- package/src/packlets/validation/field.ts +0 -99
- package/src/packlets/validation/genericValidator.ts +0 -204
- package/src/packlets/validation/index.ts +0 -31
- package/src/packlets/validation/number.ts +0 -66
- package/src/packlets/validation/object.ts +0 -208
- package/src/packlets/validation/oneOf.ts +0 -78
- package/src/packlets/validation/string.ts +0 -66
- package/src/packlets/validation/traits.ts +0 -113
- package/src/packlets/validation/typeGuard.ts +0 -83
- package/src/packlets/validation/validator.ts +0 -157
- package/src/packlets/validation/validatorBase.ts +0 -66
- package/src/packlets/validation/validators.ts +0 -254
|
@@ -130,6 +130,15 @@ class Success {
|
|
|
130
130
|
aggregateError(__errors) {
|
|
131
131
|
return this;
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* {@inheritdoc IResult.report}
|
|
135
|
+
*/
|
|
136
|
+
report(reporter, options) {
|
|
137
|
+
var _a;
|
|
138
|
+
const level = (_a = options === null || options === void 0 ? void 0 : options.success) !== null && _a !== void 0 ? _a : 'quiet';
|
|
139
|
+
reporter.reportSuccess(level, this._value);
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
133
142
|
/**
|
|
134
143
|
* Creates a {@link Success | Success<T>} with the supplied value.
|
|
135
144
|
* @param value - The value to be returned.
|
|
@@ -247,6 +256,15 @@ class Failure {
|
|
|
247
256
|
errors.addMessage(this._message);
|
|
248
257
|
return this;
|
|
249
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* {@inheritdoc IResult.report}
|
|
261
|
+
*/
|
|
262
|
+
report(reporter, options) {
|
|
263
|
+
var _a;
|
|
264
|
+
const level = (_a = options === null || options === void 0 ? void 0 : options.failure) !== null && _a !== void 0 ? _a : 'error';
|
|
265
|
+
reporter.reportFailure(level, this._message);
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
250
268
|
/**
|
|
251
269
|
* Get a 'friendly' string representation of this object.
|
|
252
270
|
* @remarks
|
|
@@ -376,6 +394,15 @@ class DetailedSuccess extends Success {
|
|
|
376
394
|
withErrorFormat(cb) {
|
|
377
395
|
return this;
|
|
378
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* {@inheritdoc IResult.report}
|
|
399
|
+
*/
|
|
400
|
+
report(reporter, options) {
|
|
401
|
+
var _a;
|
|
402
|
+
const level = (_a = options === null || options === void 0 ? void 0 : options.success) !== null && _a !== void 0 ? _a : 'quiet';
|
|
403
|
+
reporter.reportSuccess(level, this._value, this._detail);
|
|
404
|
+
return this;
|
|
405
|
+
}
|
|
379
406
|
/**
|
|
380
407
|
* Creates a {@link DetailedSuccess | DetailedSuccess<T, TD>} with the supplied value and
|
|
381
408
|
* optional detail.
|
|
@@ -452,6 +479,15 @@ class DetailedFailure extends Failure {
|
|
|
452
479
|
withErrorFormat(cb) {
|
|
453
480
|
return failWithDetail(cb(this._message, this._detail), this._detail);
|
|
454
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* {@inheritdoc IResult.report}
|
|
484
|
+
*/
|
|
485
|
+
report(reporter, options) {
|
|
486
|
+
var _a;
|
|
487
|
+
const level = (_a = options === null || options === void 0 ? void 0 : options.failure) !== null && _a !== void 0 ? _a : 'error';
|
|
488
|
+
reporter.reportFailure(level, this._message, this._detail);
|
|
489
|
+
return this;
|
|
490
|
+
}
|
|
455
491
|
orThrow(logOrFormat) {
|
|
456
492
|
if (logOrFormat !== undefined) {
|
|
457
493
|
if (typeof logOrFormat === 'function') {
|
|
@@ -19,6 +19,11 @@ export interface IReadOnlyCollector<TITEM extends ICollectible<any, any>> extend
|
|
|
19
19
|
* with an error if the index is out of range.
|
|
20
20
|
*/
|
|
21
21
|
getAt(index: number): Result<TITEM>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets all items in the collection, ordered by index.
|
|
24
|
+
* @returns An array of items in the collection, ordered by index.
|
|
25
|
+
*/
|
|
26
|
+
valuesByIndex(): ReadonlyArray<TITEM>;
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
29
|
* Parameters for constructing a {@link Collections.Collector | ICollector}.
|
|
@@ -115,6 +120,10 @@ export declare class Collector<TITEM extends ICollectible<any, any>> implements
|
|
|
115
120
|
* {@inheritdoc Collections.ResultMap.values}
|
|
116
121
|
*/
|
|
117
122
|
values(): IterableIterator<TITEM>;
|
|
123
|
+
/**
|
|
124
|
+
* {@inheritdoc Collections.IReadOnlyCollector.valuesByIndex}
|
|
125
|
+
*/
|
|
126
|
+
valuesByIndex(): ReadonlyArray<TITEM>;
|
|
118
127
|
/**
|
|
119
128
|
* Gets a read-only version of this collector.
|
|
120
129
|
*/
|
|
@@ -157,6 +157,12 @@ class Collector {
|
|
|
157
157
|
values() {
|
|
158
158
|
return this._byKey.values();
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* {@inheritdoc Collections.IReadOnlyCollector.valuesByIndex}
|
|
162
|
+
*/
|
|
163
|
+
valuesByIndex() {
|
|
164
|
+
return this._byIndex;
|
|
165
|
+
}
|
|
160
166
|
/**
|
|
161
167
|
* Gets a read-only version of this collector.
|
|
162
168
|
*/
|
|
@@ -18,7 +18,11 @@ export interface IReadOnlyValidatingCollector<TITEM extends ICollectible<any, an
|
|
|
18
18
|
/**
|
|
19
19
|
* {@inheritdoc Collections.IReadOnlyValidatingCollector.getAt}
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
getAt(index: number): Result<TITEM>;
|
|
22
|
+
/**
|
|
23
|
+
* {@inheritdoc Collections.IReadOnlyCollector.valuesByIndex}
|
|
24
|
+
*/
|
|
25
|
+
valuesByIndex(): ReadonlyArray<TITEM>;
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* Parameters for constructing a {@link Collections.ValidatingCollector | ValidatingCollector}.
|
|
@@ -51,13 +51,14 @@ class HashingNormalizer extends base_1.Normalizer {
|
|
|
51
51
|
}
|
|
52
52
|
else if (Array.isArray(from)) {
|
|
53
53
|
return (0, base_1.mapResults)(from.map((e) => this.computeHash(e))).onSuccess((a) => {
|
|
54
|
-
return (0, base_1.captureResult)(() => this._hash(a));
|
|
54
|
+
return (0, base_1.captureResult)(() => this._hash(['array', ...a]));
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
else if (from instanceof Map || from instanceof Set) {
|
|
58
|
-
|
|
58
|
+
const type = from instanceof Map ? 'map' : 'set';
|
|
59
|
+
return this.computeHash([type, ...this.normalizeEntries(from.entries())]);
|
|
59
60
|
}
|
|
60
|
-
return this.computeHash(this.normalizeEntries(Object.entries(from)));
|
|
61
|
+
return this.computeHash(['object', ...this.normalizeEntries(Object.entries(from))]);
|
|
61
62
|
}
|
|
62
63
|
return (0, base_1.fail)(`computeHash: Unexpected type - cannot hash '${typeof from}'`);
|
|
63
64
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright (c) 2020 Erik Fortune
|
|
3
4
|
*
|
|
@@ -19,6 +20,21 @@
|
|
|
19
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
21
|
* SOFTWARE.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
35
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
__exportStar(require("./logger"), exports);
|
|
39
|
+
__exportStar(require("./logReporter"), exports);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ILogger, ReporterLogLevel } from './logger';
|
|
2
|
+
import { IResultReporter, MessageLogLevel, Success } from '../base';
|
|
3
|
+
/**
|
|
4
|
+
* A function that formats a value for logging.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export type LogValueFormatter<T, TD = unknown> = (value: T, detail?: TD) => string;
|
|
8
|
+
/**
|
|
9
|
+
* A function that formats a message for logging.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type LogMessageFormatter<TD = unknown> = (message: string, detail?: TD) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Parameters for creating a {@link Logging.LogReporter | LogReporter}.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface ILogReporterCreateParams<T, TD = unknown> {
|
|
18
|
+
logger: ILogger;
|
|
19
|
+
valueFormatter?: LogValueFormatter<T, TD>;
|
|
20
|
+
messageFormatter?: LogMessageFormatter<TD>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Abstract base class which wraps an existing {@link Logging.ILogger | ILogger} to implement
|
|
24
|
+
* both {@link Logging.ILogger | ILogger} and {@link IResultReporter | IResultReporter}.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare class LogReporter<T, TD = unknown> implements ILogger, IResultReporter<T, TD> {
|
|
28
|
+
protected readonly _logger: ILogger;
|
|
29
|
+
protected readonly _valueFormatter: LogValueFormatter<T, TD>;
|
|
30
|
+
protected readonly _messageFormatter: LogMessageFormatter<TD>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new {@link Logging.LogReporter | LogReporter}.
|
|
33
|
+
* @param params - The parameters for creating the {@link Logging.LogReporter | LogReporter}.
|
|
34
|
+
*/
|
|
35
|
+
constructor(params: ILogReporterCreateParams<T, TD>);
|
|
36
|
+
/**
|
|
37
|
+
* {@inheritDoc Logging.ILogger.logLevel}
|
|
38
|
+
*/
|
|
39
|
+
get logLevel(): ReporterLogLevel;
|
|
40
|
+
/**
|
|
41
|
+
* {@inheritDoc Logging.ILogger.detail}
|
|
42
|
+
*/
|
|
43
|
+
detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* {@inheritDoc Logging.ILogger.info}
|
|
46
|
+
*/
|
|
47
|
+
info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* {@inheritDoc Logging.ILogger.warn}
|
|
50
|
+
*/
|
|
51
|
+
warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc Logging.ILogger.error}
|
|
54
|
+
*/
|
|
55
|
+
error(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* {@inheritDoc Logging.ILogger.log}
|
|
58
|
+
*/
|
|
59
|
+
log(level: MessageLogLevel, message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* {@inheritDoc IResultReporter.reportSuccess}
|
|
62
|
+
*/
|
|
63
|
+
reportSuccess(level: MessageLogLevel, value: T, detail?: TD): void;
|
|
64
|
+
/**
|
|
65
|
+
* {@inheritDoc IResultReporter.reportFailure}
|
|
66
|
+
*/
|
|
67
|
+
reportFailure(level: MessageLogLevel, message: string, detail?: TD): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=logReporter.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogReporter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class which wraps an existing {@link Logging.ILogger | ILogger} to implement
|
|
6
|
+
* both {@link Logging.ILogger | ILogger} and {@link IResultReporter | IResultReporter}.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
class LogReporter {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new {@link Logging.LogReporter | LogReporter}.
|
|
12
|
+
* @param params - The parameters for creating the {@link Logging.LogReporter | LogReporter}.
|
|
13
|
+
*/
|
|
14
|
+
constructor(params) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
this._logger = params.logger;
|
|
17
|
+
this._valueFormatter = (_a = params.valueFormatter) !== null && _a !== void 0 ? _a : ((message, __detail) => String(message));
|
|
18
|
+
this._messageFormatter = (_b = params.messageFormatter) !== null && _b !== void 0 ? _b : ((message, __detail) => message);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* {@inheritDoc Logging.ILogger.logLevel}
|
|
22
|
+
*/
|
|
23
|
+
get logLevel() {
|
|
24
|
+
return this._logger.logLevel;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* {@inheritDoc Logging.ILogger.detail}
|
|
28
|
+
*/
|
|
29
|
+
detail(message, ...parameters) {
|
|
30
|
+
return this._logger.detail(message, ...parameters);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* {@inheritDoc Logging.ILogger.info}
|
|
34
|
+
*/
|
|
35
|
+
info(message, ...parameters) {
|
|
36
|
+
return this._logger.info(message, ...parameters);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* {@inheritDoc Logging.ILogger.warn}
|
|
40
|
+
*/
|
|
41
|
+
warn(message, ...parameters) {
|
|
42
|
+
return this._logger.warn(message, ...parameters);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* {@inheritDoc Logging.ILogger.error}
|
|
46
|
+
*/
|
|
47
|
+
error(message, ...parameters) {
|
|
48
|
+
return this._logger.error(message, ...parameters);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* {@inheritDoc Logging.ILogger.log}
|
|
52
|
+
*/
|
|
53
|
+
log(level, message, ...parameters) {
|
|
54
|
+
return this._logger.log(level, message, ...parameters);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* {@inheritDoc IResultReporter.reportSuccess}
|
|
58
|
+
*/
|
|
59
|
+
reportSuccess(level, value, detail) {
|
|
60
|
+
const formatted = this._valueFormatter(value, detail);
|
|
61
|
+
this.log(level, formatted);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* {@inheritDoc IResultReporter.reportFailure}
|
|
65
|
+
*/
|
|
66
|
+
reportFailure(level, message, detail) {
|
|
67
|
+
const formatted = this._messageFormatter(message, detail);
|
|
68
|
+
this.log(level, formatted);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.LogReporter = LogReporter;
|
|
72
|
+
//# sourceMappingURL=logReporter.js.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { MessageLogLevel, Success } from '../base';
|
|
2
|
+
/**
|
|
3
|
+
* The level of logging to be used.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type ReporterLogLevel = 'all' | 'detail' | 'info' | 'warning' | 'error' | 'silent';
|
|
7
|
+
/**
|
|
8
|
+
* Compares two log levels.
|
|
9
|
+
* @param message - The first log level.
|
|
10
|
+
* @param reporter - The second log level.
|
|
11
|
+
* @returns `true` if the message should be logged, `false` if it should be suppressed.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare function shouldLog(message: MessageLogLevel, reporter: ReporterLogLevel): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Generic Result-aware logger interface with multiple levels of logging.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export interface ILogger {
|
|
20
|
+
/**
|
|
21
|
+
* The level of logging to be used.
|
|
22
|
+
*/
|
|
23
|
+
readonly logLevel: ReporterLogLevel;
|
|
24
|
+
/**
|
|
25
|
+
* Logs a message at the given level.
|
|
26
|
+
* @param level - The level of the message.
|
|
27
|
+
* @param message - The message to log.
|
|
28
|
+
* @param parameters - The parameters to log.
|
|
29
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
30
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
31
|
+
*/
|
|
32
|
+
log(level: MessageLogLevel, message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Logs a detail message.
|
|
35
|
+
* @param message - The message to log.
|
|
36
|
+
* @param parameters - The parameters to log.
|
|
37
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
38
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
39
|
+
*/
|
|
40
|
+
detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Logs an info message.
|
|
43
|
+
* @param message - The message to log.
|
|
44
|
+
* @param parameters - The parameters to log.
|
|
45
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
46
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
47
|
+
*/
|
|
48
|
+
info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Logs a warning message.
|
|
51
|
+
* @param message - The message to log.
|
|
52
|
+
* @param parameters - The parameters to log.
|
|
53
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
54
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
55
|
+
*/
|
|
56
|
+
warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Logs an error message.
|
|
59
|
+
* @param message - The message to log.
|
|
60
|
+
* @param parameters - The parameters to log.
|
|
61
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
62
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
63
|
+
*/
|
|
64
|
+
error(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Abstract base class which implements {@link Logging.ILogger | ILogger}.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare abstract class LoggerBase implements ILogger {
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritDoc Logging.ILogger.logLevel}
|
|
73
|
+
*/
|
|
74
|
+
logLevel: ReporterLogLevel;
|
|
75
|
+
protected constructor(logLevel?: ReporterLogLevel);
|
|
76
|
+
/**
|
|
77
|
+
* {@inheritDoc Logging.ILogger.detail}
|
|
78
|
+
*/
|
|
79
|
+
detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* {@inheritDoc Logging.ILogger.info}
|
|
82
|
+
*/
|
|
83
|
+
info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
84
|
+
/**
|
|
85
|
+
* {@inheritDoc Logging.ILogger.warn}
|
|
86
|
+
*/
|
|
87
|
+
warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
88
|
+
/**
|
|
89
|
+
* {@inheritDoc Logging.ILogger.error}
|
|
90
|
+
*/
|
|
91
|
+
error(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
92
|
+
/**
|
|
93
|
+
* {@inheritDoc Logging.ILogger.log}
|
|
94
|
+
*/
|
|
95
|
+
log(level: MessageLogLevel, message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* Formats a message and parameters into a string.
|
|
98
|
+
* @param message - The message to format.
|
|
99
|
+
* @param parameters - The parameters to format.
|
|
100
|
+
* @returns The formatted message.
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
protected _format(message?: unknown, ...parameters: unknown[]): string;
|
|
104
|
+
/**
|
|
105
|
+
* Inner method called for suppressed log messages.
|
|
106
|
+
*/
|
|
107
|
+
protected _suppressLog(__level: MessageLogLevel, __message?: unknown, ...__parameters: unknown[]): Success<undefined>;
|
|
108
|
+
protected abstract _log(message: string, level: MessageLogLevel): Success<string | undefined>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* An in-memory logger that stores logged and suppressed messages.
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export declare class InMemoryLogger extends LoggerBase {
|
|
115
|
+
/**
|
|
116
|
+
* The messages that have been logged.
|
|
117
|
+
*/
|
|
118
|
+
protected _logged: string[];
|
|
119
|
+
/**
|
|
120
|
+
* The messages that have been suppressed.
|
|
121
|
+
*/
|
|
122
|
+
protected _suppressed: string[];
|
|
123
|
+
/**
|
|
124
|
+
* Creates a new in-memory logger.
|
|
125
|
+
* @param logLevel - The level of logging to be used.
|
|
126
|
+
*/
|
|
127
|
+
constructor(logLevel?: ReporterLogLevel);
|
|
128
|
+
/**
|
|
129
|
+
* The messages that have been logged.
|
|
130
|
+
*/
|
|
131
|
+
get logged(): string[];
|
|
132
|
+
/**
|
|
133
|
+
* The messages that have been suppressed.
|
|
134
|
+
*/
|
|
135
|
+
get suppressed(): string[];
|
|
136
|
+
/**
|
|
137
|
+
* Clears the logged and suppressed messages.
|
|
138
|
+
*/
|
|
139
|
+
clear(): void;
|
|
140
|
+
/**
|
|
141
|
+
* {@inheritDoc Logging.LoggerBase._log}
|
|
142
|
+
*/
|
|
143
|
+
protected _log(message: string, __level: MessageLogLevel): Success<string | undefined>;
|
|
144
|
+
/**
|
|
145
|
+
* {@inheritDoc Logging.LoggerBase._suppressLog}
|
|
146
|
+
* @param level - The level of the message.
|
|
147
|
+
* @param message - The message to suppress.
|
|
148
|
+
* @param parameters - The parameters to suppress.
|
|
149
|
+
* @returns `Success` with `undefined` if the message is suppressed.
|
|
150
|
+
*/
|
|
151
|
+
protected _suppressLog(level: MessageLogLevel, message?: unknown, ...parameters: unknown[]): Success<undefined>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A console logger that outputs messages to the console.
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export declare class ConsoleLogger extends LoggerBase {
|
|
158
|
+
/**
|
|
159
|
+
* Creates a new console logger.
|
|
160
|
+
* @param logLevel - The level of logging to be used.
|
|
161
|
+
*/
|
|
162
|
+
constructor(logLevel?: ReporterLogLevel);
|
|
163
|
+
/**
|
|
164
|
+
* {@inheritDoc Logging.LoggerBase._log}
|
|
165
|
+
*/
|
|
166
|
+
protected _log(message: string, level: MessageLogLevel): Success<string | undefined>;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A no-op {@link Logging.LoggerBase | LoggerBase} that does not log anything.
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
export declare class NoOpLogger extends LoggerBase {
|
|
173
|
+
/**
|
|
174
|
+
* Creates a new no-op logger.
|
|
175
|
+
* @param logLevel - The level of logging to be used.
|
|
176
|
+
*/
|
|
177
|
+
constructor(logLevel?: ReporterLogLevel);
|
|
178
|
+
/**
|
|
179
|
+
* {@inheritDoc Logging.LoggerBase._log}
|
|
180
|
+
*/
|
|
181
|
+
protected _log(message: string, __level: MessageLogLevel): Success<string | undefined>;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=logger.d.ts.map
|