forked from Deen-Bridge/dnb-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
46 lines (41 loc) · 940 Bytes
/
Copy pathlogger.js
File metadata and controls
46 lines (41 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pino from "pino";
const isDev = process.env.NODE_ENV === "development";
const logLevel = process.env.LOG_LEVEL || (isDev ? "debug" : "info");
const transport = isDev
? {
target: "pino-pretty",
options: {
colorize: true,
translateTime: "SYS:yyyy-MM-dd HH:mm:ss.l",
ignore: "pid,hostname",
},
}
: undefined;
const logger = pino({
level: logLevel,
transport,
redact: {
paths: [
"req.headers.authorization",
"req.headers.cookie",
"password",
"newPassword",
"otp",
"token",
"signedXdr",
"JWT_SECRET",
],
censor: "[REDACTED]",
},
serializers: {
err: pino.stdSerializers.err,
req: pino.stdSerializers.req,
res: pino.stdSerializers.res,
},
base: undefined,
timestamp: pino.stdTimeFunctions.isoTime,
});
logger.stream = {
write: (message) => logger.info(message.trim()),
};
export default logger;