Skip to content

Commit

Permalink
[MS-780] feat: Configurable logger redact (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrgrundas authored Oct 24, 2024
1 parent bd5f163 commit 0abf715
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/emails-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export const handler = Sentry.wrapHandler(
logger,
});

logger.debug("Sending email.", { data, fromEmail, from, toEmail });

const html = await sender.render({
props: { data },
template,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/plugins/winstonLoggingPlugin/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";

import { envBool } from "@/lib/zod/env";
import { prepareConfig } from "@/lib/zod/util";

import { LOG_LEVELS } from "./const";
Expand All @@ -11,6 +12,7 @@ export const configSchema = z.object({
.default("error"),
NODE_ENV: z.string(),
IS_DEVELOPMENT: z.boolean(),
REDACT_LOG_KEYS: envBool.default("true"),
});

export const PLUGIN_CONFIG = prepareConfig({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/winstonLoggingPlugin/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const createLogger = ({
info.level = `[${info.level.toUpperCase()}]`;
return info;
})(),
format(redact)(),
format((info) => (PLUGIN_CONFIG.REDACT_LOG_KEYS ? redact(info) : info))(),
format.errors({ stack: true }),
format.timestamp({ format: "DD/MM/YYYY HH:mm:ss" }),
...formatters
Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function createServer() {
* Apis registration
*/
await server.register(restRoutes, {
prefix: `${CONFIG.BASE_PATH}/api`,
prefix: CONFIG.BASE_PATH ? `${CONFIG.BASE_PATH}/api` : "/api",
});

server.log.info("Registering plugins", { registrations });
Expand Down

0 comments on commit 0abf715

Please sign in to comment.