Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logs not working properly #50

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40,480 changes: 40,480 additions & 0 deletions patches/@[email protected]

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions src/lib/logger/create-logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import packageJson from "../../../package.json";
import { attachLoggerConsoleTransport } from "./logger-console-transport";
import { createLogger, logger } from "./logger";
import { attachLoggerOtelTransport } from "./logger-otel-transport";
import { attachLoggerSentryTransport } from "./logger-sentry-transport";
import { loggerContext } from "@/logger-context";

logger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"];

if (process.env.NODE_ENV !== "production") {
attachLoggerConsoleTransport(logger);
}

if (typeof window === "undefined") {
attachLoggerSentryTransport(logger);

attachLoggerOtelTransport(logger, packageJson.version, loggerContext);
}

export { createLogger, logger };
2 changes: 1 addition & 1 deletion src/pages/api/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { saleorApp } from "../../saleor-app";
import { wrapWithLoggerContext } from "@/lib/logger/logger-context";
import { withOtel } from "@/lib/otel/otel-wrapper";
import { loggerContext } from "@/logger-context";
import { createLogger } from "@/lib/logger/logger";
import { createLogger } from "@/lib/logger/create-logger";

const logger = createLogger("createAppRegisterHandler");

Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/webhooks/transaction-cancel-requested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { getZodErrorMessage } from "@/lib/zod-error";
import { getTransactionActions } from "@/lib/transaction-actions";
import { AppUrlGenerator } from "@/modules/url/app-url-generator";
import { createLogger } from "@/lib/logger/logger";
import { createLogger } from "@/lib/logger/create-logger";
import { wrapWithLoggerContext } from "@/lib/logger/logger-context";
import { withOtel } from "@/lib/otel/otel-wrapper";
import { loggerContext } from "@/logger-context";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/webhooks/transaction-charge-requested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TransactionChargeRequestedDocument,
TransactionChargeRequestedEventFragment,
} from "@/generated/graphql";
import { createLogger } from "@/lib/logger/logger";
import { createLogger } from "@/lib/logger/create-logger";
import {
ChargeRequestedResponse,
chargeRequestedInputSchema,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/webhooks/transaction-initialize-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@/generated/graphql";
import { v7 as uuidv7 } from "uuid";
import { getTransactionActions } from "@/lib/transaction-actions";
import { createLogger } from "@/lib/logger/logger";
import { createLogger } from "@/lib/logger/create-logger";
import { getZodErrorMessage } from "@/lib/zod-error";
import { dataSchema, ResponseType } from "@/modules/validation/sync-transaction";
import { AppUrlGenerator } from "@/modules/url/app-url-generator";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/webhooks/transaction-process-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TransactionProcessSessionDocument,
TransactionProcessSessionEventFragment,
} from "@/generated/graphql";
import { createLogger } from "@/lib/logger/logger";
import { createLogger } from "@/lib/logger/create-logger";
import { dataSchema, ResponseType } from "@/modules/validation/sync-transaction";
import { getZodErrorMessage } from "@/lib/zod-error";
import { getTransactionActions } from "@/lib/transaction-actions";
Expand Down
6 changes: 3 additions & 3 deletions src/pages/api/webhooks/transaction-refund-requested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TransactionRefundRequestedDocument,
TransactionRefundRequestedEventFragment,
} from "@/generated/graphql";
import { createLogger } from "@/lib/logger/logger";
import { createLogger } from "@/lib/logger/create-logger";
import {
RefundRequestedResponse,
refundRequestedInputSchema,
Expand Down Expand Up @@ -62,9 +62,9 @@ export default wrapWithLoggerContext(
const urlGenerator = new AppUrlGenerator(ctx.authData);

const successResponse: RefundRequestedResponse = {
pspReference: uuidv7(),
// pspReference: uuidv7(),
// TODO: Add result customization
result: "REFUND_SUCCESS",
result: "REFUND_FAILURE",
message: "Great success!",
actions: transactionRefundChecker.checkIfAnotherRefundIsPossible(
amount,
Expand Down
2 changes: 1 addition & 1 deletion src/server/routers/transaction-reporter.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { v7 as uuidv7 } from "uuid";
import { getTransactionActions } from "@/lib/transaction-actions";
import { TRPCError } from "@trpc/server";
import { createLogger } from "@/lib/logger/logger";
import { createLogger } from "@/lib/logger/create-logger";
import { AppUrlGenerator } from "@/modules/url/app-url-generator";

export const transactionReporterRouter = router({
Expand Down
Loading