From 92ba282ee582cca0ebde3314406156e89a269ba5 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 12 Jan 2023 08:37:41 +0000 Subject: [PATCH] Logging type updates to fix account portal build (#9317) --- packages/backend-core/package.json | 1 + packages/backend-core/src/logging.ts | 6 ++++-- packages/backend-core/yarn.lock | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index be9ac5f504..7a986708a2 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -64,6 +64,7 @@ "@types/jest": "27.5.1", "@types/koa": "2.13.4", "@types/koa-pino-logger": "3.0.0", + "@types/pino-http": "5.8.1", "@types/lodash": "4.14.180", "@types/node": "14.18.20", "@types/node-fetch": "2.6.1", diff --git a/packages/backend-core/src/logging.ts b/packages/backend-core/src/logging.ts index 57295c6595..711c38917c 100644 --- a/packages/backend-core/src/logging.ts +++ b/packages/backend-core/src/logging.ts @@ -1,6 +1,8 @@ import { Header } from "./constants" import env from "./environment" const correlator = require("correlation-id") +import { Options } from "pino-http" +import { IncomingMessage } from "http" const NonErrors = ["AccountError"] @@ -33,14 +35,14 @@ export function logWarn(message: string) { console.warn(`bb-warn: ${message}`) } -export function pinoSettings() { +export function pinoSettings(): Options { return { prettyPrint: { levelFirst: true, }, level: env.LOG_LEVEL || "error", autoLogging: { - ignore: (req: { url: string }) => req.url.includes("/health"), + ignore: (req: IncomingMessage) => !!req.url?.includes("/health"), }, } } diff --git a/packages/backend-core/yarn.lock b/packages/backend-core/yarn.lock index 981f9026a3..d8dd7886f3 100644 --- a/packages/backend-core/yarn.lock +++ b/packages/backend-core/yarn.lock @@ -1239,7 +1239,7 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.20.tgz#268f028b36eaf51181c3300252f605488c4f0650" integrity sha512-Q8KKwm9YqEmUBRsqJ2GWJDtXltBDxTdC4m5vTdXBolu2PeQh8LX+f6BTwU+OuXPu37fLxoN6gidqBmnky36FXA== -"@types/pino-http@*": +"@types/pino-http@*", "@types/pino-http@5.8.1": version "5.8.1" resolved "https://registry.yarnpkg.com/@types/pino-http/-/pino-http-5.8.1.tgz#ebb194750ad2f9245c3028b5d2c4e6d64f685ba9" integrity sha512-A9MW6VCnx5ii7s+Fs5aFIw+aSZcBCpsZ/atpxamu8tTsvWFacxSf2Hrn1Ohn1jkVRB/LiPGOapRXcFawDBnDnA==