-
Notifications
You must be signed in to change notification settings - Fork 13
/
next-logger.config.cjs
42 lines (38 loc) · 1.15 KB
/
next-logger.config.cjs
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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pino = require('pino'); // It's ok that pino is transit dependency, it's required by next-logger
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { satanizer, commonPatterns } = require('@lidofinance/satanizer');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const loadEnvConfig = require('@next/env').loadEnvConfig;
// Must load env first
const projectDir = process.cwd();
loadEnvConfig(projectDir);
const patterns = [
...commonPatterns,
process.env.INFURA_API_KEY,
process.env.ALCHEMY_API_KEY,
process.env.ETHPLORER_API_KEY,
// TODO: Delete this ENV
process.env.CLOUDFLARE_API_TOKEN,
process.env.CLOUDFLARE_ACCOUNT_ID,
process.env.CLOUDFLARE_KV_NAMESPACE_ID,
];
const mask = satanizer(patterns);
const logger = (defaultConfig) =>
pino({
...defaultConfig,
formatters: {
...defaultConfig.formatters,
level(label, _number) {
return { level: label };
},
},
hooks: {
logMethod(inputArgs, method) {
return method.apply(this, mask(inputArgs));
},
},
});
module.exports = {
logger,
};