Skip to content

Commit c944b7b

Browse files
committed
Audit log to console when running in dev and disabled via env var
1 parent 598e35b commit c944b7b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/api/functions/auditLog.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export async function createAuditLogEntry({
3131
dynamoClient,
3232
entry,
3333
}: AuditLogParams) {
34+
if (process.env.DISABLE_AUDIT_LOG && process.env.RunEnvironment === "dev") {
35+
console.log(`Audit log entry: ${JSON.stringify(entry)}`);
36+
return;
37+
}
3438
const safeDynamoClient =
3539
dynamoClient ||
3640
new DynamoDBClient({
@@ -52,8 +56,11 @@ export function buildAuditLogTransactPut({
5256
}: {
5357
entry: AuditLogEntry;
5458
}): TransactWriteItem {
59+
if (process.env.DISABLE_AUDIT_LOG && process.env.RunEnvironment === "dev") {
60+
console.log(`Audit log entry: ${JSON.stringify(entry)}`);
61+
return {};
62+
}
5563
const item = buildMarshalledAuditLogItem(entry);
56-
5764
return {
5865
Put: {
5966
TableName: genericConfig.AuditLogTable,

src/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "module",
99
"scripts": {
1010
"build": "tsc && node build.js",
11-
"dev": "cross-env LOG_LEVEL=debug concurrently --names 'esbuild,server' 'node esbuild.config.js --watch' 'cd ../../dist_devel && nodemon index.js'",
11+
"dev": "cross-env DISABLE_AUDIT_LOG=true cross-env LOG_LEVEL=debug concurrently --names 'esbuild,server' 'node esbuild.config.js --watch' 'cd ../../dist_devel && nodemon index.js'",
1212
"typecheck": "tsc --noEmit",
1313
"lint": "eslint . --ext .ts --cache",
1414
"prettier": "prettier --check *.ts **/*.ts",

0 commit comments

Comments
 (0)