From 976b3a55ca38b76b8fa88d9779adb6267b2ddf9b Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 4 Apr 2023 15:08:46 +0100 Subject: [PATCH] Update logging to support dd trace attributes (#10086) * Update logging middleware to integrate with pino for console logging * Remove elastic apm references, use updated core middlewares * Remove redundant LOG_LEVEL definitions * Remove no longer needed jest logging overrides * lint * Backwards compat between console log helpers and pino * Configurable DISABLE_HTTP_LOGGING * Don't log 4xx as errors * Remove redundant ENABLE_4XX_HTTP_LOGGING * Cleanup migrations and event logging * Improve bb-alert logging * Add DISABLE_HTTP_LOGGING to helm chart * Add ops endpoints for testing * Disable http logging in dev * Backwards compatible tracing implementation * Naming update on http logging env var * lint * Update packages/backend-core/src/environment.ts Co-authored-by: Adria Navarro * Merge * Lint * Fix console.warn failing mock by replacing with alerts mock instead * Lint --------- Co-authored-by: Adria Navarro --- .../templates/app-service-deployment.yaml | 16 +- .../templates/worker-service-deployment.yaml | 16 +- charts/budibase/values.yaml | 7 +- packages/backend-core/package.json | 4 +- .../src/cache/tests/writethrough.spec.ts | 5 +- packages/backend-core/src/environment.ts | 13 +- .../src/events/processors/LoggingProcessor.ts | 25 +-- packages/backend-core/src/logging.ts | 60 ------ packages/backend-core/src/logging/alerts.ts | 26 +++ .../src/logging/correlation/correlation.ts | 13 ++ .../src/logging/correlation/index.ts | 1 + .../src/logging/correlation/middleware.ts | 17 ++ packages/backend-core/src/logging/index.ts | 3 + .../backend-core/src/logging/pino/logger.ts | 161 +++++++++++++++ .../src/logging/pino/middleware.ts | 45 ++++ .../src/middleware/errorHandling.ts | 8 +- packages/backend-core/src/middleware/index.ts | 3 +- .../backend-core/src/middleware/logging.ts | 90 -------- .../backend-core/src/migrations/migrations.ts | 12 +- packages/backend-core/tests/jestEnv.ts | 1 - packages/backend-core/tests/jestSetup.ts | 1 - packages/backend-core/tests/logging.ts | 34 --- .../tests/utilities/mocks/alerts.ts | 3 + .../tests/utilities/mocks/index.ts | 1 + packages/backend-core/yarn.lock | 193 ++++++++++-------- packages/server/package.json | 2 - packages/server/scripts/dev/manage.js | 1 + packages/server/src/api/controllers/ops.ts | 32 +++ packages/server/src/api/routes/index.ts | 2 + packages/server/src/api/routes/ops.ts | 30 +++ packages/server/src/app.ts | 15 +- packages/server/src/elasticApm.ts | 10 - packages/server/src/environment.ts | 1 - .../functions/usageQuotas/syncApps.ts | 2 +- .../functions/usageQuotas/syncRows.ts | 5 +- packages/server/src/startup.ts | 3 - packages/server/src/tests/jestEnv.ts | 1 - packages/server/src/tests/jestSetup.ts | 1 - packages/server/src/tests/logging.ts | 34 --- packages/server/yarn.lock | 105 +--------- packages/worker/package.json | 2 - packages/worker/scripts/dev/manage.js | 1 + packages/worker/src/elasticApm.ts | 10 - packages/worker/src/environment.ts | 1 - packages/worker/src/index.ts | 9 +- packages/worker/src/tests/jestEnv.ts | 1 - packages/worker/src/tests/jestSetup.ts | 2 - packages/worker/src/tests/logging.ts | 34 --- packages/worker/yarn.lock | 108 +--------- 49 files changed, 496 insertions(+), 674 deletions(-) delete mode 100644 packages/backend-core/src/logging.ts create mode 100644 packages/backend-core/src/logging/alerts.ts create mode 100644 packages/backend-core/src/logging/correlation/correlation.ts create mode 100644 packages/backend-core/src/logging/correlation/index.ts create mode 100644 packages/backend-core/src/logging/correlation/middleware.ts create mode 100644 packages/backend-core/src/logging/index.ts create mode 100644 packages/backend-core/src/logging/pino/logger.ts create mode 100644 packages/backend-core/src/logging/pino/middleware.ts delete mode 100644 packages/backend-core/src/middleware/logging.ts delete mode 100644 packages/backend-core/tests/logging.ts create mode 100644 packages/backend-core/tests/utilities/mocks/alerts.ts create mode 100644 packages/server/src/api/controllers/ops.ts create mode 100644 packages/server/src/api/routes/ops.ts delete mode 100644 packages/server/src/elasticApm.ts delete mode 100644 packages/server/src/tests/logging.ts delete mode 100644 packages/worker/src/elasticApm.ts delete mode 100644 packages/worker/src/tests/logging.ts diff --git a/charts/budibase/templates/app-service-deployment.yaml b/charts/budibase/templates/app-service-deployment.yaml index df4070806f..4d73b75ae7 100644 --- a/charts/budibase/templates/app-service-deployment.yaml +++ b/charts/budibase/templates/app-service-deployment.yaml @@ -64,6 +64,8 @@ spec: value: {{ .Values.globals.enableAnalytics | quote }} - name: API_ENCRYPTION_KEY value: {{ .Values.globals.apiEncryptionKey | quote }} + - name: HTTP_LOGGING + value: {{ .Values.services.apps.httpLogging }} - name: INTERNAL_API_KEY valueFrom: secretKeyRef: @@ -119,7 +121,7 @@ spec: - name: MULTI_TENANCY value: {{ .Values.globals.multiTenancy | quote }} - name: LOG_LEVEL - value: {{ default "info" .Values.services.apps.logLevel | quote }} + value: {{ .Values.services.apps.logLevel | quote }} - name: REDIS_PASSWORD value: {{ .Values.services.redis.password }} - name: REDIS_URL @@ -180,18 +182,6 @@ spec: - name: DD_APM_DD_URL value: https://trace.agent.datadoghq.eu {{ end }} - {{ if .Values.globals.elasticApmEnabled }} - - name: ELASTIC_APM_ENABLED - value: {{ .Values.globals.elasticApmEnabled | quote }} - {{ end }} - {{ if .Values.globals.elasticApmSecretToken }} - - name: ELASTIC_APM_SECRET_TOKEN - value: {{ .Values.globals.elasticApmSecretToken | quote }} - {{ end }} - {{ if .Values.globals.elasticApmServerUrl }} - - name: ELASTIC_APM_SERVER_URL - value: {{ .Values.globals.elasticApmServerUrl | quote }} - {{ end }} {{ if .Values.globals.globalAgentHttpProxy }} - name: GLOBAL_AGENT_HTTP_PROXY value: {{ .Values.globals.globalAgentHttpProxy | quote }} diff --git a/charts/budibase/templates/worker-service-deployment.yaml b/charts/budibase/templates/worker-service-deployment.yaml index f48d19689b..d12be421dc 100644 --- a/charts/budibase/templates/worker-service-deployment.yaml +++ b/charts/budibase/templates/worker-service-deployment.yaml @@ -64,6 +64,8 @@ spec: {{ end }} - name: API_ENCRYPTION_KEY value: {{ .Values.globals.apiEncryptionKey | quote }} + - name: HTTP_LOGGING + value: {{ .Values.services.worker.httpLogging }} - name: INTERNAL_API_KEY valueFrom: secretKeyRef: @@ -115,7 +117,7 @@ spec: - name: MULTI_TENANCY value: {{ .Values.globals.multiTenancy | quote }} - name: LOG_LEVEL - value: {{ default "info" .Values.services.worker.logLevel | quote }} + value: {{ .Values.services.worker.logLevel | quote }} - name: REDIS_PASSWORD value: {{ .Values.services.redis.password | quote }} - name: REDIS_URL @@ -170,18 +172,6 @@ spec: - name: DD_APM_DD_URL value: https://trace.agent.datadoghq.eu {{ end }} - {{ if .Values.globals.elasticApmEnabled }} - - name: ELASTIC_APM_ENABLED - value: {{ .Values.globals.elasticApmEnabled | quote }} - {{ end }} - {{ if .Values.globals.elasticApmSecretToken }} - - name: ELASTIC_APM_SECRET_TOKEN - value: {{ .Values.globals.elasticApmSecretToken | quote }} - {{ end }} - {{ if .Values.globals.elasticApmServerUrl }} - - name: ELASTIC_APM_SERVER_URL - value: {{ .Values.globals.elasticApmServerUrl | quote }} - {{ end }} {{ if .Values.globals.globalAgentHttpProxy }} - name: GLOBAL_AGENT_HTTP_PROXY value: {{ .Values.globals.globalAgentHttpProxy | quote }} diff --git a/charts/budibase/values.yaml b/charts/budibase/values.yaml index ccbbf9878e..dbf6b6b46e 100644 --- a/charts/budibase/values.yaml +++ b/charts/budibase/values.yaml @@ -80,7 +80,6 @@ globals: enableAnalytics: "1" sentryDSN: "" posthogToken: "phc_bIjZL7oh2GEUd2vqvTBH8WvrX0fWTFQMs6H5KQxiUxU" - logLevel: info selfHosted: "1" # set to 0 for budibase cloud environment, set to 1 for self-hosted setup multiTenancy: "0" # set to 0 to disable multiple orgs, set to 1 to enable multiple orgs accountPortalUrl: "" @@ -107,9 +106,6 @@ globals: smtp: enabled: false -# elasticApmEnabled: -# elasticApmSecretToken: -# elasticApmServerUrl: # globalAgentHttpProxy: # globalAgentHttpsProxy: # globalAgentNoProxy: @@ -137,6 +133,7 @@ services: port: 4002 replicaCount: 1 logLevel: info + httpLogging: 1 resources: {} # nodeDebug: "" # set the value of NODE_DEBUG # annotations: @@ -147,6 +144,8 @@ services: worker: port: 4003 replicaCount: 1 + logLevel: info + httpLogging: 1 resources: {} # annotations: # co.elastic.logs/multiline.type: pattern diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 951af6b063..47657eac46 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -39,6 +39,7 @@ "joi": "17.6.0", "jsonwebtoken": "9.0.0", "koa-passport": "4.1.4", + "koa-pino-logger": "4.0.0", "lodash": "4.17.21", "lodash.isarguments": "3.1.0", "node-fetch": "2.6.7", @@ -64,11 +65,9 @@ "@types/ioredis": "4.28.0", "@types/jest": "28.1.1", "@types/koa": "2.13.4", - "@types/koa-pino-logger": "3.0.0", "@types/lodash": "4.14.180", "@types/node": "14.18.20", "@types/node-fetch": "2.6.1", - "@types/pino-http": "5.8.1", "@types/pouchdb": "6.4.0", "@types/redlock": "4.0.3", "@types/semver": "7.3.7", @@ -81,6 +80,7 @@ "koa": "2.13.4", "nodemon": "2.0.16", "pouchdb-adapter-memory": "7.2.2", + "pino-pretty": "10.0.0", "timekeeper": "2.2.0", "ts-jest": "28.0.4", "ts-node": "10.8.1", diff --git a/packages/backend-core/src/cache/tests/writethrough.spec.ts b/packages/backend-core/src/cache/tests/writethrough.spec.ts index a34f05e881..363344c84d 100644 --- a/packages/backend-core/src/cache/tests/writethrough.spec.ts +++ b/packages/backend-core/src/cache/tests/writethrough.spec.ts @@ -2,6 +2,7 @@ import { structures, DBTestConfiguration, expectFunctionWasCalledTimesWith, + mocks, } from "../../../tests" import { Writethrough } from "../writethrough" import { getDB } from "../../db" @@ -77,9 +78,9 @@ describe("writethrough", () => { expect.arrayContaining([current._rev, current._rev, newRev]) ) expectFunctionWasCalledTimesWith( - console.warn, + mocks.alerts.logWarn, 2, - "bb-warn: Ignoring redlock conflict in write-through cache" + "Ignoring redlock conflict in write-through cache" ) const output = await db.get(current._id) diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index 5718494fc4..68f056c80c 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -36,6 +36,15 @@ function getAPIEncryptionKey() { : process.env.JWT_SECRET // fallback to the JWT_SECRET used historically } +function httpLogging() { + if (process.env.HTTP_LOGGING === undefined) { + // on by default unless otherwise specified + return true + } + + return process.env.HTTP_LOGGING +} + const environment = { isTest, isJest, @@ -90,11 +99,11 @@ const environment = { USE_COUCH: process.env.USE_COUCH || true, DEFAULT_LICENSE: process.env.DEFAULT_LICENSE, SERVICE: process.env.SERVICE || "budibase", - LOG_LEVEL: process.env.LOG_LEVEL, + LOG_LEVEL: process.env.LOG_LEVEL || "info", SESSION_UPDATE_PERIOD: process.env.SESSION_UPDATE_PERIOD, DEPLOYMENT_ENVIRONMENT: process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose", - ENABLE_4XX_HTTP_LOGGING: process.env.ENABLE_4XX_HTTP_LOGGING || true, + HTTP_LOGGING: httpLogging(), ENABLE_AUDIT_LOG_IP_ADDR: process.env.ENABLE_AUDIT_LOG_IP_ADDR, // smtp SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED, diff --git a/packages/backend-core/src/events/processors/LoggingProcessor.ts b/packages/backend-core/src/events/processors/LoggingProcessor.ts index 6bb691a83a..0f4d02b99c 100644 --- a/packages/backend-core/src/events/processors/LoggingProcessor.ts +++ b/packages/backend-core/src/events/processors/LoggingProcessor.ts @@ -2,14 +2,6 @@ import { Event, Identity, Group } from "@budibase/types" import { EventProcessor } from "./types" import env from "../../environment" -const getTimestampString = (timestamp?: string | number) => { - let timestampString = "" - if (timestamp) { - timestampString = `[timestamp=${new Date(timestamp).toISOString()}]` - } - return timestampString -} - const skipLogging = env.SELF_HOSTED && !env.isDev() export default class LoggingProcessor implements EventProcessor { @@ -22,32 +14,21 @@ export default class LoggingProcessor implements EventProcessor { if (skipLogging) { return } - let timestampString = getTimestampString(timestamp) - let message = `[audit] [identityType=${identity.type}] ${timestampString} ${event} ` - if (env.isDev()) { - message = message + `[debug: [properties=${JSON.stringify(properties)}] ]` - } - console.log(message) + console.log(`[audit] [identityType=${identity.type}] ${event}`, properties) } async identify(identity: Identity, timestamp?: string | number) { if (skipLogging) { return } - let timestampString = getTimestampString(timestamp) - console.log( - `[audit] [${JSON.stringify(identity)}] ${timestampString} identified` - ) + console.log(`[audit] identified`, identity) } async identifyGroup(group: Group, timestamp?: string | number) { if (skipLogging) { return } - let timestampString = getTimestampString(timestamp) - console.log( - `[audit] [${JSON.stringify(group)}] ${timestampString} group identified` - ) + console.log(`[audit] group identified`, group) } shutdown(): void { diff --git a/packages/backend-core/src/logging.ts b/packages/backend-core/src/logging.ts deleted file mode 100644 index 8f2ae6e619..0000000000 --- a/packages/backend-core/src/logging.ts +++ /dev/null @@ -1,60 +0,0 @@ -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"] - -function isSuppressed(e?: any) { - return e && e["suppressAlert"] -} - -export function logAlert(message: string, e?: any) { - if (e && NonErrors.includes(e.name) && isSuppressed(e)) { - return - } - let errorJson = "" - if (e) { - errorJson = ": " + JSON.stringify(e, Object.getOwnPropertyNames(e)) - } - console.error(`bb-alert: ${message} ${errorJson}`) -} - -export function logAlertWithInfo( - message: string, - db: string, - id: string, - error: any -) { - message = `${message} - db: ${db} - doc: ${id} - error: ` - logAlert(message, error) -} - -export function logWarn(message: string) { - console.warn(`bb-warn: ${message}`) -} - -export function pinoSettings(): Options { - return { - prettyPrint: { - levelFirst: true, - }, - genReqId: correlator.getId, - level: env.LOG_LEVEL || "error", - autoLogging: { - ignore: (req: IncomingMessage) => !!req.url?.includes("/health"), - }, - } -} - -const setCorrelationHeader = (headers: any) => { - const correlationId = correlator.getId() - if (correlationId) { - headers[Header.CORRELATION_ID] = correlationId - } -} - -export const correlation = { - setHeader: setCorrelationHeader, -} diff --git a/packages/backend-core/src/logging/alerts.ts b/packages/backend-core/src/logging/alerts.ts new file mode 100644 index 0000000000..625ecfcf15 --- /dev/null +++ b/packages/backend-core/src/logging/alerts.ts @@ -0,0 +1,26 @@ +const NonErrors = ["AccountError"] + +function isSuppressed(e?: any) { + return e && e["suppressAlert"] +} + +export function logAlert(message: string, e?: any) { + if (e && NonErrors.includes(e.name) && isSuppressed(e)) { + return + } + console.error(`bb-alert: ${message}`, e) +} + +export function logAlertWithInfo( + message: string, + db: string, + id: string, + error: any +) { + message = `${message} - db: ${db} - doc: ${id} - error: ` + logAlert(message, error) +} + +export function logWarn(message: string) { + console.warn(`bb-warn: ${message}`) +} diff --git a/packages/backend-core/src/logging/correlation/correlation.ts b/packages/backend-core/src/logging/correlation/correlation.ts new file mode 100644 index 0000000000..b5b47df9c6 --- /dev/null +++ b/packages/backend-core/src/logging/correlation/correlation.ts @@ -0,0 +1,13 @@ +import { Header } from "../../constants" +const correlator = require("correlation-id") + +export const setHeader = (headers: any) => { + const correlationId = correlator.getId() + if (correlationId) { + headers[Header.CORRELATION_ID] = correlationId + } +} + +export function getId() { + return correlator.getId() +} diff --git a/packages/backend-core/src/logging/correlation/index.ts b/packages/backend-core/src/logging/correlation/index.ts new file mode 100644 index 0000000000..a6d8b920fb --- /dev/null +++ b/packages/backend-core/src/logging/correlation/index.ts @@ -0,0 +1 @@ +export * from "./correlation" diff --git a/packages/backend-core/src/logging/correlation/middleware.ts b/packages/backend-core/src/logging/correlation/middleware.ts new file mode 100644 index 0000000000..f77714a5ae --- /dev/null +++ b/packages/backend-core/src/logging/correlation/middleware.ts @@ -0,0 +1,17 @@ +import { Header } from "../../constants" +import { v4 as uuid } from "uuid" +const correlator = require("correlation-id") + +const correlation = (ctx: any, next: any) => { + // use the provided correlation id header if present + let correlationId = ctx.headers[Header.CORRELATION_ID] + if (!correlationId) { + correlationId = uuid() + } + + return correlator.withId(correlationId, () => { + return next() + }) +} + +export default correlation diff --git a/packages/backend-core/src/logging/index.ts b/packages/backend-core/src/logging/index.ts new file mode 100644 index 0000000000..137a943deb --- /dev/null +++ b/packages/backend-core/src/logging/index.ts @@ -0,0 +1,3 @@ +export * as correlation from "./correlation/correlation" +export { default as logger } from "./pino/logger" +export * from "./alerts" diff --git a/packages/backend-core/src/logging/pino/logger.ts b/packages/backend-core/src/logging/pino/logger.ts new file mode 100644 index 0000000000..0b73a00f4d --- /dev/null +++ b/packages/backend-core/src/logging/pino/logger.ts @@ -0,0 +1,161 @@ +import env from "../../environment" +import pino, { LoggerOptions } from "pino" +import * as context from "../../context" +import * as correlation from "../correlation" +import { IdentityType } from "@budibase/types" + +// LOGGER + +const pinoOptions: LoggerOptions = { + level: env.LOG_LEVEL, + formatters: { + level: label => { + return { level: label.toUpperCase() } + }, + bindings: () => { + return {} + }, + }, + timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`, +} + +if (env.isDev()) { + pinoOptions.transport = { + target: "pino-pretty", + options: { + singleLine: true, + }, + } +} + +export const logger = pino(pinoOptions) + +// CONSOLE OVERRIDES + +interface MergingObject { + objects?: any[] + tenantId?: string + appId?: string + identityId?: string + identityType?: IdentityType + correlationId?: string + err?: Error +} + +function isPlainObject(obj: any) { + return typeof obj === "object" && obj !== null && !(obj instanceof Error) +} + +function isError(obj: any) { + return obj instanceof Error +} + +function isMessage(obj: any) { + return typeof obj === "string" +} + +/** + * Backwards compatibility between console logging statements + * and pino logging requirements. + */ +function getLogParams(args: any[]): [MergingObject, string] { + let error = undefined + let objects: any[] = [] + let message = "" + + args.forEach(arg => { + if (isMessage(arg)) { + message = `${message} ${arg}`.trimStart() + } + if (isPlainObject(arg)) { + objects.push(arg) + } + if (isError(arg)) { + error = arg + } + }) + + const identity = getIdentity() + + const mergingObject = { + objects: objects.length ? objects : undefined, + tenantId: getTenantId(), + appId: getAppId(), + identityId: identity?._id, + identityType: identity?.type, + correlationId: correlation.getId(), + err: error, + } + + return [mergingObject, message] +} + +console.log = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + logger.info(obj, msg) +} +console.info = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + logger.info(obj, msg) +} +console.warn = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + logger.warn(obj, msg) +} +console.error = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + logger.error(obj, msg) +} + +/** + * custom trace impl - this resembles the node trace behaviour rather + * than traditional trace logging + * @param arg + */ +console.trace = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + if (!obj.err) { + // to get stack trace + obj.err = new Error() + } + logger.trace(obj, msg) +} + +console.debug = (...arg: any) => { + const [obj, msg] = getLogParams(arg) + logger.debug(obj, msg) +} + +// CONTEXT + +const getTenantId = () => { + let tenantId + try { + tenantId = context.getTenantId() + } catch (e: any) { + // do nothing + } + return tenantId +} + +const getAppId = () => { + let appId + try { + appId = context.getAppId() + } catch (e) { + // do nothing + } + return appId +} + +const getIdentity = () => { + let identity + try { + identity = context.getIdentity() + } catch (e) { + // do nothing + } + return identity +} + +export default logger diff --git a/packages/backend-core/src/logging/pino/middleware.ts b/packages/backend-core/src/logging/pino/middleware.ts new file mode 100644 index 0000000000..e9d37ab692 --- /dev/null +++ b/packages/backend-core/src/logging/pino/middleware.ts @@ -0,0 +1,45 @@ +import env from "../../environment" +import logger from "./logger" +import { IncomingMessage } from "http" +const pino = require("koa-pino-logger") +import { Options } from "pino-http" +import { Ctx } from "@budibase/types" +const correlator = require("correlation-id") + +export function pinoSettings(): Options { + return { + logger, + genReqId: correlator.getId, + autoLogging: { + ignore: (req: IncomingMessage) => !!req.url?.includes("/health"), + }, + serializers: { + req: req => { + return { + method: req.method, + url: req.url, + correlationId: req.id, + } + }, + res: res => { + return { + status: res.statusCode, + } + }, + }, + } +} + +function getMiddleware() { + if (env.HTTP_LOGGING) { + return pino(pinoSettings()) + } else { + return (ctx: Ctx, next: any) => { + return next() + } + } +} + +const pinoMiddleware = getMiddleware() + +export default pinoMiddleware diff --git a/packages/backend-core/src/middleware/errorHandling.ts b/packages/backend-core/src/middleware/errorHandling.ts index 36aff2cdbc..ebdd4107e9 100644 --- a/packages/backend-core/src/middleware/errorHandling.ts +++ b/packages/backend-core/src/middleware/errorHandling.ts @@ -1,6 +1,5 @@ import { APIError } from "@budibase/types" import * as errors from "../errors" -import env from "../environment" export async function errorHandling(ctx: any, next: any) { try { @@ -9,9 +8,10 @@ export async function errorHandling(ctx: any, next: any) { const status = err.status || err.statusCode || 500 ctx.status = status - if (status > 499 || env.ENABLE_4XX_HTTP_LOGGING) { - ctx.log.error(err) - console.trace(err) + if (status >= 400 && status < 500) { + console.warn(err) + } else { + console.error(err) } const error = errors.getPublicError(err) diff --git a/packages/backend-core/src/middleware/index.ts b/packages/backend-core/src/middleware/index.ts index dce07168d4..980bf06b00 100644 --- a/packages/backend-core/src/middleware/index.ts +++ b/packages/backend-core/src/middleware/index.ts @@ -14,7 +14,8 @@ export { default as csrf } from "./csrf" export { default as adminOnly } from "./adminOnly" export { default as builderOrAdmin } from "./builderOrAdmin" export { default as builderOnly } from "./builderOnly" -export { default as logging } from "./logging" +export { default as pino } from "../logging/pino/middleware" +export { default as correlation } from "../logging/correlation/middleware" export { default as errorHandling } from "./errorHandling" export { default as querystringToBody } from "./querystringToBody" export * as joiValidator from "./joi-validator" diff --git a/packages/backend-core/src/middleware/logging.ts b/packages/backend-core/src/middleware/logging.ts deleted file mode 100644 index db9b64b883..0000000000 --- a/packages/backend-core/src/middleware/logging.ts +++ /dev/null @@ -1,90 +0,0 @@ -const correlator = require("correlation-id") -import { Header } from "../constants" -import { v4 as uuid } from "uuid" -import * as context from "../context" - -const debug = console.warn -const trace = console.trace -const log = console.log -const info = console.info -const warn = console.warn -const error = console.error - -const getTenantId = () => { - let tenantId - try { - tenantId = context.getTenantId() - } catch (e: any) { - // do nothing - } - return tenantId -} - -const getAppId = () => { - let appId - try { - appId = context.getAppId() - } catch (e) { - // do nothing - } - return appId -} - -const getIdentityId = () => { - let identityId - try { - const identity = context.getIdentity() - identityId = identity?._id - } catch (e) { - // do nothing - } - return identityId -} - -const print = (fn: any, data: any[]) => { - let message = "" - - const correlationId = correlator.getId() - if (correlationId) { - message = message + `[correlationId=${correlator.getId()}]` - } - - const tenantId = getTenantId() - if (tenantId) { - message = message + ` [tenantId=${tenantId}]` - } - - const appId = getAppId() - if (appId) { - message = message + ` [appId=${appId}]` - } - - const identityId = getIdentityId() - if (identityId) { - message = message + ` [identityId=${identityId}]` - } - - if (!process.env.CI) { - fn(message, data) - } -} - -const logging = (ctx: any, next: any) => { - // use the provided correlation id header if present - let correlationId = ctx.headers[Header.CORRELATION_ID] - if (!correlationId) { - correlationId = uuid() - } - - return correlator.withId(correlationId, () => { - console.debug = data => print(debug, data) - console.trace = data => print(trace, data) - console.log = data => print(log, data) - console.info = data => print(info, data) - console.warn = data => print(warn, data) - console.error = data => print(error, data) - return next() - }) -} - -export default logging diff --git a/packages/backend-core/src/migrations/migrations.ts b/packages/backend-core/src/migrations/migrations.ts index ab72091d56..c750bc4882 100644 --- a/packages/backend-core/src/migrations/migrations.ts +++ b/packages/backend-core/src/migrations/migrations.ts @@ -99,9 +99,7 @@ export const runMigration = async ( options.force[migrationType] && options.force[migrationType].includes(migrationName) ) { - log( - `[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Forcing` - ) + log(`[Migration: ${migrationName}] [DB: ${dbName}] Forcing`) } else { // no force, exit return @@ -111,7 +109,7 @@ export const runMigration = async ( // check if the migration is not a no-op if (!options.noOp) { log( - `[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}` + `[Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}` ) if (migration.preventRetry) { @@ -131,9 +129,7 @@ export const runMigration = async ( await migration.fn(db) } - log( - `[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Complete` - ) + log(`[Migration: ${migrationName}] [DB: ${dbName}] Complete`) } // mark as complete @@ -141,7 +137,7 @@ export const runMigration = async ( await db.put(doc) } catch (err) { console.error( - `[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Error: `, + `[Migration: ${migrationName}] [DB: ${dbName}] Error: `, err ) throw err diff --git a/packages/backend-core/tests/jestEnv.ts b/packages/backend-core/tests/jestEnv.ts index 3555973928..c2047118ec 100644 --- a/packages/backend-core/tests/jestEnv.ts +++ b/packages/backend-core/tests/jestEnv.ts @@ -3,5 +3,4 @@ process.env.MULTI_TENANCY = "1" process.env.NODE_ENV = "jest" process.env.MOCK_REDIS = "1" process.env.LOG_LEVEL = process.env.LOG_LEVEL || "error" -process.env.ENABLE_4XX_HTTP_LOGGING = "0" process.env.REDIS_PASSWORD = "budibase" diff --git a/packages/backend-core/tests/jestSetup.ts b/packages/backend-core/tests/jestSetup.ts index be81fbff75..f5542e8fdd 100644 --- a/packages/backend-core/tests/jestSetup.ts +++ b/packages/backend-core/tests/jestSetup.ts @@ -1,4 +1,3 @@ -import "./logging" import env from "../src/environment" import { cleanup } from "../src/timers" import { mocks, testContainerUtils } from "./utilities" diff --git a/packages/backend-core/tests/logging.ts b/packages/backend-core/tests/logging.ts deleted file mode 100644 index 271f4d62ff..0000000000 --- a/packages/backend-core/tests/logging.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum LogLevel { - TRACE = "trace", - DEBUG = "debug", - INFO = "info", - WARN = "warn", - ERROR = "error", -} - -const LOG_INDEX: { [key in LogLevel]: number } = { - [LogLevel.TRACE]: 1, - [LogLevel.DEBUG]: 2, - [LogLevel.INFO]: 3, - [LogLevel.WARN]: 4, - [LogLevel.ERROR]: 5, -} - -const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel] - -if (setIndex > LOG_INDEX.trace) { - global.console.trace = jest.fn() -} - -if (setIndex > LOG_INDEX.debug) { - global.console.debug = jest.fn() -} - -if (setIndex > LOG_INDEX.info) { - global.console.info = jest.fn() - global.console.log = jest.fn() -} - -if (setIndex > LOG_INDEX.warn) { - global.console.warn = jest.fn() -} diff --git a/packages/backend-core/tests/utilities/mocks/alerts.ts b/packages/backend-core/tests/utilities/mocks/alerts.ts new file mode 100644 index 0000000000..501c543671 --- /dev/null +++ b/packages/backend-core/tests/utilities/mocks/alerts.ts @@ -0,0 +1,3 @@ +jest.mock("../../../src/logging/alerts") +import * as _alerts from "../../../src/logging/alerts" +export const alerts = jest.mocked(_alerts) diff --git a/packages/backend-core/tests/utilities/mocks/index.ts b/packages/backend-core/tests/utilities/mocks/index.ts index f5f45c0342..915021cecf 100644 --- a/packages/backend-core/tests/utilities/mocks/index.ts +++ b/packages/backend-core/tests/utilities/mocks/index.ts @@ -5,5 +5,6 @@ export const accounts = jest.mocked(_accounts) export * as date from "./date" export * as licenses from "./licenses" export { default as fetch } from "./fetch" +export * from "./alerts" import "./posthog" import "./events" diff --git a/packages/backend-core/yarn.lock b/packages/backend-core/yarn.lock index 91c5c6c9f3..b7ac2a859b 100644 --- a/packages/backend-core/yarn.lock +++ b/packages/backend-core/yarn.lock @@ -1217,15 +1217,6 @@ dependencies: "@types/koa" "*" -"@types/koa-pino-logger@3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/koa-pino-logger/-/koa-pino-logger-3.0.0.tgz#275d4b000abc14b1928dc2e9ab476c8296a64b6a" - integrity sha512-sP+12JNX01q+nHpCRqkVIuLjaRemQEfDoFg0evpTnjUEI3jUI2ZrOkhQ5coxn3yVm2tedui/2YhlaPn/XrYNWA== - dependencies: - "@types/koa" "*" - "@types/pino" "*" - "@types/pino-http" "*" - "@types/koa@*", "@types/koa@2.13.4": version "2.13.4" resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.13.4.tgz#10620b3f24a8027ef5cbae88b393d1b31205726b" @@ -1273,44 +1264,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.20.tgz#268f028b36eaf51181c3300252f605488c4f0650" integrity sha512-Q8KKwm9YqEmUBRsqJ2GWJDtXltBDxTdC4m5vTdXBolu2PeQh8LX+f6BTwU+OuXPu37fLxoN6gidqBmnky36FXA== -"@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== - dependencies: - "@types/pino" "6.3" - -"@types/pino-pretty@*": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@types/pino-pretty/-/pino-pretty-5.0.0.tgz#aa7a61cfd553b051764acfa0a49872f7a09a1722" - integrity sha512-N1uzqSzioqz8R3AkDbSJwcfDWeI3YMPNapSQQhnB2ISU4NYgUIcAh+hYT5ygqBM+klX4htpEhXMmoJv3J7GrdA== - dependencies: - pino-pretty "*" - -"@types/pino-std-serializers@*": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz#1e28b80b554c8222858e99a4e0fc77fd070e10e8" - integrity sha512-gXfUZx2xIBbFYozGms53fT0nvkacx/+62c8iTxrEqH5PkIGAQvDbXg2774VWOycMPbqn5YJBQ3BMsg4Li3dWbg== - dependencies: - pino-std-serializers "*" - -"@types/pino@*": - version "7.0.5" - resolved "https://registry.yarnpkg.com/@types/pino/-/pino-7.0.5.tgz#1c84a81b924a6a9e263dbb581dffdbad7a3c60c4" - integrity sha512-wKoab31pknvILkxAF8ss+v9iNyhw5Iu/0jLtRkUD74cNfOOLJNnqfFKAv0r7wVaTQxRZtWrMpGfShwwBjOcgcg== - dependencies: - pino "*" - -"@types/pino@6.3": - version "6.3.12" - resolved "https://registry.yarnpkg.com/@types/pino/-/pino-6.3.12.tgz#4425db6ced806109c3df957100cba9dfcd73c228" - integrity sha512-dsLRTq8/4UtVSpJgl9aeqHvbh6pzdmjYD3C092SYgLD2TyoCqHpTJk6vp8DvCTGGc7iowZ2MoiYiVUUCcu7muw== - dependencies: - "@types/node" "*" - "@types/pino-pretty" "*" - "@types/pino-std-serializers" "*" - sonic-boom "^2.1.0" - "@types/pouchdb-adapter-cordova-sqlite@*": version "1.0.1" resolved "https://registry.yarnpkg.com/@types/pouchdb-adapter-cordova-sqlite/-/pouchdb-adapter-cordova-sqlite-1.0.1.tgz#49e5ee6df7cc0c23196fcb340f43a560e74eb1d6" @@ -2539,6 +2492,16 @@ duplexer3@^0.1.4: resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" integrity sha512-CEj8FwwNA4cVH2uFCoHUrmojhYh1vmCdOaneKJXwkeY1i9jnlslVo9dx+hQ5Hl9GnH/Bwy/IjxAyOePyPKYnzA== +duplexify@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-4.1.2.tgz#18b4f8d28289132fa0b9573c898d9f903f81c7b0" + integrity sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw== + dependencies: + end-of-stream "^1.4.1" + inherits "^2.0.3" + readable-stream "^3.1.1" + stream-shift "^1.0.0" + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -2728,9 +2691,9 @@ extsprintf@^1.2.0: integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA== fast-copy@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/fast-copy/-/fast-copy-3.0.0.tgz#875ebf33b13948ae012b6e51d33da5e6e7571ab8" - integrity sha512-4HzS+9pQ5Yxtv13Lhs1Z1unMXamBdn5nA4bEi1abYpDNSpSp7ODYQ1KPMF6nTatfEzgH6/zPvXKU1zvHiUjWlA== + version "3.0.1" + resolved "https://registry.yarnpkg.com/fast-copy/-/fast-copy-3.0.1.tgz#9e89ef498b8c04c1cd76b33b8e14271658a732aa" + integrity sha512-Knr7NOtK3HWRYGtHoJrjkaWepqT8thIVGAwt0p0aUs1zqkAzXZV4vo9fFNwyb5fcqK1GKYFYxldQdIDVKhUAfA== fast-deep-equal@^3.1.1: version "3.1.3" @@ -2742,7 +2705,7 @@ fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -fast-redact@^3.1.1: +fast-redact@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/fast-redact/-/fast-redact-3.1.2.tgz#d58e69e9084ce9fa4c1a6fa98a3e1ecf5d7839aa" integrity sha512-+0em+Iya9fKGfEQGcd62Yv6onjBmmhV1uh86XVfOU8VwAe6kaFdQCWI9s0/Nnugx5Vd9tdbZ7e6gE2tR9dzXdw== @@ -2752,6 +2715,13 @@ fast-safe-stringify@^2.1.1: resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884" integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== +fast-url-parser@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/fast-url-parser/-/fast-url-parser-1.1.3.tgz#f4af3ea9f34d8a271cf58ad2b3759f431f0b318d" + integrity sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ== + dependencies: + punycode "^1.3.2" + fb-watchman@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.1.tgz#fc84fb39d2709cf3ff6d743706157bb5708a8a85" @@ -4027,6 +3997,13 @@ koa-passport@4.1.4: dependencies: passport "^0.4.0" +koa-pino-logger@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/koa-pino-logger/-/koa-pino-logger-4.0.0.tgz#a45c9fd0a39e9cd84ac23da502055054ee51b80d" + integrity sha512-YI/LB9ajyLPpjvf6e+7Ewmn+OQkCJpu/Y9eI1n7fnipu5Y1NchuNlke0mqh3/2z+5oDYr7pijjOWruEDIfua2A== + dependencies: + pino-http "^6.5.0" + koa@2.13.4, koa@^2.13.4: version "2.13.4" resolved "https://registry.yarnpkg.com/koa/-/koa-2.13.4.tgz#ee5b0cb39e0b8069c38d115139c774833d32462e" @@ -4623,6 +4600,11 @@ object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== +on-exit-leak-free@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz#b39c9e3bf7690d890f4861558b0d7b90a442d209" + integrity sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg== + on-exit-leak-free@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-2.1.0.tgz#5c703c968f7e7f851885f6459bf8a8a57edc9cc4" @@ -4857,7 +4839,7 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -pino-abstract-transport@^1.0.0, pino-abstract-transport@v1.0.0: +pino-abstract-transport@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pino-abstract-transport/-/pino-abstract-transport-1.0.0.tgz#cc0d6955fffcadb91b7b49ef220a6cc111d48bb3" integrity sha512-c7vo5OpW4wIS42hUVcT5REsL8ZljsUfBjqV/e2sFxmFEFZiq1XLUp5EYLtuDH6PEHq9W1egWqRbnLUP5FuZmOA== @@ -4865,10 +4847,28 @@ pino-abstract-transport@^1.0.0, pino-abstract-transport@v1.0.0: readable-stream "^4.0.0" split2 "^4.0.0" -pino-pretty@*: - version "9.1.1" - resolved "https://registry.yarnpkg.com/pino-pretty/-/pino-pretty-9.1.1.tgz#e7d64c1db98266ca428ab56567b844ba780cd0e1" - integrity sha512-iJrnjgR4FWQIXZkUF48oNgoRI9BpyMhaEmihonHeCnZ6F50ZHAS4YGfGBT/ZVNsPmd+hzkIPGzjKdY08+/yAXw== +pino-abstract-transport@v0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz#4b54348d8f73713bfd14e3dc44228739aa13d9c0" + integrity sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ== + dependencies: + duplexify "^4.1.2" + split2 "^4.0.0" + +pino-http@^6.5.0: + version "6.6.0" + resolved "https://registry.yarnpkg.com/pino-http/-/pino-http-6.6.0.tgz#d0a1deacada8c93327fdaa48f5bdc94bc43d3407" + integrity sha512-PlItaK2MLpoIMLEcClhfb1VQk/o6fKppINl5s6sPE/4rvufkdO3kCSs/92EwrBsB1yssRCQqDV+w1xpYuPVnjg== + dependencies: + fast-url-parser "^1.1.3" + get-caller-file "^2.0.5" + pino "^7.5.0" + pino-std-serializers "^5.0.0" + +pino-pretty@10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/pino-pretty/-/pino-pretty-10.0.0.tgz#fd2f307ee897289f63d09b0b804ac2ecc9a18516" + integrity sha512-zKFjYXBzLaLTEAN1ayKpHXtL5UeRQC7R3lvhKe7fWs7hIVEjKGG/qIXwQt9HmeUp71ogUd/YcW+LmMwRp4KT6Q== dependencies: colorette "^2.0.7" dateformat "^4.6.3" @@ -4885,27 +4885,32 @@ pino-pretty@*: sonic-boom "^3.0.0" strip-json-comments "^3.1.1" -pino-std-serializers@*, pino-std-serializers@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-6.1.0.tgz#307490fd426eefc95e06067e85d8558603e8e844" - integrity sha512-KO0m2f1HkrPe9S0ldjx7za9BJjeHqBku5Ch8JyxETxT8dEFGz1PwgrHaOQupVYitpzbFSYm7nnljxD8dik2c+g== +pino-std-serializers@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz#1791ccd2539c091ae49ce9993205e2cd5dbba1e2" + integrity sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q== -pino@*: - version "8.8.0" - resolved "https://registry.yarnpkg.com/pino/-/pino-8.8.0.tgz#1f0d6695a224aa06afc7ad60f2ccc4772d3b9233" - integrity sha512-cF8iGYeu2ODg2gIwgAHcPrtR63ILJz3f7gkogaHC/TXVVXxZgInmNYiIpDYEwgEkxZti2Se6P2W2DxlBIZe6eQ== +pino-std-serializers@^5.0.0: + version "5.6.0" + resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-5.6.0.tgz#31b141155d6520967c5ec72944d08fb45c490fd3" + integrity sha512-VdUXCw8gO+xhir7sFuoYSjTnzB+TMDGxhAC/ph3YS3sdHnXNdsK0wMtADNUltfeGkn2KDxEM21fnjF3RwXyC8A== + +pino@^7.5.0: + version "7.11.0" + resolved "https://registry.yarnpkg.com/pino/-/pino-7.11.0.tgz#0f0ea5c4683dc91388081d44bff10c83125066f6" + integrity sha512-dMACeu63HtRLmCG8VKdy4cShCPKaYDR4youZqoSWLxl5Gu99HUw8bw75thbPv9Nip+H+QYX8o3ZJbTdVZZ2TVg== dependencies: atomic-sleep "^1.0.0" - fast-redact "^3.1.1" - on-exit-leak-free "^2.1.0" - pino-abstract-transport v1.0.0 - pino-std-serializers "^6.0.0" - process-warning "^2.0.0" + fast-redact "^3.0.0" + on-exit-leak-free "^0.2.0" + pino-abstract-transport v0.5.0 + pino-std-serializers "^4.0.0" + process-warning "^1.0.0" quick-format-unescaped "^4.0.3" - real-require "^0.2.0" - safe-stable-stringify "^2.3.1" - sonic-boom "^3.1.0" - thread-stream "^2.0.0" + real-require "^0.1.0" + safe-stable-stringify "^2.1.0" + sonic-boom "^2.2.1" + thread-stream "^0.15.1" pirates@^4.0.4: version "4.0.5" @@ -5156,10 +5161,10 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== -process-warning@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-2.1.0.tgz#1e60e3bfe8183033bbc1e702c2da74f099422d1a" - integrity sha512-9C20RLxrZU/rFnxWncDkuF6O999NdIf3E1ws4B0ZeY3sRVPzWBMsYDE2lxjxhiXxg464cQTgKUGm8/i6y2YGXg== +process-warning@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-1.0.0.tgz#980a0b25dc38cd6034181be4b7726d89066b4616" + integrity sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q== process@^0.11.10: version "0.11.10" @@ -5207,6 +5212,11 @@ punycode@1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" integrity sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw== +punycode@^1.3.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== + punycode@^2.1.0, punycode@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" @@ -5330,10 +5340,10 @@ readline-sync@^1.4.9: resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.10.tgz#41df7fbb4b6312d673011594145705bf56d8873b" integrity sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw== -real-require@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/real-require/-/real-require-0.2.0.tgz#209632dea1810be2ae063a6ac084fee7e33fba78" - integrity sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg== +real-require@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/real-require/-/real-require-0.1.0.tgz#736ac214caa20632847b7ca8c1056a0767df9381" + integrity sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg== redis-commands@1.7.0: version "1.7.0" @@ -5477,7 +5487,7 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-stable-stringify@^2.3.1: +safe-stable-stringify@^2.1.0: version "2.4.2" resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.4.2.tgz#ec7b037768098bf65310d1d64370de0dc02353aa" integrity sha512-gMxvPJYhP0O9n2pvcfYfIuYgbledAOJFcqRThtPRmjscaipiwcwPPKLytpVzMkG2HAN87Qmo2d4PtGiri1dSLA== @@ -5589,14 +5599,14 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -sonic-boom@^2.1.0: +sonic-boom@^2.2.1: version "2.8.0" resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-2.8.0.tgz#c1def62a77425090e6ad7516aad8eb402e047611" integrity sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg== dependencies: atomic-sleep "^1.0.0" -sonic-boom@^3.0.0, sonic-boom@^3.1.0: +sonic-boom@^3.0.0: version "3.2.1" resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-3.2.1.tgz#972ceab831b5840a08a002fa95a672008bda1c38" integrity sha512-iITeTHxy3B9FGu8aVdiDXUVAcHMF9Ss0cCsAOo2HfCrmVGT3/DT5oYaeu0M/YKZDlKTvChEyPq0zI9Hf33EX6A== @@ -5701,6 +5711,11 @@ step@0.0.x: resolved "https://registry.yarnpkg.com/step/-/step-0.0.6.tgz#143e7849a5d7d3f4a088fe29af94915216eeede2" integrity sha512-qSSeQinUJk2w38vUFobjFoE307GqsozMC8VisOCkJLpklvKPT0ptPHwWOrENoag8rgLudvTkfP3bancwP93/Jw== +stream-shift@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" + integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== + stream-to-array@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/stream-to-array/-/stream-to-array-2.3.0.tgz#bbf6b39f5f43ec30bc71babcb37557acecf34353" @@ -5897,12 +5912,12 @@ testcontainers@4.7.0: stream-to-array "^2.3.0" tar-fs "^2.1.0" -thread-stream@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/thread-stream/-/thread-stream-2.3.0.tgz#4fc07fb39eff32ae7bad803cb7dd9598349fed33" - integrity sha512-kaDqm1DET9pp3NXwR8382WHbnpXnRkN9xGN9dQt3B2+dmXiW8X1SOwmFOxAErEQ47ObhZ96J6yhZNXuyCOL7KA== +thread-stream@^0.15.1: + version "0.15.2" + resolved "https://registry.yarnpkg.com/thread-stream/-/thread-stream-0.15.2.tgz#fb95ad87d2f1e28f07116eb23d85aba3bc0425f4" + integrity sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA== dependencies: - real-require "^0.2.0" + real-require "^0.1.0" through2@3.0.2: version "3.0.2" diff --git a/packages/server/package.json b/packages/server/package.json index 3e9778e7e1..24168df926 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -85,7 +85,6 @@ "koa-body": "4.2.0", "koa-compress": "4.0.1", "koa-connect": "2.1.0", - "koa-pino-logger": "3.0.0", "koa-send": "5.0.0", "koa-session": "5.12.0", "koa-static": "5.0.0", @@ -99,7 +98,6 @@ "node-fetch": "2.6.7", "open": "8.4.0", "pg": "8.5.1", - "pino-pretty": "5.1.3", "posthog-node": "1.3.0", "pouchdb": "7.3.0", "pouchdb-adapter-memory": "7.2.2", diff --git a/packages/server/scripts/dev/manage.js b/packages/server/scripts/dev/manage.js index 543e00ac59..c5043895cb 100644 --- a/packages/server/scripts/dev/manage.js +++ b/packages/server/scripts/dev/manage.js @@ -45,6 +45,7 @@ async function init() { BB_ADMIN_USER_PASSWORD: "", PLUGINS_DIR: "", TENANT_FEATURE_FLAGS: "*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR", + HTTP_LOGGING: 0, } let envFile = "" Object.keys(envFileJson).forEach(key => { diff --git a/packages/server/src/api/controllers/ops.ts b/packages/server/src/api/controllers/ops.ts new file mode 100644 index 0000000000..89ad0ac97b --- /dev/null +++ b/packages/server/src/api/controllers/ops.ts @@ -0,0 +1,32 @@ +import { Ctx } from "@budibase/types" +import { logging } from "@budibase/backend-core" + +interface LogRequest { + message: string + data?: any +} + +interface ErrorRequest { + message: string +} + +export async function log(ctx: Ctx) { + const body = ctx.request.body + console.trace(body.message, body.data) + console.debug(body.message, body.data) + console.info(body.message, body.data) + console.warn(body.message, body.data) + console.error(body.message, body.data) + ctx.status = 204 +} + +export async function alert(ctx: Ctx) { + const body = ctx.request.body + logging.logAlert(body.message, new Error(body.message)) + ctx.status = 204 +} + +export async function error(ctx: Ctx) { + const body = ctx.request.body + throw new Error(body.message) +} diff --git a/packages/server/src/api/routes/index.ts b/packages/server/src/api/routes/index.ts index 9dc119ec83..e15e8aa92b 100644 --- a/packages/server/src/api/routes/index.ts +++ b/packages/server/src/api/routes/index.ts @@ -25,6 +25,7 @@ import devRoutes from "./dev" import cloudRoutes from "./cloud" import migrationRoutes from "./migrations" import pluginRoutes from "./plugin" +import opsRoutes from "./ops" import Router from "@koa/router" import { api as pro } from "@budibase/pro" @@ -63,6 +64,7 @@ export const mainRoutes: Router[] = [ rowRoutes, migrationRoutes, pluginRoutes, + opsRoutes, scheduleRoutes, environmentVariableRoutes, // these need to be handled last as they still use /api/:tableId diff --git a/packages/server/src/api/routes/ops.ts b/packages/server/src/api/routes/ops.ts new file mode 100644 index 0000000000..8ff1ca995f --- /dev/null +++ b/packages/server/src/api/routes/ops.ts @@ -0,0 +1,30 @@ +import Router from "@koa/router" +import * as controller from "../controllers/ops" +import { middleware } from "@budibase/backend-core" +import Joi from "joi" + +export function logsValidator() { + return middleware.joiValidator.body( + Joi.object({ + message: Joi.string().required(), + data: Joi.object(), + }) + ) +} + +export function errorValidator() { + return middleware.joiValidator.body( + Joi.object({ + message: Joi.string().required(), + }) + ) +} + +const router: Router = new Router() + +router + .post("/api/ops/log", logsValidator(), controller.log) + .post("/api/ops/error", errorValidator(), controller.error) + .post("/api/ops/alert", errorValidator(), controller.alert) + +export default router diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index a7070b3c19..230904f405 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -2,21 +2,9 @@ if (process.env.DD_APM_ENABLED) { require("./ddApm") } -if (process.env.ELASTIC_APM_ENABLED) { - require("./elasticApm") -} - // need to load environment first import env from "./environment" -// enable APM if configured -if (process.env.ELASTIC_APM_ENABLED) { - const apm = require("elastic-apm-node").start({ - serviceName: process.env.SERVICE, - environment: process.env.BUDIBASE_ENVIRONMENT, - }) -} - import { ExtendableContext } from "koa" import * as db from "./db" db.init() @@ -53,7 +41,8 @@ app.use( }) ) -app.use(middleware.logging) +app.use(middleware.correlation) +app.use(middleware.pino) app.use(userAgent) if (env.isProd()) { diff --git a/packages/server/src/elasticApm.ts b/packages/server/src/elasticApm.ts deleted file mode 100644 index 5581b9dd4b..0000000000 --- a/packages/server/src/elasticApm.ts +++ /dev/null @@ -1,10 +0,0 @@ -import apm from "elastic-apm-node" - -// enable APM if configured -if (process.env.ELASTIC_APM_ENABLED) { - console.log("Starting elastic-apm-node") - apm.start({ - serviceName: process.env.SERVICE, - environment: process.env.BUDIBASE_ENVIRONMENT, - }) -} diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts index 058e8bdff8..1bd5a6486c 100644 --- a/packages/server/src/environment.ts +++ b/packages/server/src/environment.ts @@ -62,7 +62,6 @@ const environment = { // minor SALT_ROUNDS: process.env.SALT_ROUNDS, LOGGER: process.env.LOGGER, - LOG_LEVEL: process.env.LOG_LEVEL, ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL, AUTOMATION_MAX_ITERATIONS: parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200, diff --git a/packages/server/src/migrations/functions/usageQuotas/syncApps.ts b/packages/server/src/migrations/functions/usageQuotas/syncApps.ts index 351154dccc..39b8efe335 100644 --- a/packages/server/src/migrations/functions/usageQuotas/syncApps.ts +++ b/packages/server/src/migrations/functions/usageQuotas/syncApps.ts @@ -9,6 +9,6 @@ export const run = async () => { // sync app count const tenantId = tenancy.getTenantId() - console.log(`[Tenant: ${tenantId}] Syncing app count: ${appCount}`) + console.log(`Syncing app count: ${appCount}`) await quotas.setUsage(appCount, StaticQuotaName.APPS, QuotaUsageType.STATIC) } diff --git a/packages/server/src/migrations/functions/usageQuotas/syncRows.ts b/packages/server/src/migrations/functions/usageQuotas/syncRows.ts index 92574d1f27..506218a41f 100644 --- a/packages/server/src/migrations/functions/usageQuotas/syncRows.ts +++ b/packages/server/src/migrations/functions/usageQuotas/syncRows.ts @@ -1,4 +1,4 @@ -import { tenancy, db as dbCore } from "@budibase/backend-core" +import { db as dbCore } from "@budibase/backend-core" import { getUniqueRows } from "../../../utilities/usageQuota/rows" import { quotas } from "@budibase/pro" import { StaticQuotaName, QuotaUsageType, App } from "@budibase/types" @@ -18,8 +18,7 @@ export const run = async () => { }) // sync row count - const tenantId = tenancy.getTenantId() - console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`) + console.log(`Syncing row count: ${rowCount}`) await quotas.setUsagePerApp( counts, StaticQuotaName.ROWS, diff --git a/packages/server/src/startup.ts b/packages/server/src/startup.ts index 6cdbf87c2c..f6a5307b8f 100644 --- a/packages/server/src/startup.ts +++ b/packages/server/src/startup.ts @@ -16,13 +16,10 @@ import * as bullboard from "./automations/bullboard" import * as pro from "@budibase/pro" import * as api from "./api" import sdk from "./sdk" -const pino = require("koa-pino-logger") let STARTUP_RAN = false async function initRoutes(app: any) { - app.use(pino(logging.pinoSettings())) - if (!env.isTest()) { const plugin = await bullboard.init() app.use(plugin) diff --git a/packages/server/src/tests/jestEnv.ts b/packages/server/src/tests/jestEnv.ts index 1f76bccd5f..34c51009aa 100644 --- a/packages/server/src/tests/jestEnv.ts +++ b/packages/server/src/tests/jestEnv.ts @@ -6,7 +6,6 @@ process.env.MULTI_TENANCY = "1" // @ts-ignore process.env.BUDIBASE_DIR = tmpdir("budibase-unittests") process.env.LOG_LEVEL = process.env.LOG_LEVEL || "error" -process.env.ENABLE_4XX_HTTP_LOGGING = "0" process.env.MOCK_REDIS = "1" process.env.PLATFORM_URL = "http://localhost:10000" process.env.REDIS_PASSWORD = "budibase" diff --git a/packages/server/src/tests/jestSetup.ts b/packages/server/src/tests/jestSetup.ts index 9f3b85cac4..e233e7152e 100644 --- a/packages/server/src/tests/jestSetup.ts +++ b/packages/server/src/tests/jestSetup.ts @@ -1,4 +1,3 @@ -import "./logging" import env from "../environment" import { env as coreEnv, timers } from "@budibase/backend-core" import { testContainerUtils } from "@budibase/backend-core/tests" diff --git a/packages/server/src/tests/logging.ts b/packages/server/src/tests/logging.ts deleted file mode 100644 index 271f4d62ff..0000000000 --- a/packages/server/src/tests/logging.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum LogLevel { - TRACE = "trace", - DEBUG = "debug", - INFO = "info", - WARN = "warn", - ERROR = "error", -} - -const LOG_INDEX: { [key in LogLevel]: number } = { - [LogLevel.TRACE]: 1, - [LogLevel.DEBUG]: 2, - [LogLevel.INFO]: 3, - [LogLevel.WARN]: 4, - [LogLevel.ERROR]: 5, -} - -const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel] - -if (setIndex > LOG_INDEX.trace) { - global.console.trace = jest.fn() -} - -if (setIndex > LOG_INDEX.debug) { - global.console.debug = jest.fn() -} - -if (setIndex > LOG_INDEX.info) { - global.console.info = jest.fn() - global.console.log = jest.fn() -} - -if (setIndex > LOG_INDEX.warn) { - global.console.warn = jest.fn() -} diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index ccd0c2b20b..409fd47778 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1677,11 +1677,6 @@ protobufjs "^6.11.3" yargs "^16.2.0" -"@hapi/bourne@^2.0.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@hapi/bourne/-/bourne-2.1.0.tgz#66aff77094dc3080bd5df44ec63881f2676eb020" - integrity sha512-i1BpaNDVLJdRBEKeJWkVO6tYX6DMFBuwMhSuWqLsY4ufeTKGVuV5rBsUhxPayXqnnWHgXUAmWK16H/ykO5Wj4Q== - "@hapi/hoek@^9.0.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" @@ -4168,16 +4163,6 @@ argparse@^2.0.1: resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== -args@^5.0.1: - version "5.0.3" - resolved "https://registry.yarnpkg.com/args/-/args-5.0.3.tgz#943256db85021a85684be2f0882f25d796278702" - integrity sha512-h6k/zfFgusnv3i5TU08KQkVKuCPBtL/PWQbWkHUxvJrZ2nAyeaUupneemcrgn1xmqxPQsPIzwkUhOpoqPDRZuA== - dependencies: - camelcase "5.0.0" - chalk "2.4.2" - leven "2.1.0" - mri "1.1.4" - argsarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/argsarray/-/argsarray-0.0.1.tgz#6e7207b4ecdb39b0af88303fa5ae22bda8df61cb" @@ -4992,11 +4977,6 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -camelcase@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" - integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA== - camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -5022,7 +5002,7 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== -chalk@2.4.2, chalk@^2.0.0, chalk@^2.1.0: +chalk@^2.0.0, chalk@^2.1.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -5617,11 +5597,6 @@ date-utils@*: resolved "https://registry.yarnpkg.com/date-utils/-/date-utils-1.2.21.tgz#61fb16cdc1274b3c9acaaffe9fc69df8720a2b64" integrity sha512-wJMBjqlwXR0Iv0wUo/lFbhSQ7MmG1hl36iuxuE91kW+5b5sWbase73manEqNH9sOLFAMG83B4ffNKq9/Iq0FVA== -dateformat@^4.5.1: - version "4.6.3" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.6.3.tgz#556fa6497e5217fedb78821424f8a1c22fa3f4b5" - integrity sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA== - dayjs@^1.10.4, dayjs@^1.10.5: version "1.11.3" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.3.tgz#4754eb694a624057b9ad2224b67b15d552589258" @@ -6913,13 +6888,6 @@ fast-text-encoding@^1.0.0, fast-text-encoding@^1.0.3: resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.3.tgz#ec02ac8e01ab8a319af182dae2681213cfe9ce53" integrity sha512-dtm4QZH9nZtcDt8qJiOH9fcQd1NAgi+K1O2DbE6GG1PPCK/BWfOH3idCTRQ4ImXRUOyopDEgDEnVEE7Y/2Wrig== -fast-url-parser@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/fast-url-parser/-/fast-url-parser-1.1.3.tgz#f4af3ea9f34d8a271cf58ad2b3759f431f0b318d" - integrity sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ== - dependencies: - punycode "^1.3.2" - fastest-levenshtein@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" @@ -9281,7 +9249,7 @@ jimp@0.16.1: "@jimp/types" "^0.16.1" regenerator-runtime "^0.13.3" -jmespath@0.15.0, jmespath@^0.15.0: +jmespath@0.15.0: version "0.15.0" resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217" integrity sha512-+kHj8HXArPfpPEKGLZ+kB5ONRTCiGQXo8RQYL0hH8t6pWXUBBK5KkkQmTNOwKK4LEsd0yTsgtjJVm4UBSZea4w== @@ -9307,7 +9275,7 @@ join-component@^1.1.0: resolved "https://registry.yarnpkg.com/join-component/-/join-component-1.1.0.tgz#b8417b750661a392bee2c2537c68b2a9d4977cd5" integrity sha512-bF7vcQxbODoGK1imE2P9GS9aw4zD0Sd+Hni68IMZLj7zRnquH7dXUmMw9hDI5S/Jzt7q+IyTXN0rSg2GI0IKhQ== -joycon@^3.0.0, joycon@^3.0.1: +joycon@^3.0.1: version "3.1.1" resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== @@ -9680,13 +9648,6 @@ koa-passport@4.1.4: dependencies: passport "^0.4.0" -koa-pino-logger@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/koa-pino-logger/-/koa-pino-logger-3.0.0.tgz#27600b4f3639e8767dfc6b66493109c5457f53ba" - integrity sha512-teJsT88JLRBYH7pJACGAwAHfl2y/x5u5aSPD03Z/HW6QDMAWyRxk4dsY0/UbtM8wgaXIaxZgIFUxxvgiQFr6WQ== - dependencies: - pino-http "^5.0.1" - koa-router@^10.0.0: version "10.1.1" resolved "https://registry.yarnpkg.com/koa-router/-/koa-router-10.1.1.tgz#20809f82648518b84726cd445037813cd99f17ff" @@ -9902,11 +9863,6 @@ levelup@4.4.0, levelup@^4.3.2: level-supports "~1.0.0" xtend "~4.0.0" -leven@2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580" - integrity sha512-nvVPLpIHUxCUoRLrFqTgSxXJ614d8AgQoWl7zPe/2VadE8+1dpU3LBhowRuBAcuwruWtOdD8oYC9jDNJjXDPyA== - leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -10592,11 +10548,6 @@ monitor-event-loop-delay@^1.0.0: resolved "https://registry.yarnpkg.com/monitor-event-loop-delay/-/monitor-event-loop-delay-1.0.0.tgz#b5ab78165a3bb93f2b275c50d01430c7f155d1f7" integrity sha512-YRIr1exCIfBDLZle8WHOfSo7Xg3M+phcZfq9Fx1L6Abo+atGp7cge5pM7PjyBn4s1oZI/BRD4EMrzQBbPpVb5Q== -mri@1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.4.tgz#7cb1dd1b9b40905f1fac053abe25b6720f44744a" - integrity sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w== - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -11618,44 +11569,12 @@ pinkie@^2.0.0: resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" integrity sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg== -pino-http@^5.0.1: - version "5.8.0" - resolved "https://registry.yarnpkg.com/pino-http/-/pino-http-5.8.0.tgz#6e688fd5f965c5b6991f340eb660ea2927be9aa7" - integrity sha512-YwXiyRb9y0WCD1P9PcxuJuh3Dc5qmXde/paJE86UGYRdiFOi828hR9iUGmk5gaw6NBT9gLtKANOHFimvh19U5w== - dependencies: - fast-url-parser "^1.1.3" - pino "^6.13.0" - pino-std-serializers "^4.0.0" - -pino-pretty@5.1.3: - version "5.1.3" - resolved "https://registry.yarnpkg.com/pino-pretty/-/pino-pretty-5.1.3.tgz#c4085093d1dffda359ab52731f87d96f7f832dc9" - integrity sha512-Zj+0TVdYKkAAIx9EUCL5e4TttwgsaFvJh2ceIMQeFCY8ak9tseEZQGSgpvyjEj1/iIVGIh5tdhkGEQWSMILKHA== - dependencies: - "@hapi/bourne" "^2.0.0" - args "^5.0.1" - chalk "^4.0.0" - dateformat "^4.5.1" - fast-safe-stringify "^2.0.7" - jmespath "^0.15.0" - joycon "^3.0.0" - pump "^3.0.0" - readable-stream "^3.6.0" - rfdc "^1.3.0" - split2 "^3.1.1" - strip-json-comments "^3.1.1" - pino-std-serializers@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-3.2.0.tgz#b56487c402d882eb96cd67c257868016b61ad671" integrity sha512-EqX4pwDPrt3MuOAAUBMU0Tk5kR/YcCM5fNPEzgCO2zJ5HfX0vbiH9HbJglnyeQsN96Kznae6MWD47pZB5avTrg== -pino-std-serializers@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz#1791ccd2539c091ae49ce9993205e2cd5dbba1e2" - integrity sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q== - -pino@^6.11.2, pino@^6.13.0: +pino@^6.11.2: version "6.14.0" resolved "https://registry.yarnpkg.com/pino/-/pino-6.14.0.tgz#b745ea87a99a6c4c9b374e4f29ca7910d4c69f78" integrity sha512-iuhEDel3Z3hF9Jfe44DPXR8l07bhjuFY3GMHIXbjnY9XcafbyDDwl2sN2vw2GjMPf5Nkoe+OFao7ffn9SXaKDg== @@ -12131,11 +12050,6 @@ punycode@1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" integrity sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw== -punycode@^1.3.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== - punycode@^2.1.0, punycode@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" @@ -12275,7 +12189,7 @@ readable-stream@1.1.14, readable-stream@^1.0.27-1: isarray "0.0.1" string_decoder "~0.10.x" -"readable-stream@2 || 3", readable-stream@^3.0.0, readable-stream@^3.0.1, readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.5.0, readable-stream@^3.6.0: +"readable-stream@2 || 3", readable-stream@^3.0.1, readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.5.0, readable-stream@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -12687,7 +12601,7 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rfdc@^1.2.0, rfdc@^1.3.0: +rfdc@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== @@ -13288,13 +13202,6 @@ split2@^2.1.0: dependencies: through2 "^2.0.2" -split2@^3.1.1: - version "3.2.2" - resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f" - integrity sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg== - dependencies: - readable-stream "^3.0.0" - split2@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/split2/-/split2-4.1.0.tgz#101907a24370f85bb782f08adaabe4e281ecf809" diff --git a/packages/worker/package.json b/packages/worker/package.json index 0e8b54a521..957f516650 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -56,7 +56,6 @@ "koa-body": "4.2.0", "koa-compress": "4.0.1", "koa-passport": "4.1.4", - "koa-pino-logger": "3.0.0", "koa-send": "5.0.1", "koa-session": "5.13.1", "koa-static": "5.0.0", @@ -66,7 +65,6 @@ "passport-google-oauth": "2.0.0", "passport-jwt": "4.0.0", "passport-local": "1.0.0", - "pino-pretty": "5.1.3", "pouchdb": "7.3.0", "pouchdb-all-dbs": "1.1.1", "server-destroy": "1.0.1" diff --git a/packages/worker/scripts/dev/manage.js b/packages/worker/scripts/dev/manage.js index 21a9eab9c6..ecf5defd47 100644 --- a/packages/worker/scripts/dev/manage.js +++ b/packages/worker/scripts/dev/manage.js @@ -30,6 +30,7 @@ async function init() { DEPLOYMENT_ENVIRONMENT: "development", TENANT_FEATURE_FLAGS: "*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR", ENABLE_EMAIL_TEST_MODE: 1, + HTTP_LOGGING: 0, } let envFile = "" Object.keys(envFileJson).forEach(key => { diff --git a/packages/worker/src/elasticApm.ts b/packages/worker/src/elasticApm.ts deleted file mode 100644 index 5581b9dd4b..0000000000 --- a/packages/worker/src/elasticApm.ts +++ /dev/null @@ -1,10 +0,0 @@ -import apm from "elastic-apm-node" - -// enable APM if configured -if (process.env.ELASTIC_APM_ENABLED) { - console.log("Starting elastic-apm-node") - apm.start({ - serviceName: process.env.SERVICE, - environment: process.env.BUDIBASE_ENVIRONMENT, - }) -} diff --git a/packages/worker/src/environment.ts b/packages/worker/src/environment.ts index 812af6aacd..678ffe7f14 100644 --- a/packages/worker/src/environment.ts +++ b/packages/worker/src/environment.ts @@ -47,7 +47,6 @@ const environment = { // flags NODE_ENV: process.env.NODE_ENV, SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED || ""), - LOG_LEVEL: process.env.LOG_LEVEL, MULTI_TENANCY: process.env.MULTI_TENANCY, DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL, SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED, diff --git a/packages/worker/src/index.ts b/packages/worker/src/index.ts index 1a646c623d..30596d1d76 100644 --- a/packages/worker/src/index.ts +++ b/packages/worker/src/index.ts @@ -2,10 +2,6 @@ if (process.env.DD_APM_ENABLED) { require("./ddApm") } -if (process.env.ELASTIC_APM_ENABLED) { - require("./elasticApm") -} - // need to load environment first import env from "./environment" import { Scope } from "@sentry/node" @@ -31,7 +27,6 @@ import api from "./api" import * as redis from "./utilities/redis" const Sentry = require("@sentry/node") const koaSession = require("koa-session") -const logger = require("koa-pino-logger") const { userAgent } = require("koa-useragent") import destroyable from "server-destroy" @@ -60,8 +55,8 @@ app.use(handleScimBody) app.use(koaBody({ multipart: true })) app.use(koaSession(app)) -app.use(middleware.logging) -app.use(logger(logging.pinoSettings())) +app.use(middleware.correlation) +app.use(middleware.pino) app.use(userAgent) // authentication diff --git a/packages/worker/src/tests/jestEnv.ts b/packages/worker/src/tests/jestEnv.ts index 5784e44dcf..fc92bbbf23 100644 --- a/packages/worker/src/tests/jestEnv.ts +++ b/packages/worker/src/tests/jestEnv.ts @@ -2,7 +2,6 @@ process.env.SELF_HOSTED = "0" process.env.NODE_ENV = "jest" process.env.JWT_SECRET = "test-jwtsecret" process.env.LOG_LEVEL = process.env.LOG_LEVEL || "error" -process.env.ENABLE_4XX_HTTP_LOGGING = "0" process.env.MULTI_TENANCY = "1" process.env.MINIO_URL = "http://localhost" process.env.MINIO_ACCESS_KEY = "test" diff --git a/packages/worker/src/tests/jestSetup.ts b/packages/worker/src/tests/jestSetup.ts index 7a3fb08cb9..17bcb7dfb4 100644 --- a/packages/worker/src/tests/jestSetup.ts +++ b/packages/worker/src/tests/jestSetup.ts @@ -1,5 +1,3 @@ -import "./logging" - import { mocks, testContainerUtils } from "@budibase/backend-core/tests" import env from "../environment" import { env as coreEnv, timers } from "@budibase/backend-core" diff --git a/packages/worker/src/tests/logging.ts b/packages/worker/src/tests/logging.ts deleted file mode 100644 index 271f4d62ff..0000000000 --- a/packages/worker/src/tests/logging.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum LogLevel { - TRACE = "trace", - DEBUG = "debug", - INFO = "info", - WARN = "warn", - ERROR = "error", -} - -const LOG_INDEX: { [key in LogLevel]: number } = { - [LogLevel.TRACE]: 1, - [LogLevel.DEBUG]: 2, - [LogLevel.INFO]: 3, - [LogLevel.WARN]: 4, - [LogLevel.ERROR]: 5, -} - -const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel] - -if (setIndex > LOG_INDEX.trace) { - global.console.trace = jest.fn() -} - -if (setIndex > LOG_INDEX.debug) { - global.console.debug = jest.fn() -} - -if (setIndex > LOG_INDEX.info) { - global.console.info = jest.fn() - global.console.log = jest.fn() -} - -if (setIndex > LOG_INDEX.warn) { - global.console.warn = jest.fn() -} diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 20ec58a674..5db376b1b3 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -682,11 +682,6 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@hapi/bourne@^2.0.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@hapi/bourne/-/bourne-2.1.0.tgz#66aff77094dc3080bd5df44ec63881f2676eb020" - integrity sha512-i1BpaNDVLJdRBEKeJWkVO6tYX6DMFBuwMhSuWqLsY4ufeTKGVuV5rBsUhxPayXqnnWHgXUAmWK16H/ykO5Wj4Q== - "@hapi/hoek@^9.0.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" @@ -2133,16 +2128,6 @@ argparse@^1.0.10, argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -args@^5.0.1: - version "5.0.3" - resolved "https://registry.yarnpkg.com/args/-/args-5.0.3.tgz#943256db85021a85684be2f0882f25d796278702" - integrity sha512-h6k/zfFgusnv3i5TU08KQkVKuCPBtL/PWQbWkHUxvJrZ2nAyeaUupneemcrgn1xmqxPQsPIzwkUhOpoqPDRZuA== - dependencies: - camelcase "5.0.0" - chalk "2.4.2" - leven "2.1.0" - mri "1.1.4" - argsarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/argsarray/-/argsarray-0.0.1.tgz#6e7207b4ecdb39b0af88303fa5ae22bda8df61cb" @@ -2676,11 +2661,6 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -camelcase@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" - integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA== - camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -2706,7 +2686,7 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== -chalk@2.4.2, chalk@^2.0.0, chalk@^2.1.0: +chalk@^2.0.0, chalk@^2.1.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3142,11 +3122,6 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -dateformat@^4.5.1: - version "4.6.3" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.6.3.tgz#556fa6497e5217fedb78821424f8a1c22fa3f4b5" - integrity sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA== - dayjs@^1.10.4: version "1.11.7" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2" @@ -4014,13 +3989,6 @@ fast-stream-to-buffer@^1.0.0: dependencies: end-of-stream "^1.4.1" -fast-url-parser@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/fast-url-parser/-/fast-url-parser-1.1.3.tgz#f4af3ea9f34d8a271cf58ad2b3759f431f0b318d" - integrity sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ== - dependencies: - punycode "^1.3.2" - fastq@^1.6.0: version "1.13.0" resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" @@ -5744,7 +5712,7 @@ jest@28.1.1: import-local "^3.0.2" jest-cli "^28.1.1" -jmespath@0.15.0, jmespath@^0.15.0: +jmespath@0.15.0: version "0.15.0" resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217" integrity sha512-+kHj8HXArPfpPEKGLZ+kB5ONRTCiGQXo8RQYL0hH8t6pWXUBBK5KkkQmTNOwKK4LEsd0yTsgtjJVm4UBSZea4w== @@ -5765,11 +5733,6 @@ join-component@^1.1.0: resolved "https://registry.yarnpkg.com/join-component/-/join-component-1.1.0.tgz#b8417b750661a392bee2c2537c68b2a9d4977cd5" integrity sha512-bF7vcQxbODoGK1imE2P9GS9aw4zD0Sd+Hni68IMZLj7zRnquH7dXUmMw9hDI5S/Jzt7q+IyTXN0rSg2GI0IKhQ== -joycon@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" - integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== - js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -5998,13 +5961,6 @@ koa-passport@4.1.4: dependencies: passport "^0.4.0" -koa-pino-logger@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/koa-pino-logger/-/koa-pino-logger-3.0.0.tgz#27600b4f3639e8767dfc6b66493109c5457f53ba" - integrity sha512-teJsT88JLRBYH7pJACGAwAHfl2y/x5u5aSPD03Z/HW6QDMAWyRxk4dsY0/UbtM8wgaXIaxZgIFUxxvgiQFr6WQ== - dependencies: - pino-http "^5.0.1" - koa-send@5.0.1, koa-send@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/koa-send/-/koa-send-5.0.1.tgz#39dceebfafb395d0d60beaffba3a70b4f543fe79" @@ -6169,11 +6125,6 @@ levelup@4.4.0, levelup@^4.3.2: level-supports "~1.0.0" xtend "~4.0.0" -leven@2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580" - integrity sha512-nvVPLpIHUxCUoRLrFqTgSxXJ614d8AgQoWl7zPe/2VadE8+1dpU3LBhowRuBAcuwruWtOdD8oYC9jDNJjXDPyA== - leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -6609,11 +6560,6 @@ monitor-event-loop-delay@^1.0.0: resolved "https://registry.yarnpkg.com/monitor-event-loop-delay/-/monitor-event-loop-delay-1.0.0.tgz#b5ab78165a3bb93f2b275c50d01430c7f155d1f7" integrity sha512-YRIr1exCIfBDLZle8WHOfSo7Xg3M+phcZfq9Fx1L6Abo+atGp7cge5pM7PjyBn4s1oZI/BRD4EMrzQBbPpVb5Q== -mri@1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.4.tgz#7cb1dd1b9b40905f1fac053abe25b6720f44744a" - integrity sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w== - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -7256,44 +7202,12 @@ pify@^5.0.0: resolved "https://registry.yarnpkg.com/pify/-/pify-5.0.0.tgz#1f5eca3f5e87ebec28cc6d54a0e4aaf00acc127f" integrity sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA== -pino-http@^5.0.1: - version "5.8.0" - resolved "https://registry.yarnpkg.com/pino-http/-/pino-http-5.8.0.tgz#6e688fd5f965c5b6991f340eb660ea2927be9aa7" - integrity sha512-YwXiyRb9y0WCD1P9PcxuJuh3Dc5qmXde/paJE86UGYRdiFOi828hR9iUGmk5gaw6NBT9gLtKANOHFimvh19U5w== - dependencies: - fast-url-parser "^1.1.3" - pino "^6.13.0" - pino-std-serializers "^4.0.0" - -pino-pretty@5.1.3: - version "5.1.3" - resolved "https://registry.yarnpkg.com/pino-pretty/-/pino-pretty-5.1.3.tgz#c4085093d1dffda359ab52731f87d96f7f832dc9" - integrity sha512-Zj+0TVdYKkAAIx9EUCL5e4TttwgsaFvJh2ceIMQeFCY8ak9tseEZQGSgpvyjEj1/iIVGIh5tdhkGEQWSMILKHA== - dependencies: - "@hapi/bourne" "^2.0.0" - args "^5.0.1" - chalk "^4.0.0" - dateformat "^4.5.1" - fast-safe-stringify "^2.0.7" - jmespath "^0.15.0" - joycon "^3.0.0" - pump "^3.0.0" - readable-stream "^3.6.0" - rfdc "^1.3.0" - split2 "^3.1.1" - strip-json-comments "^3.1.1" - pino-std-serializers@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-3.2.0.tgz#b56487c402d882eb96cd67c257868016b61ad671" integrity sha512-EqX4pwDPrt3MuOAAUBMU0Tk5kR/YcCM5fNPEzgCO2zJ5HfX0vbiH9HbJglnyeQsN96Kznae6MWD47pZB5avTrg== -pino-std-serializers@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz#1791ccd2539c091ae49ce9993205e2cd5dbba1e2" - integrity sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q== - -pino@^6.11.2, pino@^6.13.0: +pino@^6.11.2: version "6.14.0" resolved "https://registry.yarnpkg.com/pino/-/pino-6.14.0.tgz#b745ea87a99a6c4c9b374e4f29ca7910d4c69f78" integrity sha512-iuhEDel3Z3hF9Jfe44DPXR8l07bhjuFY3GMHIXbjnY9XcafbyDDwl2sN2vw2GjMPf5Nkoe+OFao7ffn9SXaKDg== @@ -7660,11 +7574,6 @@ punycode@1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" integrity sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw== -punycode@^1.3.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== - punycode@^2.1.0, punycode@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" @@ -7776,7 +7685,7 @@ readable-stream@1.1.14, readable-stream@^1.0.27-1: isarray "0.0.1" string_decoder "~0.10.x" -"readable-stream@2 || 3", readable-stream@^3.0.0, readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.5.0, readable-stream@^3.6.0: +"readable-stream@2 || 3", readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.5.0, readable-stream@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -8078,7 +7987,7 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rfdc@^1.2.0, rfdc@^1.3.0: +rfdc@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== @@ -8448,13 +8357,6 @@ split2@^2.1.0: dependencies: through2 "^2.0.2" -split2@^3.1.1: - version "3.2.2" - resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f" - integrity sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg== - dependencies: - readable-stream "^3.0.0" - split@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9"