@punks/backend-core 0.0.36 → 0.0.37
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.
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ILogger, LogLevel, MetaSerializationType } from "../abstractions";
|
|
2
2
|
export declare class Log {
|
|
3
|
-
private static
|
|
4
|
-
private static level;
|
|
5
|
-
private static metaSerialization;
|
|
3
|
+
private static readonly options;
|
|
6
4
|
static setSerializationType(type: MetaSerializationType): void;
|
|
7
5
|
static setLevel(level: LogLevel): void;
|
|
8
6
|
static enable(): void;
|
package/dist/esm/index.js
CHANGED
|
@@ -28429,44 +28429,42 @@ class DefaultLogger {
|
|
|
28429
28429
|
}
|
|
28430
28430
|
|
|
28431
28431
|
class InternalLogger {
|
|
28432
|
-
constructor(
|
|
28433
|
-
this.
|
|
28434
|
-
this.level = level;
|
|
28435
|
-
this.serialization = serialization;
|
|
28432
|
+
constructor(options, provider) {
|
|
28433
|
+
this.options = options;
|
|
28436
28434
|
this.provider = provider;
|
|
28437
28435
|
}
|
|
28438
28436
|
debug(message, meta) {
|
|
28439
|
-
if (this.enabled && this.level === LogLevel.Debug) {
|
|
28437
|
+
if (this.options.enabled && this.options.level === LogLevel.Debug) {
|
|
28440
28438
|
this.provider.debug(message, this.serializeMeta(meta));
|
|
28441
28439
|
}
|
|
28442
28440
|
}
|
|
28443
28441
|
info(message, meta) {
|
|
28444
|
-
if (this.enabled && this.level <= LogLevel.Info) {
|
|
28442
|
+
if (this.options.enabled && this.options.level <= LogLevel.Info) {
|
|
28445
28443
|
this.provider.info(message, this.serializeMeta(meta));
|
|
28446
28444
|
}
|
|
28447
28445
|
}
|
|
28448
28446
|
warn(message, meta) {
|
|
28449
|
-
if (this.enabled && this.level <= LogLevel.Warn) {
|
|
28447
|
+
if (this.options.enabled && this.options.level <= LogLevel.Warn) {
|
|
28450
28448
|
this.provider.warn(message, this.serializeMeta(meta));
|
|
28451
28449
|
}
|
|
28452
28450
|
}
|
|
28453
28451
|
error(message, meta) {
|
|
28454
|
-
if (this.enabled && this.level <= LogLevel.Error) {
|
|
28452
|
+
if (this.options.enabled && this.options.level <= LogLevel.Error) {
|
|
28455
28453
|
this.provider.error(message, this.serializeMeta(meta));
|
|
28456
28454
|
}
|
|
28457
28455
|
}
|
|
28458
28456
|
fatal(message, meta) {
|
|
28459
|
-
if (this.enabled && this.level <= LogLevel.Fatal) {
|
|
28457
|
+
if (this.options.enabled && this.options.level <= LogLevel.Fatal) {
|
|
28460
28458
|
this.provider.fatal(message, this.serializeMeta(meta));
|
|
28461
28459
|
}
|
|
28462
28460
|
}
|
|
28463
28461
|
exception(message, error, meta) {
|
|
28464
|
-
if (this.enabled && this.level <= LogLevel.Error) {
|
|
28462
|
+
if (this.options.enabled && this.options.level <= LogLevel.Error) {
|
|
28465
28463
|
this.provider.exception(message, error, this.serializeMeta(meta));
|
|
28466
28464
|
}
|
|
28467
28465
|
}
|
|
28468
28466
|
serializeMeta(meta) {
|
|
28469
|
-
switch (this.serialization) {
|
|
28467
|
+
switch (this.options.serialization) {
|
|
28470
28468
|
case MetaSerializationType.JSON:
|
|
28471
28469
|
return JSON.stringify(meta, null, 2);
|
|
28472
28470
|
case MetaSerializationType.None:
|
|
@@ -28475,35 +28473,36 @@ class InternalLogger {
|
|
|
28475
28473
|
}
|
|
28476
28474
|
}
|
|
28477
28475
|
}
|
|
28478
|
-
const getLogger = ({
|
|
28479
|
-
return new InternalLogger(
|
|
28476
|
+
const getLogger = ({ options, loggerName, }) => {
|
|
28477
|
+
return new InternalLogger(options, new DefaultLogger(loggerName));
|
|
28480
28478
|
};
|
|
28481
28479
|
class Log {
|
|
28482
28480
|
static setSerializationType(type) {
|
|
28483
|
-
this.
|
|
28481
|
+
this.options.serialization = type;
|
|
28484
28482
|
}
|
|
28485
28483
|
static setLevel(level) {
|
|
28486
|
-
this.level = level;
|
|
28487
|
-
this.
|
|
28484
|
+
this.options.level = level;
|
|
28485
|
+
this.options.level = level;
|
|
28486
|
+
this.options.enabled = true;
|
|
28488
28487
|
}
|
|
28489
28488
|
static enable() {
|
|
28490
|
-
this.enabled = true;
|
|
28489
|
+
this.options.enabled = true;
|
|
28491
28490
|
}
|
|
28492
28491
|
static disable() {
|
|
28493
|
-
this.enabled = false;
|
|
28492
|
+
this.options.enabled = false;
|
|
28494
28493
|
}
|
|
28495
28494
|
static getLogger(loggerName) {
|
|
28496
28495
|
return getLogger({
|
|
28497
|
-
|
|
28498
|
-
level: this.level,
|
|
28499
|
-
serialization: this.metaSerialization,
|
|
28496
|
+
options: this.options,
|
|
28500
28497
|
loggerName,
|
|
28501
28498
|
});
|
|
28502
28499
|
}
|
|
28503
28500
|
}
|
|
28504
|
-
Log.
|
|
28505
|
-
|
|
28506
|
-
|
|
28501
|
+
Log.options = {
|
|
28502
|
+
enabled: true,
|
|
28503
|
+
level: LogLevel.Debug,
|
|
28504
|
+
serialization: MetaSerializationType.None,
|
|
28505
|
+
};
|
|
28507
28506
|
|
|
28508
28507
|
export { ExcelKeyTransform, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, groupBy, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, last, mapOrThrow, mergeDeep, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, subArrays, subtractTime, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
|
|
28509
28508
|
//# sourceMappingURL=index.js.map
|