Skip to content

Commit e0dd7a8

Browse files
committed
feat: added pretty print for pino logger
1 parent 6274cd0 commit e0dd7a8

4 files changed

Lines changed: 1862 additions & 5010 deletions

File tree

backend/src/routes/health.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from 'express';
22
import { appDataSouce } from '../data-source';
33
const Healthrouter = express.Router();
4-
Healthrouter.get('/health', async (req, res) => {
4+
Healthrouter.get('/', async (req, res) => {
55
try {
66
if (!appDataSouce.isInitialized) {
77
return res.status(503).json({

backend/src/utils/logger.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
import pino from 'pino';
2+
3+
const isDev = process.env.NODE_ENV !== 'production';
4+
25
export const logger = pino({
3-
level: process.env.NODE_ENV === 'production' ? 'info' : 'debug',
6+
level: process.env.LOG_LEVEL || 'info',
7+
transport: isDev
8+
? {
9+
target: 'pino-pretty',
10+
options: {
11+
colorize: true,
12+
translateTime: 'SYS:standard',
13+
ignore: 'pid,hostname',
14+
},
15+
}
16+
: undefined,
417
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@commitlint/cli": "^20.2.0",
1111
"@commitlint/config-conventional": "^20.2.0",
1212
"husky": "^9.1.7",
13+
"pino-pretty": "^13.1.3",
1314
"prettier": "^3.7.4"
1415
}
1516
}

0 commit comments

Comments
 (0)