mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
chore: update risefront
with log handler
This commit is contained in:
parent
e9c698771e
commit
1a21c8406a
3 changed files with 27 additions and 9 deletions
32
main.go
32
main.go
|
@ -110,15 +110,31 @@ func main() {
|
|||
Run: Program(ctx, confPath),
|
||||
Name: "nginx-ui",
|
||||
Addresses: []string{fmt.Sprintf("%s:%d", cSettings.ServerSettings.Host, cSettings.ServerSettings.Port)},
|
||||
ErrorHandler: func(kind string, err error) {
|
||||
if errors.Is(err, net.ErrClosed) {
|
||||
return
|
||||
LogHandler: func(loglevel risefront.LogLevel, kind string, args ...interface{}) {
|
||||
switch loglevel {
|
||||
case risefront.DebugLevel:
|
||||
logger.Debugf(kind, args...)
|
||||
case risefront.InfoLevel:
|
||||
logger.Infof(kind, args...)
|
||||
case risefront.WarnLevel:
|
||||
logger.Warnf(kind, args...)
|
||||
case risefront.ErrorLevel:
|
||||
switch args[0].(type) {
|
||||
case error:
|
||||
if errors.Is(args[0].(error), net.ErrClosed) {
|
||||
return
|
||||
}
|
||||
logger.Errorf(kind, fmt.Errorf("%v", args[0].(error)))
|
||||
default:
|
||||
logger.Errorf(kind, args...)
|
||||
}
|
||||
case risefront.FatalLevel:
|
||||
logger.Fatalf(kind, args...)
|
||||
case risefront.PanicLevel:
|
||||
logger.Panicf(kind, args...)
|
||||
default:
|
||||
logger.Errorf(kind, args...)
|
||||
}
|
||||
logger.Error(kind, err)
|
||||
},
|
||||
LogHandler: func(logLevel risefront.LogLevel, kind string, args ...any) {
|
||||
args = append([]any{kind}, args...)
|
||||
logger.Info(args...)
|
||||
},
|
||||
})
|
||||
if err != nil && !errors.Is(err, context.DeadlineExceeded) &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue