From 03d14478a23d3d4b3a5558eccd1b195c1c869ac6 Mon Sep 17 00:00:00 2001 From: Matias Lahti Date: Fri, 20 Mar 2015 17:01:36 +0200 Subject: [PATCH] handle stderr stat() throwing an error on Windows --- gnatsd.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gnatsd.go b/gnatsd.go index 5ae8ae2a..14a70778 100644 --- a/gnatsd.go +++ b/gnatsd.go @@ -135,8 +135,9 @@ func configureLogger(s *server.Server, opts *server.Options) { } else { colors := true // Check to see if stderr is being redirected and if so turn off color - stat, _ := os.Stderr.Stat() - if (stat.Mode() & os.ModeCharDevice) == 0 { + // Also turn off colors if we're running on Windows where os.Stderr.Stat() returns an invalid handle-error + stat, err := os.Stderr.Stat() + if err != nil || (stat.Mode()&os.ModeCharDevice) == 0 { colors = false } log = logger.NewStdLogger(opts.Logtime, opts.Debug, opts.Trace, colors, true)