🧹 Pino transports API and capture console.log
All checks were successful
Deploy application / deploy (push) Successful in 26s

This commit is contained in:
Martin Berg Alstad 2025-02-06 19:37:11 +01:00
parent 71e70a2713
commit efa9e785f2
Signed by: martials
GPG Key ID: A3824877B269F2E2
3 changed files with 12 additions and 8 deletions

View File

@ -108,9 +108,7 @@ export class Sparebank1Impl implements Bank {
const result = await Api.refreshToken(refreshToken)
if (result.status === "failure") {
throw logger.error({
err: new Error(`Failed to fetch refresh token: '${result.data}'`),
})
throw new Error(`Failed to fetch refresh token: '${result.data}'`)
}
const oAuthToken = result.data

View File

@ -4,6 +4,14 @@ import { LOG_LEVEL } from "../config.ts"
/**
* / Returns a logging instance with the default log-level "info"
*/
export default pino({
level: LOG_LEVEL,
})
const logger = pino(
pino.destination({
level: LOG_LEVEL,
}),
)
console.log = function (...args): void {
logger.info(args, args?.[0])
}
export default logger

View File

@ -16,8 +16,6 @@ import { CronJob } from "cron"
import { createDirsIfMissing } from "@/fs.ts"
import dayjs from "dayjs"
// TODO Transports api for pino https://github.com/pinojs/pino/blob/HEAD/docs/transports.md
// TODO if possible, capture other log messages and move them into pino
// TODO move tsx to devDependency. Requires ts support for Node with support for @ alias
// TODO verbatimSyntax in tsconfig, conflicts with jest
// TODO multi module project. Main | DAL | Sparebank1 impl