Skip to content

Commit 2646a02

Browse files
committed
PEER-234: Simplify request logging
Signed-off-by: SeeuSim <[email protected]>
1 parent 9a07b50 commit 2646a02

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

backend/collaboration/src/server.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,21 @@ import { setUpWSServer } from './ws';
1515

1616
const app = express();
1717

18-
app.use(pino());
18+
app.use(
19+
pino({
20+
serializers: {
21+
req: ({ id, method, url, headers: { host, referer }, query, params }) => ({
22+
id,
23+
method,
24+
url,
25+
headers: { host, referer },
26+
query,
27+
params,
28+
}),
29+
res: ({ statusCode }) => ({ statusCode }),
30+
},
31+
})
32+
);
1933
app.use(json());
2034
app.use(
2135
cors({

backend/matching/src/server.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,21 @@ import { UI_HOST } from './config';
1111
import { createWs } from './ws';
1212

1313
const app = express();
14-
app.use(pino());
14+
app.use(
15+
pino({
16+
serializers: {
17+
req: ({ id, method, url, headers: { host, referer }, query, params }) => ({
18+
id,
19+
method,
20+
url,
21+
headers: { host, referer },
22+
query,
23+
params,
24+
}),
25+
res: ({ statusCode }) => ({ statusCode }),
26+
},
27+
})
28+
);
1529
app.use(json());
1630
app.use(
1731
cors({

backend/question/src/server.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,21 @@ import { logger } from '@/lib/utils';
1313
import questionsRouter from '@/routes/question';
1414

1515
const app = express();
16-
app.use(pino());
16+
app.use(
17+
pino({
18+
serializers: {
19+
req: ({ id, method, url, headers: { host, referer }, query, params }) => ({
20+
id,
21+
method,
22+
url,
23+
headers: { host, referer },
24+
query,
25+
params,
26+
}),
27+
res: ({ statusCode }) => ({ statusCode }),
28+
},
29+
})
30+
);
1731
app.use(json());
1832
app.use(helmet());
1933
app.use(

backend/user/src/server.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ import authCheckRoutes from '@/routes/auth-check';
1616
import userRoutes from '@/routes/user';
1717

1818
const app = express();
19-
app.use(pino());
19+
app.use(
20+
pino({
21+
serializers: {
22+
req: ({ id, method, url, headers: { host, referer }, query, params }) => ({
23+
id,
24+
method,
25+
url,
26+
headers: { host, referer },
27+
query,
28+
params,
29+
}),
30+
res: ({ statusCode }) => ({ statusCode }),
31+
},
32+
})
33+
);
2034
app.use(json());
2135
app.use(helmet());
2236
app.use(cookieParser());

0 commit comments

Comments
 (0)