Skip to content

Commit

Permalink
Disable debug level logger for some actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm committed Jun 28, 2023
1 parent 4514587 commit 0aa32b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func EnableDebugMode() {
Debug("Enable verbose logging")
}

// DisableDebugMode method disables verbose logging.
func DisableDebugMode() {
isDebugMode = false
}

// Debug method logs message with "debug" level.
func Debug(a ...interface{}) {
if !IsDebugMode() {
Expand Down
2 changes: 2 additions & 0 deletions internal/packages/installer/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func NewForPackage(options Options) (Installer, error) {
return CreateForZip(options.Kibana, options.ZipPath)
}

logger.DisableDebugMode()
target, err := builder.BuildPackage(builder.BuildOptions{
PackageRoot: options.RootPath,
CreateZip: supportsZip,
Expand All @@ -79,6 +80,7 @@ func NewForPackage(options Options) (Installer, error) {
if err != nil {
return nil, fmt.Errorf("failed to build package: %v", err)
}
logger.EnableDebugMode()

if supportsZip {
return CreateForZip(options.Kibana, target)
Expand Down
2 changes: 2 additions & 0 deletions internal/testrunner/runners/system/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@ func (r *runner) run() (results []testrunner.TestResult, err error) {
}
defer os.RemoveAll(tempDir)

logger.DisableDebugMode()
dumpOptions := stack.DumpOptions{Output: tempDir, Profile: r.options.Profile}
_, err = stack.Dump(dumpOptions)
if err != nil {
return nil, fmt.Errorf("dump failed: %w", err)
}
logger.EnableDebugMode()

logResults, err := r.checkAgentLogs(dumpOptions, startTesting, errorPatterns)
if err != nil {
Expand Down

0 comments on commit 0aa32b2

Please sign in to comment.