defensive code
This commit is contained in:
+2
-1
@@ -64,7 +64,8 @@ func NewLogger(opts ...Option) Logger {
|
|||||||
} else if options.File != "" {
|
} else if options.File != "" {
|
||||||
f, err := os.OpenFile(options.File, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644)
|
f, err := os.OpenFile(options.File, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644)
|
||||||
if err != nil {
|
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)
|
logger = logger.Output(f)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user