mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-22 20:24:03 +02:00
fix: fatal and panic does not terminate the program
This commit is contained in:
parent
8363dfe257
commit
c8e9ed8440
1 changed files with 8 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
package gperr
|
package gperr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
"github.com/yusing/go-proxy/internal/common"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
|
@ -14,6 +16,12 @@ func log(msg string, err error, level zerolog.Level, logger ...*zerolog.Logger)
|
||||||
l = logging.GetLogger()
|
l = logging.GetLogger()
|
||||||
}
|
}
|
||||||
l.WithLevel(level).Msg(New(highlight(msg)).With(err).Error())
|
l.WithLevel(level).Msg(New(highlight(msg)).With(err).Error())
|
||||||
|
switch level {
|
||||||
|
case zerolog.FatalLevel:
|
||||||
|
os.Exit(1)
|
||||||
|
case zerolog.PanicLevel:
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogFatal(msg string, err error, logger ...*zerolog.Logger) {
|
func LogFatal(msg string, err error, logger ...*zerolog.Logger) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue