@likec4/log 1.43.0 → 1.44.0

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/index.mjs CHANGED
@@ -1283,9 +1283,10 @@ const parseStack = (stack) => {
1283
1283
  });
1284
1284
  return lines;
1285
1285
  };
1286
- function ident(value, identation = 2) {
1286
+ function indent(value, indentation = 2) {
1287
1287
  value = Array.isArray(value) ? value : value.split("\n");
1288
- return value.map((l) => `${" ".repeat(identation)}${l}`).join("\n");
1288
+ const prefix = " ".repeat(indentation);
1289
+ return value.map((l) => `${prefix}${l}`).join("\n");
1289
1290
  }
1290
1291
  function loggable(error) {
1291
1292
  if (typeof error === "string") {
@@ -1295,11 +1296,11 @@ function loggable(error) {
1295
1296
  const mergedErr = mergeErrorCause(error);
1296
1297
  if (mergedErr.stack) {
1297
1298
  const stack = parseStack(mergedErr.stack);
1298
- return mergedErr.message + "\n" + ident(stack.slice(1));
1299
+ return mergedErr.message + "\n" + indent(stack.slice(1));
1299
1300
  }
1300
1301
  return mergedErr.message;
1301
1302
  }
1302
- return safeStringify(error);
1303
+ return safeStringify(error, { indentation: " " });
1303
1304
  }
1304
1305
 
1305
1306
  function gerErrorFromLogRecord(record) {
@@ -1327,14 +1328,14 @@ function appendErrorToMessage(values, color) {
1327
1328
  if (error) {
1328
1329
  let errorMessge = error.message;
1329
1330
  if (error.stack) {
1330
- errorMessge = errorMessge + "\n" + ident(error.stack.split("\n").slice(1));
1331
+ errorMessge = errorMessge + "\n" + indent(error.stack.split("\n").slice(1));
1331
1332
  }
1332
1333
  if (color) {
1333
1334
  errorMessge = `${ansiColors.red}${errorMessge}${RESET}`;
1334
1335
  }
1335
1336
  return {
1336
1337
  ...values,
1337
- message: values.message + "\n" + ident(errorMessge)
1338
+ message: values.message + "\n" + indent(errorMessge)
1338
1339
  };
1339
1340
  }
1340
1341
  return values;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@likec4/log",
3
3
  "description": "Shared interface for logging",
4
4
  "license": "MIT",
5
- "version": "1.43.0",
5
+ "version": "1.44.0",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
8
8
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -42,7 +42,7 @@
42
42
  "typescript": "5.9.3",
43
43
  "unbuild": "3.5.0",
44
44
  "wrap-error-message": "^3.0.1",
45
- "@likec4/tsconfig": "1.43.0",
45
+ "@likec4/tsconfig": "1.44.0",
46
46
  "@likec4/devops": "1.42.0"
47
47
  },
48
48
  "scripts": {
package/src/formatters.ts CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  } from '@logtape/logtape'
14
14
  import mergeErrorCause from 'merge-error-cause'
15
15
  import wrapErrorMessage from 'wrap-error-message'
16
- import { ident, parseStack } from './utils'
16
+ import { indent, parseStack } from './utils'
17
17
 
18
18
  function gerErrorFromLogRecord(record: LogRecord): Error | null {
19
19
  const errors = Object
@@ -45,14 +45,14 @@ export function appendErrorToMessage(values: FormattedValues, color?: boolean):
45
45
  if (error) {
46
46
  let errorMessge = error.message
47
47
  if (error.stack) {
48
- errorMessge = errorMessge + '\n' + ident(error.stack.split('\n').slice(1))
48
+ errorMessge = errorMessge + '\n' + indent(error.stack.split('\n').slice(1))
49
49
  }
50
50
  if (color) {
51
51
  errorMessge = `${ansiColors.red}${errorMessge}${RESET}`
52
52
  }
53
53
  return {
54
54
  ...values,
55
- message: values.message + '\n' + ident(errorMessge),
55
+ message: values.message + '\n' + indent(errorMessge),
56
56
  }
57
57
  }
58
58
  return values
package/src/utils.ts CHANGED
@@ -16,9 +16,10 @@ export const parseStack = (stack: string): string[] => {
16
16
  return lines
17
17
  }
18
18
 
19
- export function ident(value: string | string[], identation = 2): string {
19
+ export function indent(value: string | string[], indentation = 2): string {
20
20
  value = Array.isArray(value) ? value : value.split('\n')
21
- return value.map((l) => `${' '.repeat(identation)}${l}`).join('\n')
21
+ const prefix = ' '.repeat(indentation)
22
+ return value.map((l) => `${prefix}${l}`).join('\n')
22
23
  }
23
24
 
24
25
  export function loggable(error: unknown): string {
@@ -29,9 +30,9 @@ export function loggable(error: unknown): string {
29
30
  const mergedErr = mergeErrorCause(error)
30
31
  if (mergedErr.stack) {
31
32
  const stack = parseStack(mergedErr.stack)
32
- return mergedErr.message + '\n' + ident(stack.slice(1))
33
+ return mergedErr.message + '\n' + indent(stack.slice(1))
33
34
  }
34
35
  return mergedErr.message
35
36
  }
36
- return safeStringify(error)
37
+ return safeStringify(error, { indentation: '\t' })
37
38
  }