@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.
package/dist/cjs/index.js
CHANGED
|
@@ -28438,44 +28438,42 @@ class DefaultLogger {
|
|
|
28438
28438
|
}
|
|
28439
28439
|
|
|
28440
28440
|
class InternalLogger {
|
|
28441
|
-
constructor(
|
|
28442
|
-
this.
|
|
28443
|
-
this.level = level;
|
|
28444
|
-
this.serialization = serialization;
|
|
28441
|
+
constructor(options, provider) {
|
|
28442
|
+
this.options = options;
|
|
28445
28443
|
this.provider = provider;
|
|
28446
28444
|
}
|
|
28447
28445
|
debug(message, meta) {
|
|
28448
|
-
if (this.enabled && this.level === exports.LogLevel.Debug) {
|
|
28446
|
+
if (this.options.enabled && this.options.level === exports.LogLevel.Debug) {
|
|
28449
28447
|
this.provider.debug(message, this.serializeMeta(meta));
|
|
28450
28448
|
}
|
|
28451
28449
|
}
|
|
28452
28450
|
info(message, meta) {
|
|
28453
|
-
if (this.enabled && this.level <= exports.LogLevel.Info) {
|
|
28451
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Info) {
|
|
28454
28452
|
this.provider.info(message, this.serializeMeta(meta));
|
|
28455
28453
|
}
|
|
28456
28454
|
}
|
|
28457
28455
|
warn(message, meta) {
|
|
28458
|
-
if (this.enabled && this.level <= exports.LogLevel.Warn) {
|
|
28456
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Warn) {
|
|
28459
28457
|
this.provider.warn(message, this.serializeMeta(meta));
|
|
28460
28458
|
}
|
|
28461
28459
|
}
|
|
28462
28460
|
error(message, meta) {
|
|
28463
|
-
if (this.enabled && this.level <= exports.LogLevel.Error) {
|
|
28461
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Error) {
|
|
28464
28462
|
this.provider.error(message, this.serializeMeta(meta));
|
|
28465
28463
|
}
|
|
28466
28464
|
}
|
|
28467
28465
|
fatal(message, meta) {
|
|
28468
|
-
if (this.enabled && this.level <= exports.LogLevel.Fatal) {
|
|
28466
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Fatal) {
|
|
28469
28467
|
this.provider.fatal(message, this.serializeMeta(meta));
|
|
28470
28468
|
}
|
|
28471
28469
|
}
|
|
28472
28470
|
exception(message, error, meta) {
|
|
28473
|
-
if (this.enabled && this.level <= exports.LogLevel.Error) {
|
|
28471
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Error) {
|
|
28474
28472
|
this.provider.exception(message, error, this.serializeMeta(meta));
|
|
28475
28473
|
}
|
|
28476
28474
|
}
|
|
28477
28475
|
serializeMeta(meta) {
|
|
28478
|
-
switch (this.serialization) {
|
|
28476
|
+
switch (this.options.serialization) {
|
|
28479
28477
|
case exports.MetaSerializationType.JSON:
|
|
28480
28478
|
return JSON.stringify(meta, null, 2);
|
|
28481
28479
|
case exports.MetaSerializationType.None:
|
|
@@ -28484,35 +28482,36 @@ class InternalLogger {
|
|
|
28484
28482
|
}
|
|
28485
28483
|
}
|
|
28486
28484
|
}
|
|
28487
|
-
const getLogger = ({
|
|
28488
|
-
return new InternalLogger(
|
|
28485
|
+
const getLogger = ({ options, loggerName, }) => {
|
|
28486
|
+
return new InternalLogger(options, new DefaultLogger(loggerName));
|
|
28489
28487
|
};
|
|
28490
28488
|
class Log {
|
|
28491
28489
|
static setSerializationType(type) {
|
|
28492
|
-
this.
|
|
28490
|
+
this.options.serialization = type;
|
|
28493
28491
|
}
|
|
28494
28492
|
static setLevel(level) {
|
|
28495
|
-
this.level = level;
|
|
28496
|
-
this.
|
|
28493
|
+
this.options.level = level;
|
|
28494
|
+
this.options.level = level;
|
|
28495
|
+
this.options.enabled = true;
|
|
28497
28496
|
}
|
|
28498
28497
|
static enable() {
|
|
28499
|
-
this.enabled = true;
|
|
28498
|
+
this.options.enabled = true;
|
|
28500
28499
|
}
|
|
28501
28500
|
static disable() {
|
|
28502
|
-
this.enabled = false;
|
|
28501
|
+
this.options.enabled = false;
|
|
28503
28502
|
}
|
|
28504
28503
|
static getLogger(loggerName) {
|
|
28505
28504
|
return getLogger({
|
|
28506
|
-
|
|
28507
|
-
level: this.level,
|
|
28508
|
-
serialization: this.metaSerialization,
|
|
28505
|
+
options: this.options,
|
|
28509
28506
|
loggerName,
|
|
28510
28507
|
});
|
|
28511
28508
|
}
|
|
28512
28509
|
}
|
|
28513
|
-
Log.
|
|
28514
|
-
|
|
28515
|
-
|
|
28510
|
+
Log.options = {
|
|
28511
|
+
enabled: true,
|
|
28512
|
+
level: exports.LogLevel.Debug,
|
|
28513
|
+
serialization: exports.MetaSerializationType.None,
|
|
28514
|
+
};
|
|
28516
28515
|
|
|
28517
28516
|
exports.Log = Log;
|
|
28518
28517
|
exports.addTime = addTime;
|