-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
Hi folks,
I am using hclog
in a project and instantiate the logger with a custom io.Writer
, which should be fine according to the struct:
Line 246 in fb16e2d
Output io.Writer |
If ColorOption
is set to AutoColor
, we get only a collored output, if Output
from the previous line is a true io.File
Lines 273 to 275 in fb16e2d
// Color the output. On Windows, colored logs are only available for io.Writers that | |
// are concretely instances of *os.File. | |
Color ColorOption |
But, if Output
is not an io.File
, hclog
panics, instead of a fail-safe operation and omitting colouring.
Line 20 in fb16e2d
fi := l.checkWriterIsFile() |
Lines 879 to 887 in fb16e2d
// checks if the underlying io.Writer is a file, and | |
// panics if not. For use by colorization. | |
func (l *intLogger) checkWriterIsFile() *os.File { | |
fi, ok := l.writer.w.(*os.File) | |
if !ok { | |
panic("Cannot enable coloring of non-file Writers") | |
} | |
return fi | |
} |
As a fail-safe option, we can always switch to ColorOff
, instead of panic.
Line 83 in fb16e2d
ColorOff ColorOption = iota |
Or, might i miss something?
Metadata
Metadata
Assignees
Labels
No labels