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

@@ -1,5 +1,3 @@
import { formatError } from "pretty-print-error";
import { decryptSecret } from "@homarr/common/server";
import type { Integration } from "@homarr/db/schema";
import type { IntegrationKind, IntegrationSecretKind } from "@homarr/definitions";
@@ -41,7 +39,10 @@ export const testConnectionAsync = async (
};
} catch (error) {
logger.warn(
`Failed to decrypt secret from database integration="${integration.name}" secretKind="${secret.kind}"\n${formatError(error)}`,
new Error(
`Failed to decrypt secret from database integration="${integration.name}" secretKind="${secret.kind}"`,
{ cause: error },
),
);
return null;
}

View File

@@ -1,5 +1,3 @@
import { formatError } from "pretty-print-error";
import { logger } from "@homarr/log";
import { updateCheckerRequestHandler } from "@homarr/request-handler/update-checker";
@@ -12,7 +10,7 @@ export const updateCheckerRouter = createTRPCRouter({
const data = await handler.getCachedOrUpdatedDataAsync({});
return data.data.availableUpdates;
} catch (error) {
logger.error(`Failed to get available updates\n${formatError(error)}`);
logger.error(new Error("Failed to get available updates", { cause: error }));
return undefined; // We return undefined to not show the indicator in the UI
}
}),