From cecd983ab0ad23747d72d9a1fa5a2442394a9abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renaud=20Lain=C3=A9?= Date: Thu, 21 Mar 2019 14:17:33 -0400 Subject: [PATCH] feat(core): add config to set default debug scopes You can set different scopes for both dev and prod environments --- src/bp/core/botpress.ts | 12 ++++++++++++ src/bp/core/config/botpress.config.ts | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/bp/core/botpress.ts b/src/bp/core/botpress.ts index bfe665973cc..100fe388832 100644 --- a/src/bp/core/botpress.ts +++ b/src/bp/core/botpress.ts @@ -39,6 +39,7 @@ import { DataRetentionService } from './services/retention/service' import { WorkspaceService } from './services/workspace-service' import { Statistics } from './stats' import { TYPES } from './types' +import { setDebugScopes } from '../debug' export type StartOptions = { modules: sdk.ModuleEntryPoint[] @@ -107,6 +108,7 @@ export class Botpress { await AppLifecycle.setDone(AppLifecycleEvents.CONFIGURATION_LOADED) + this.setDebugScopes() await this.checkJwtSecret() await this.checkEditionRequirements() await this.loadModules(options.modules) @@ -200,6 +202,16 @@ export class Botpress { await this.ghostService.global().sync() } + private setDebugScopes() { + if (!this.config) { + return + } + + const debugConfig = this.config.logs.debugScope + const debugScopes = process.env.IS_PRODUCTION ? debugConfig.prod : debugConfig.dev + setDebugScopes(debugScopes.join(',')) + } + private async initializeServices() { await this.loggerDbPersister.initialize(this.database, await this.loggerProvider('LogDbPersister')) this.loggerDbPersister.start() diff --git a/src/bp/core/config/botpress.config.ts b/src/bp/core/config/botpress.config.ts index 608017cd690..45c55c5a1d7 100644 --- a/src/bp/core/config/botpress.config.ts +++ b/src/bp/core/config/botpress.config.ts @@ -64,6 +64,19 @@ export interface LogsConfig { */ maxFileSize: number } + + /** + * The default debug scope per environment. + * @example ["bp:dialog*", "bp:nlu:intents*"] + */ + debugScope: { + /** + * The default debug scopes for the development environment + * @default ["bp:dialog*", "bp:nlu:intents*"] + */ + dev: string[] + prod: string[] + } } /**