@punks/backend-core 0.0.80 → 0.0.82

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.
@@ -8,6 +8,7 @@ type LoggerOptions = {
8
8
  level: LogLevel;
9
9
  loggerName?: string;
10
10
  serialization: MetaSerializationType;
11
+ maxMetaLength?: number;
11
12
  };
12
13
  export declare class Log {
13
14
  private static readonly container;
@@ -8,3 +8,4 @@ export declare const toTitleCase: (str: string) => string;
8
8
  export declare const ensureTailingSlash: (value: string) => string;
9
9
  export declare const ensureStartSlash: (value: string) => string;
10
10
  export declare const multipleSplit: (str: string, separators: string[]) => string[];
11
+ export declare const truncateString: (str: string, maxLength: number, filler?: string) => string;
package/dist/esm/index.js CHANGED
@@ -305,6 +305,7 @@ const multipleSplit = (str, separators) => {
305
305
  .join("|");
306
306
  return str.split(new RegExp(regexPattern));
307
307
  };
308
+ const truncateString = (str, maxLength, filler = "...") => (str.length > maxLength ? str.substring(0, maxLength) + filler : str);
308
309
 
309
310
  const removeUndefinedProps = (obj, options = { recursive: false }) => {
310
311
  const { recursive } = options;
@@ -31246,15 +31247,15 @@ class InternalLogger {
31246
31247
  if (meta && typeof meta === "string") {
31247
31248
  return meta;
31248
31249
  }
31249
- const serializedMeta = meta
31250
- ? jsonSerialize(meta, {
31251
- prettify: true,
31252
- stripBinaryData: true,
31253
- })
31254
- : undefined;
31250
+ const serializedMeta = jsonSerialize(meta, {
31251
+ prettify: true,
31252
+ stripBinaryData: true,
31253
+ });
31255
31254
  switch (options.serialization) {
31256
31255
  case MetaSerializationType.JSON:
31257
- return serializedMeta;
31256
+ return serializedMeta && options.maxMetaLength
31257
+ ? truncateString(serializedMeta, options.maxMetaLength, "...")
31258
+ : serializedMeta;
31258
31259
  case MetaSerializationType.None:
31259
31260
  default:
31260
31261
  return serializedMeta ? JSON.parse(serializedMeta) : undefined;
@@ -31466,5 +31467,5 @@ const processArrayItemMove = (items, input) => {
31466
31467
  }));
31467
31468
  };
31468
31469
 
31469
- export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, decodeBase64, decodeUtf8, deserializeQueryString, distinct, distinctElements, encodeBase64, encodeUtf8, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, generateHash, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, replaceUndefinedWithNull, selectMany, serializeQueryString, sleep, sort, splitPath, stripTags, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
31470
+ export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, decodeBase64, decodeUtf8, deserializeQueryString, distinct, distinctElements, encodeBase64, encodeUtf8, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, generateHash, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, replaceUndefinedWithNull, selectMany, serializeQueryString, sleep, sort, splitPath, stripTags, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, truncateString, updateQueryParameters };
31470
31471
  //# sourceMappingURL=index.js.map