Skip to content

Commit

Permalink
feat(core): add config to set default debug scopes
Browse files Browse the repository at this point in the history
You can set different scopes for both dev and prod environments
  • Loading branch information
rndlaine committed Mar 21, 2019
1 parent a1d4fce commit cecd983
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bp/core/botpress.ts
Expand Up @@ -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[]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions src/bp/core/config/botpress.config.ts
Expand Up @@ -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[]
}
}

/**
Expand Down

0 comments on commit cecd983

Please sign in to comment.