@punks/backend-core 0.0.35 → 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 +39 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/logging/service.d.ts +1 -3
- package/dist/cjs/types/utils/{objects.d.ts → objects/index.d.ts} +1 -0
- package/dist/esm/index.js +39 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/logging/service.d.ts +1 -3
- package/dist/esm/types/utils/{objects.d.ts → objects/index.d.ts} +1 -0
- package/dist/esm/types/utils/objects/mergeDeep.spec.d.ts +1 -0
- package/dist/esm/types/utils/objects/removeUndefinedProps.spec.d.ts +1 -0
- package/dist/index.d.ts +3 -4
- package/package.json +1 -1
- /package/dist/cjs/types/utils/{objects.test.d.ts → objects/mergeDeep.spec.d.ts} +0 -0
- /package/dist/{esm/types/utils/objects.test.d.ts → cjs/types/utils/objects/removeUndefinedProps.spec.d.ts} +0 -0
|
@@ -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
|
@@ -272,6 +272,21 @@ const buildObject = (...props) => {
|
|
|
272
272
|
}
|
|
273
273
|
return out;
|
|
274
274
|
};
|
|
275
|
+
const mergeDeep = (a, b) => {
|
|
276
|
+
const c = { ...(a ?? {}) };
|
|
277
|
+
for (const key in b ?? {}) {
|
|
278
|
+
if (b.hasOwnProperty(key)) {
|
|
279
|
+
const value = b[key];
|
|
280
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
281
|
+
c[key] = mergeDeep(c[key] ?? {}, value);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
c[key] = value;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return c;
|
|
289
|
+
};
|
|
275
290
|
|
|
276
291
|
const pluralize = (word) => {
|
|
277
292
|
return word.endsWith("s") ? `${word}es` : `${word}s`;
|
|
@@ -28414,44 +28429,42 @@ class DefaultLogger {
|
|
|
28414
28429
|
}
|
|
28415
28430
|
|
|
28416
28431
|
class InternalLogger {
|
|
28417
|
-
constructor(
|
|
28418
|
-
this.
|
|
28419
|
-
this.level = level;
|
|
28420
|
-
this.serialization = serialization;
|
|
28432
|
+
constructor(options, provider) {
|
|
28433
|
+
this.options = options;
|
|
28421
28434
|
this.provider = provider;
|
|
28422
28435
|
}
|
|
28423
28436
|
debug(message, meta) {
|
|
28424
|
-
if (this.enabled && this.level === LogLevel.Debug) {
|
|
28437
|
+
if (this.options.enabled && this.options.level === LogLevel.Debug) {
|
|
28425
28438
|
this.provider.debug(message, this.serializeMeta(meta));
|
|
28426
28439
|
}
|
|
28427
28440
|
}
|
|
28428
28441
|
info(message, meta) {
|
|
28429
|
-
if (this.enabled && this.level <= LogLevel.Info) {
|
|
28442
|
+
if (this.options.enabled && this.options.level <= LogLevel.Info) {
|
|
28430
28443
|
this.provider.info(message, this.serializeMeta(meta));
|
|
28431
28444
|
}
|
|
28432
28445
|
}
|
|
28433
28446
|
warn(message, meta) {
|
|
28434
|
-
if (this.enabled && this.level <= LogLevel.Warn) {
|
|
28447
|
+
if (this.options.enabled && this.options.level <= LogLevel.Warn) {
|
|
28435
28448
|
this.provider.warn(message, this.serializeMeta(meta));
|
|
28436
28449
|
}
|
|
28437
28450
|
}
|
|
28438
28451
|
error(message, meta) {
|
|
28439
|
-
if (this.enabled && this.level <= LogLevel.Error) {
|
|
28452
|
+
if (this.options.enabled && this.options.level <= LogLevel.Error) {
|
|
28440
28453
|
this.provider.error(message, this.serializeMeta(meta));
|
|
28441
28454
|
}
|
|
28442
28455
|
}
|
|
28443
28456
|
fatal(message, meta) {
|
|
28444
|
-
if (this.enabled && this.level <= LogLevel.Fatal) {
|
|
28457
|
+
if (this.options.enabled && this.options.level <= LogLevel.Fatal) {
|
|
28445
28458
|
this.provider.fatal(message, this.serializeMeta(meta));
|
|
28446
28459
|
}
|
|
28447
28460
|
}
|
|
28448
28461
|
exception(message, error, meta) {
|
|
28449
|
-
if (this.enabled && this.level <= LogLevel.Error) {
|
|
28462
|
+
if (this.options.enabled && this.options.level <= LogLevel.Error) {
|
|
28450
28463
|
this.provider.exception(message, error, this.serializeMeta(meta));
|
|
28451
28464
|
}
|
|
28452
28465
|
}
|
|
28453
28466
|
serializeMeta(meta) {
|
|
28454
|
-
switch (this.serialization) {
|
|
28467
|
+
switch (this.options.serialization) {
|
|
28455
28468
|
case MetaSerializationType.JSON:
|
|
28456
28469
|
return JSON.stringify(meta, null, 2);
|
|
28457
28470
|
case MetaSerializationType.None:
|
|
@@ -28460,35 +28473,36 @@ class InternalLogger {
|
|
|
28460
28473
|
}
|
|
28461
28474
|
}
|
|
28462
28475
|
}
|
|
28463
|
-
const getLogger = ({
|
|
28464
|
-
return new InternalLogger(
|
|
28476
|
+
const getLogger = ({ options, loggerName, }) => {
|
|
28477
|
+
return new InternalLogger(options, new DefaultLogger(loggerName));
|
|
28465
28478
|
};
|
|
28466
28479
|
class Log {
|
|
28467
28480
|
static setSerializationType(type) {
|
|
28468
|
-
this.
|
|
28481
|
+
this.options.serialization = type;
|
|
28469
28482
|
}
|
|
28470
28483
|
static setLevel(level) {
|
|
28471
|
-
this.level = level;
|
|
28472
|
-
this.
|
|
28484
|
+
this.options.level = level;
|
|
28485
|
+
this.options.level = level;
|
|
28486
|
+
this.options.enabled = true;
|
|
28473
28487
|
}
|
|
28474
28488
|
static enable() {
|
|
28475
|
-
this.enabled = true;
|
|
28489
|
+
this.options.enabled = true;
|
|
28476
28490
|
}
|
|
28477
28491
|
static disable() {
|
|
28478
|
-
this.enabled = false;
|
|
28492
|
+
this.options.enabled = false;
|
|
28479
28493
|
}
|
|
28480
28494
|
static getLogger(loggerName) {
|
|
28481
28495
|
return getLogger({
|
|
28482
|
-
|
|
28483
|
-
level: this.level,
|
|
28484
|
-
serialization: this.metaSerialization,
|
|
28496
|
+
options: this.options,
|
|
28485
28497
|
loggerName,
|
|
28486
28498
|
});
|
|
28487
28499
|
}
|
|
28488
28500
|
}
|
|
28489
|
-
Log.
|
|
28490
|
-
|
|
28491
|
-
|
|
28501
|
+
Log.options = {
|
|
28502
|
+
enabled: true,
|
|
28503
|
+
level: LogLevel.Debug,
|
|
28504
|
+
serialization: MetaSerializationType.None,
|
|
28505
|
+
};
|
|
28492
28506
|
|
|
28493
|
-
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, 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 };
|
|
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 };
|
|
28494
28508
|
//# sourceMappingURL=index.js.map
|