From 5758120eccf6b331d04b240fc386a8d41efdc00a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 2 May 2023 14:58:34 +0100 Subject: [PATCH 1/7] Minor updates to CLI - incrementing docker-compose version as per #10222 as well as a fix for prebuilds when using pkg version. --- packages/cli/package.json | 2 +- packages/cli/src/index.ts | 5 ++--- yarn.lock | 26 +++++++++++++------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 87f8885baa..6da00a3cbf 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -36,7 +36,7 @@ "chalk": "4.1.0", "cli-progress": "3.11.2", "commander": "7.1.0", - "docker-compose": "0.23.12", + "docker-compose": "0.24.0", "dotenv": "16.0.1", "download": "8.0.0", "find-free-port": "^2.0.0", diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index cca2c91862..47514835ed 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,9 +1,8 @@ #!/usr/bin/env node -import { logging } from "@budibase/backend-core" -logging.disableLogger() import "./prebuilds" import "./environment" -import { env } from "@budibase/backend-core" +import { env, logging } from "@budibase/backend-core" +logging.disableLogger() import { getCommands } from "./options" import { Command } from "commander" import { getHelpDescription } from "./utils" diff --git a/yarn.lock b/yarn.lock index 3b403d6444..559ee1eaa3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1486,15 +1486,15 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" -"@budibase/pro@2.5.6-alpha.41": - version "2.5.6-alpha.41" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.6-alpha.41.tgz#2632b398159211bf64bf6caff9753c877b6fc09d" - integrity sha512-8Zfm+RtcXY77gdXXHti8QT+Vt+1ApuVqYL3KCkxBVbpzgQci/F3mipNXUX8bEy/y+QYAdgn6psDTWAqyr9VALg== +"@budibase/pro@2.5.6-alpha.42": + version "2.5.6-alpha.42" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.6-alpha.42.tgz#15ec86d9918b7d58e3236240afda31309f3162ae" + integrity sha512-aes19IVAEGqf0YPLJMnOKHv99AR6LO8jMpPVCbSZcZODS3byxh9kC2+sWH1mAd781zymyN79HnwGrVJNOdV8jw== dependencies: - "@budibase/backend-core" "2.5.6-alpha.41" + "@budibase/backend-core" "2.5.6-alpha.42" "@budibase/shared-core" "2.4.44-alpha.1" "@budibase/string-templates" "2.4.44-alpha.1" - "@budibase/types" "2.5.6-alpha.41" + "@budibase/types" "2.5.6-alpha.42" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" @@ -9545,13 +9545,6 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -docker-compose@0.23.12: - version "0.23.12" - resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.23.12.tgz#fa883b98be08f6926143d06bf9e522ef7ed3210c" - integrity sha512-KFbSMqQBuHjTGZGmYDOCO0L4SaML3BsWTId5oSUyaBa22vALuFHNv+UdDWs3HcMylHWKsxCbLB7hnM/nCosWZw== - dependencies: - yaml "^1.10.2" - docker-compose@0.23.17: version "0.23.17" resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.23.17.tgz#8816bef82562d9417dc8c790aa4871350f93a2ba" @@ -9559,6 +9552,13 @@ docker-compose@0.23.17: dependencies: yaml "^1.10.2" +docker-compose@0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.24.0.tgz#474cd38b05b3887a56ffb2c39f16a7ae4d7d5077" + integrity sha512-RN/oSPLPa6ZG5e4dHg8tD8EMpd1WJqomNMBQT+d2M5MwcmfrPW/xHTent4TVqX0zZvHemv7qhhNlzXjxCnFaQw== + dependencies: + yaml "^1.10.2" + docker-compose@^0.23.5: version "0.23.19" resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.23.19.tgz#9947726e2fe67bdfa9e8efe1ff15aa0de2e10eb8" From cf2488cd351e3c32926a230393c7e1e17c947052 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 2 May 2023 14:42:41 +0000 Subject: [PATCH 2/7] v2.5.6-alpha.43 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 6 +++--- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 12 ++++++------ packages/frontend-core/package.json | 6 +++--- packages/sdk/package.json | 2 +- packages/server/package.json | 12 ++++++------ packages/shared-core/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lerna.json b/lerna.json index 5ad64883d4..20d6ead3ba 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "npmClient": "yarn", "useWorkspaces": true, "packages": ["packages/*"], diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 1302568db5..941b4639b8 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -24,7 +24,7 @@ "dependencies": { "@budibase/nano": "10.1.2", "@budibase/pouchdb-replication-stream": "1.2.10", - "@budibase/types": "2.5.6-alpha.42", + "@budibase/types": "2.5.6-alpha.43", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-cloudfront-sign": "2.2.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index ff82bbc2c4..318c2f3172 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,8 +38,8 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "1.2.1", - "@budibase/shared-core": "2.5.6-alpha.42", - "@budibase/string-templates": "2.5.6-alpha.42", + "@budibase/shared-core": "2.5.6-alpha.43", + "@budibase/string-templates": "2.5.6-alpha.43", "@spectrum-css/accordion": "3.0.24", "@spectrum-css/actionbutton": "1.0.1", "@spectrum-css/actiongroup": "1.0.1", diff --git a/packages/builder/package.json b/packages/builder/package.json index 0015174bcf..0fdbab0a67 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "license": "GPL-3.0", "private": true, "scripts": { @@ -58,10 +58,10 @@ } }, "dependencies": { - "@budibase/bbui": "2.5.6-alpha.42", - "@budibase/frontend-core": "2.5.6-alpha.42", - "@budibase/shared-core": "2.5.6-alpha.42", - "@budibase/string-templates": "2.5.6-alpha.42", + "@budibase/bbui": "2.5.6-alpha.43", + "@budibase/frontend-core": "2.5.6-alpha.43", + "@budibase/shared-core": "2.5.6-alpha.43", + "@budibase/string-templates": "2.5.6-alpha.43", "@fortawesome/fontawesome-svg-core": "^6.2.1", "@fortawesome/free-brands-svg-icons": "^6.2.1", "@fortawesome/free-solid-svg-icons": "^6.2.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 6da00a3cbf..4fe0ddc637 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "dist/index.js", "bin": { @@ -29,9 +29,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "2.5.6-alpha.42", - "@budibase/string-templates": "2.5.6-alpha.42", - "@budibase/types": "2.5.6-alpha.42", + "@budibase/backend-core": "2.5.6-alpha.43", + "@budibase/string-templates": "2.5.6-alpha.43", + "@budibase/types": "2.5.6-alpha.43", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 7ff0ddae9c..29b49c3105 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,11 +19,11 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "2.5.6-alpha.42", - "@budibase/frontend-core": "2.5.6-alpha.42", - "@budibase/shared-core": "2.5.6-alpha.42", - "@budibase/string-templates": "2.5.6-alpha.42", - "@budibase/types": "2.5.6-alpha.42", + "@budibase/bbui": "2.5.6-alpha.43", + "@budibase/frontend-core": "2.5.6-alpha.43", + "@budibase/shared-core": "2.5.6-alpha.43", + "@budibase/string-templates": "2.5.6-alpha.43", + "@budibase/types": "2.5.6-alpha.43", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index c0b60cb091..11cdfddfc9 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,13 +1,13 @@ { "name": "@budibase/frontend-core", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "2.5.6-alpha.42", - "@budibase/shared-core": "2.5.6-alpha.42", + "@budibase/bbui": "2.5.6-alpha.43", + "@budibase/shared-core": "2.5.6-alpha.43", "dayjs": "^1.11.7", "lodash": "^4.17.21", "socket.io-client": "^4.6.1", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 13cc20f9e9..9ab1a37fcb 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/sdk", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Budibase Public API SDK", "author": "Budibase", "license": "MPL-2.0", diff --git a/packages/server/package.json b/packages/server/package.json index cc8a8208dc..5e8f212055 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -45,12 +45,12 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "2.5.6-alpha.42", - "@budibase/client": "2.5.6-alpha.42", + "@budibase/backend-core": "2.5.6-alpha.43", + "@budibase/client": "2.5.6-alpha.43", "@budibase/pro": "2.5.6-alpha.42", - "@budibase/shared-core": "2.5.6-alpha.42", - "@budibase/string-templates": "2.5.6-alpha.42", - "@budibase/types": "2.5.6-alpha.42", + "@budibase/shared-core": "2.5.6-alpha.43", + "@budibase/string-templates": "2.5.6-alpha.43", + "@budibase/types": "2.5.6-alpha.43", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 4ea3deea5f..43ce16b9a6 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/shared-core", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Shared data utils", "main": "dist/cjs/src/index.js", "types": "dist/mjs/src/index.d.ts", @@ -20,7 +20,7 @@ "dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\"" }, "dependencies": { - "@budibase/types": "2.5.6-alpha.42" + "@budibase/types": "2.5.6-alpha.43" }, "devDependencies": { "concurrently": "^7.6.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index e1397182dc..0d0bbd2ef2 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 3068068d4c..929b82c172 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Budibase types", "main": "dist/cjs/index.js", "types": "dist/mjs/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index ae9358f084..5e3303f764 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "2.5.6-alpha.42", + "version": "2.5.6-alpha.43", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -37,10 +37,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "2.5.6-alpha.42", + "@budibase/backend-core": "2.5.6-alpha.43", "@budibase/pro": "2.5.6-alpha.42", - "@budibase/string-templates": "2.5.6-alpha.42", - "@budibase/types": "2.5.6-alpha.42", + "@budibase/string-templates": "2.5.6-alpha.43", + "@budibase/types": "2.5.6-alpha.43", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From 7d22394d6e6afdb2e0e5eb1893317ad6915aeea1 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 2 May 2023 14:44:15 +0000 Subject: [PATCH 3/7] Update pro version to 2.5.6-alpha.43 --- packages/server/package.json | 2 +- packages/worker/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 5e8f212055..74d6575b82 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -47,7 +47,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "2.5.6-alpha.43", "@budibase/client": "2.5.6-alpha.43", - "@budibase/pro": "2.5.6-alpha.42", + "@budibase/pro": "2.5.6-alpha.43", "@budibase/shared-core": "2.5.6-alpha.43", "@budibase/string-templates": "2.5.6-alpha.43", "@budibase/types": "2.5.6-alpha.43", diff --git a/packages/worker/package.json b/packages/worker/package.json index 5e3303f764..9f40685933 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -38,7 +38,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "2.5.6-alpha.43", - "@budibase/pro": "2.5.6-alpha.42", + "@budibase/pro": "2.5.6-alpha.43", "@budibase/string-templates": "2.5.6-alpha.43", "@budibase/types": "2.5.6-alpha.43", "@koa/router": "8.0.8", From 552499b781cabc533fced825c2744182b47fe0d4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 2 May 2023 16:22:43 +0100 Subject: [PATCH 4/7] Re-writing the disabling of pino/logging - it seems that the pino logger is causing a variety of issues in the built CLI version - easier to offer an environment variable for backend-core which completely removes the logger. --- packages/backend-core/src/environment.ts | 1 + packages/backend-core/src/logging/index.ts | 2 +- .../backend-core/src/logging/pino/logger.ts | 305 +++++++++--------- packages/cli/src/index.ts | 4 +- 4 files changed, 149 insertions(+), 163 deletions(-) diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index 0d413b8fa9..1bea1f3692 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -154,6 +154,7 @@ const environment = { ? process.env.ENABLE_SSO_MAINTENANCE_MODE : false, VERSION: findVersion(), + DISABLE_PINO_LOGGER: process.env.DISABLE_PINO_LOGGER, _set(key: any, value: any) { process.env[key] = value // @ts-ignore diff --git a/packages/backend-core/src/logging/index.ts b/packages/backend-core/src/logging/index.ts index b229f47dea..b87062c478 100644 --- a/packages/backend-core/src/logging/index.ts +++ b/packages/backend-core/src/logging/index.ts @@ -1,5 +1,5 @@ export * as correlation from "./correlation/correlation" -export { logger, disableLogger } from "./pino/logger" +export { logger } from "./pino/logger" export * from "./alerts" // turn off or on context logging i.e. tenantId, appId etc diff --git a/packages/backend-core/src/logging/pino/logger.ts b/packages/backend-core/src/logging/pino/logger.ts index dd4b505d30..8e0ed2a8fb 100644 --- a/packages/backend-core/src/logging/pino/logger.ts +++ b/packages/backend-core/src/logging/pino/logger.ts @@ -5,184 +5,169 @@ import * as correlation from "../correlation" import { IdentityType } from "@budibase/types" import { LOG_CONTEXT } from "../index" -// CORE LOGGERS - for disabling - -const BUILT_INS = { - log: console.log, - error: console.error, - info: console.info, - warn: console.warn, - trace: console.trace, - debug: console.debug, -} - // 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, +let pinoInstance: pino.Logger | undefined +if (!env.DISABLE_PINO_LOGGER) { + const pinoOptions: LoggerOptions = { + level: env.LOG_LEVEL, + formatters: { + level: label => { + return { level: label.toUpperCase() } + }, + bindings: () => { + return {} + }, }, + timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`, } -} -export const logger = pino(pinoOptions) + if (env.isDev()) { + pinoOptions.transport = { + target: "pino-pretty", + options: { + singleLine: true, + }, + } + } -export function disableLogger() { - console.log = BUILT_INS.log - console.error = BUILT_INS.error - console.info = BUILT_INS.info - console.warn = BUILT_INS.warn - console.trace = BUILT_INS.trace - console.debug = BUILT_INS.debug -} + pinoInstance = 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() - - let contextObject = {} - - if (LOG_CONTEXT) { - contextObject = { - tenantId: getTenantId(), - appId: getAppId(), - identityId: identity?._id, - identityType: identity?.type, - correlationId: correlation.getId(), - } + interface MergingObject { + objects?: any[] + tenantId?: string + appId?: string + identityId?: string + identityType?: IdentityType + correlationId?: string + err?: Error } - const mergingObject = { - objects: objects.length ? objects : undefined, - err: error, - ...contextObject, + function isPlainObject(obj: any) { + return typeof obj === "object" && obj !== null && !(obj instanceof 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() + function isError(obj: any) { + return obj instanceof Error } - logger.trace(obj, msg) -} -console.debug = (...arg: any) => { - const [obj, msg] = getLogParams(arg) - logger.debug(obj, msg) -} + 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() + + let contextObject = {} + + if (LOG_CONTEXT) { + contextObject = { + tenantId: getTenantId(), + appId: getAppId(), + identityId: identity?._id, + identityType: identity?.type, + correlationId: correlation.getId(), + } + } + + const mergingObject = { + objects: objects.length ? objects : undefined, + err: error, + ...contextObject, + } + + return [mergingObject, message] + } + + console.log = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + pinoInstance?.info(obj, msg) + } + console.info = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + pinoInstance?.info(obj, msg) + } + console.warn = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + pinoInstance?.warn(obj, msg) + } + console.error = (...arg: any[]) => { + const [obj, msg] = getLogParams(arg) + pinoInstance?.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() + } + pinoInstance?.trace(obj, msg) + } + + console.debug = (...arg: any) => { + const [obj, msg] = getLogParams(arg) + pinoInstance?.debug(obj, msg) + } // CONTEXT -const getTenantId = () => { - let tenantId - try { - tenantId = context.getTenantId() - } catch (e: any) { - // do nothing + 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 } - 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 const logger = pinoInstance diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 47514835ed..8082d3f0a0 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node +process.env.DISABLE_PINO_LOGGER = "1" import "./prebuilds" import "./environment" -import { env, logging } from "@budibase/backend-core" -logging.disableLogger() +import { env } from "@budibase/backend-core" import { getCommands } from "./options" import { Command } from "commander" import { getHelpDescription } from "./utils" From f61f9eba686f5852c10a7304007a6e80954602c3 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 2 May 2023 16:28:56 +0100 Subject: [PATCH 5/7] Linting. --- packages/backend-core/src/logging/pino/logger.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/src/logging/pino/logger.ts b/packages/backend-core/src/logging/pino/logger.ts index 8e0ed2a8fb..276377eb00 100644 --- a/packages/backend-core/src/logging/pino/logger.ts +++ b/packages/backend-core/src/logging/pino/logger.ts @@ -33,7 +33,7 @@ if (!env.DISABLE_PINO_LOGGER) { pinoInstance = pino(pinoOptions) -// CONSOLE OVERRIDES + // CONSOLE OVERRIDES interface MergingObject { objects?: any[] @@ -137,7 +137,7 @@ if (!env.DISABLE_PINO_LOGGER) { pinoInstance?.debug(obj, msg) } -// CONTEXT + // CONTEXT const getTenantId = () => { let tenantId From b911b04a039a7969376cf1a0da06558786af8eb4 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 2 May 2023 18:09:57 +0000 Subject: [PATCH 6/7] v2.5.6-alpha.44 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 6 +++--- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 12 ++++++------ packages/frontend-core/package.json | 6 +++--- packages/sdk/package.json | 2 +- packages/server/package.json | 12 ++++++------ packages/shared-core/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lerna.json b/lerna.json index 20d6ead3ba..3273f7bce7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "npmClient": "yarn", "useWorkspaces": true, "packages": ["packages/*"], diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 941b4639b8..e72abc9e9d 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -24,7 +24,7 @@ "dependencies": { "@budibase/nano": "10.1.2", "@budibase/pouchdb-replication-stream": "1.2.10", - "@budibase/types": "2.5.6-alpha.43", + "@budibase/types": "2.5.6-alpha.44", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-cloudfront-sign": "2.2.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 318c2f3172..68f0db5f73 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,8 +38,8 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "1.2.1", - "@budibase/shared-core": "2.5.6-alpha.43", - "@budibase/string-templates": "2.5.6-alpha.43", + "@budibase/shared-core": "2.5.6-alpha.44", + "@budibase/string-templates": "2.5.6-alpha.44", "@spectrum-css/accordion": "3.0.24", "@spectrum-css/actionbutton": "1.0.1", "@spectrum-css/actiongroup": "1.0.1", diff --git a/packages/builder/package.json b/packages/builder/package.json index 0fdbab0a67..e5434c14a2 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "license": "GPL-3.0", "private": true, "scripts": { @@ -58,10 +58,10 @@ } }, "dependencies": { - "@budibase/bbui": "2.5.6-alpha.43", - "@budibase/frontend-core": "2.5.6-alpha.43", - "@budibase/shared-core": "2.5.6-alpha.43", - "@budibase/string-templates": "2.5.6-alpha.43", + "@budibase/bbui": "2.5.6-alpha.44", + "@budibase/frontend-core": "2.5.6-alpha.44", + "@budibase/shared-core": "2.5.6-alpha.44", + "@budibase/string-templates": "2.5.6-alpha.44", "@fortawesome/fontawesome-svg-core": "^6.2.1", "@fortawesome/free-brands-svg-icons": "^6.2.1", "@fortawesome/free-solid-svg-icons": "^6.2.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 4fe0ddc637..1424fd7021 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "dist/index.js", "bin": { @@ -29,9 +29,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "2.5.6-alpha.43", - "@budibase/string-templates": "2.5.6-alpha.43", - "@budibase/types": "2.5.6-alpha.43", + "@budibase/backend-core": "2.5.6-alpha.44", + "@budibase/string-templates": "2.5.6-alpha.44", + "@budibase/types": "2.5.6-alpha.44", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 29b49c3105..19ba08c169 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,11 +19,11 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "2.5.6-alpha.43", - "@budibase/frontend-core": "2.5.6-alpha.43", - "@budibase/shared-core": "2.5.6-alpha.43", - "@budibase/string-templates": "2.5.6-alpha.43", - "@budibase/types": "2.5.6-alpha.43", + "@budibase/bbui": "2.5.6-alpha.44", + "@budibase/frontend-core": "2.5.6-alpha.44", + "@budibase/shared-core": "2.5.6-alpha.44", + "@budibase/string-templates": "2.5.6-alpha.44", + "@budibase/types": "2.5.6-alpha.44", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 11cdfddfc9..414aac562e 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,13 +1,13 @@ { "name": "@budibase/frontend-core", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "2.5.6-alpha.43", - "@budibase/shared-core": "2.5.6-alpha.43", + "@budibase/bbui": "2.5.6-alpha.44", + "@budibase/shared-core": "2.5.6-alpha.44", "dayjs": "^1.11.7", "lodash": "^4.17.21", "socket.io-client": "^4.6.1", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 9ab1a37fcb..618469354a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/sdk", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Budibase Public API SDK", "author": "Budibase", "license": "MPL-2.0", diff --git a/packages/server/package.json b/packages/server/package.json index 74d6575b82..1ea7b20752 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -45,12 +45,12 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "2.5.6-alpha.43", - "@budibase/client": "2.5.6-alpha.43", + "@budibase/backend-core": "2.5.6-alpha.44", + "@budibase/client": "2.5.6-alpha.44", "@budibase/pro": "2.5.6-alpha.43", - "@budibase/shared-core": "2.5.6-alpha.43", - "@budibase/string-templates": "2.5.6-alpha.43", - "@budibase/types": "2.5.6-alpha.43", + "@budibase/shared-core": "2.5.6-alpha.44", + "@budibase/string-templates": "2.5.6-alpha.44", + "@budibase/types": "2.5.6-alpha.44", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 43ce16b9a6..b4fa8ac9e5 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/shared-core", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Shared data utils", "main": "dist/cjs/src/index.js", "types": "dist/mjs/src/index.d.ts", @@ -20,7 +20,7 @@ "dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\"" }, "dependencies": { - "@budibase/types": "2.5.6-alpha.43" + "@budibase/types": "2.5.6-alpha.44" }, "devDependencies": { "concurrently": "^7.6.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 0d0bbd2ef2..4db78ef952 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 929b82c172..79a9b5d05c 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Budibase types", "main": "dist/cjs/index.js", "types": "dist/mjs/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 9f40685933..75eb339cd7 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "2.5.6-alpha.43", + "version": "2.5.6-alpha.44", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -37,10 +37,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "2.5.6-alpha.43", + "@budibase/backend-core": "2.5.6-alpha.44", "@budibase/pro": "2.5.6-alpha.43", - "@budibase/string-templates": "2.5.6-alpha.43", - "@budibase/types": "2.5.6-alpha.43", + "@budibase/string-templates": "2.5.6-alpha.44", + "@budibase/types": "2.5.6-alpha.44", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From ecff055b3e726958cd3031fd4b827639d05c2485 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 2 May 2023 18:11:31 +0000 Subject: [PATCH 7/7] Update pro version to 2.5.6-alpha.44 --- packages/server/package.json | 2 +- packages/worker/package.json | 2 +- yarn.lock | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 1ea7b20752..34569a9727 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -47,7 +47,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "2.5.6-alpha.44", "@budibase/client": "2.5.6-alpha.44", - "@budibase/pro": "2.5.6-alpha.43", + "@budibase/pro": "2.5.6-alpha.44", "@budibase/shared-core": "2.5.6-alpha.44", "@budibase/string-templates": "2.5.6-alpha.44", "@budibase/types": "2.5.6-alpha.44", diff --git a/packages/worker/package.json b/packages/worker/package.json index 75eb339cd7..7e6a9c5495 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -38,7 +38,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "2.5.6-alpha.44", - "@budibase/pro": "2.5.6-alpha.43", + "@budibase/pro": "2.5.6-alpha.44", "@budibase/string-templates": "2.5.6-alpha.44", "@budibase/types": "2.5.6-alpha.44", "@koa/router": "8.0.8", diff --git a/yarn.lock b/yarn.lock index 559ee1eaa3..815b155ff9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1486,15 +1486,15 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" -"@budibase/pro@2.5.6-alpha.42": - version "2.5.6-alpha.42" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.6-alpha.42.tgz#15ec86d9918b7d58e3236240afda31309f3162ae" - integrity sha512-aes19IVAEGqf0YPLJMnOKHv99AR6LO8jMpPVCbSZcZODS3byxh9kC2+sWH1mAd781zymyN79HnwGrVJNOdV8jw== +"@budibase/pro@2.5.6-alpha.43": + version "2.5.6-alpha.43" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.6-alpha.43.tgz#3273219bcb51c0dde75753d59b22698722aad673" + integrity sha512-xUU7wFLsRczmPoystg5PN4GPtks0leMrdQJpCA3hxGM09szSHEheGKRCH3fpXhwbYe8GRsJx+27xrVxkW4+9yQ== dependencies: - "@budibase/backend-core" "2.5.6-alpha.42" + "@budibase/backend-core" "2.5.6-alpha.43" "@budibase/shared-core" "2.4.44-alpha.1" "@budibase/string-templates" "2.4.44-alpha.1" - "@budibase/types" "2.5.6-alpha.42" + "@budibase/types" "2.5.6-alpha.43" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0"