defensive code

This commit is contained in:
A.Unger
2021-03-17 15:59:05 +01:00
parent fa27def950
commit 9c6e8d7bf3

View File

@@ -64,7 +64,8 @@ func NewLogger(opts ...Option) Logger {
} else if options.File != "" {
f, err := os.OpenFile(options.File, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644)
if err != nil {
panic(err)
print(fmt.Sprintf("file could not be opened for writing: %s. error: %v", options.File, err))
os.Exit(1)
}
logger = logger.Output(f)
} else {