Initial commit: USDT transfer worker (RabbitMQ + Postgres + Vault)
This commit is contained in:
20
src/logger.ts
Normal file
20
src/logger.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { pino, type Logger } from "pino";
|
||||
|
||||
const VALID_LEVELS = new Set(["trace", "debug", "info", "warn", "error", "fatal", "silent"]);
|
||||
|
||||
function resolveLevel(input: string | undefined): string {
|
||||
if (!input) {
|
||||
return "info";
|
||||
}
|
||||
|
||||
const normalized = input.toLowerCase();
|
||||
return VALID_LEVELS.has(normalized) ? normalized : "info";
|
||||
}
|
||||
|
||||
export function createLogger(level: string | undefined): Logger {
|
||||
return pino({
|
||||
level: resolveLevel(level),
|
||||
base: { service: "usdt-transfer" },
|
||||
timestamp: pino.stdTimeFunctions.isoTime
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user