Skip to content

Commit

Permalink
Fix console color output on Windows (#5612)
Browse files Browse the repository at this point in the history
Closes #5611
  • Loading branch information
andrewkroh authored and exekias committed Nov 16, 2017
1 parent 7bf8d31 commit 51ed4eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Fix missing ACK in redis output. {issue}5404[5404]
- Change add_kubernetes_metadata to attempt detection of namespace. {pull}5482[5482]
- Avoid double slash when join url and path {pull}5517[5517]
- Fix console color output for Windows. {issue}5611[5611]

*Auditbeat*

Expand Down
7 changes: 7 additions & 0 deletions libbeat/testing/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"fmt"
"io"
"os"
"runtime"
"strings"

"github.com/fatih/color"
"github.com/mattn/go-colorable"
)

// ConsoleDriver outputs test result to the given stdout/stderr descriptors
Expand All @@ -26,6 +28,11 @@ func NewConsoleDriver(stdout io.Writer) *ConsoleDriver {
// NewConsoleDriverWithKiller initializes and returns a new console driver with output file
// Killer function will be called on fatal errors
func NewConsoleDriverWithKiller(stdout io.Writer, killer func()) *ConsoleDriver {
// On Windows we must wrap file outputs with a Colorable to achieve the right
// escape sequences.
if f, ok := stdout.(*os.File); ok && runtime.GOOS == "windows" {
stdout = colorable.NewColorable(f)
}
return &ConsoleDriver{
Stdout: stdout,
level: 0,
Expand Down

0 comments on commit 51ed4eb

Please sign in to comment.