feat(logs): improve logs by logging errors with causes and metadata (#2703)

* feat(logs): improve logs by logging errors with causes and metadata

* fix: deepsource issue
This commit is contained in:
Meier Lukas
2025-03-26 21:53:51 +01:00
committed by GitHub
parent 3e1c000d51
commit 579dd5763d
10 changed files with 81 additions and 45 deletions

View File

@@ -0,0 +1,8 @@
export const formatMetadata = (metadata: Record<string, unknown> | Error, ignoreKeys?: string[]) => {
const filteredMetadata = Object.keys(metadata)
.filter((key) => !ignoreKeys?.includes(key))
.map((key) => ({ key, value: metadata[key as keyof typeof metadata] }))
.filter(({ value }) => typeof value !== "object" && typeof value !== "function");
return filteredMetadata.map(({ key, value }) => `${key}="${value as string}"`).join(" ");
};