chore: update risefront with log handler

This commit is contained in:
Hintay 2025-05-06 23:20:32 +09:00
parent e9c698771e
commit 1a21c8406a
No known key found for this signature in database
GPG key ID: 120FC7FF121F2F2D
3 changed files with 27 additions and 9 deletions

2
go.mod
View file

@ -313,7 +313,7 @@ require (
) )
replace ( replace (
code.pfad.fr/risefront => github.com/nginxui/risefront v1.2.1 code.pfad.fr/risefront => github.com/nginxui/risefront v1.2.2
github.com/tufanbarisyildirim/gonginx => github.com/0xJacky/gonginx v0.0.0-20250420001451-d120448e89a4 github.com/tufanbarisyildirim/gonginx => github.com/0xJacky/gonginx v0.0.0-20250420001451-d120448e89a4
gorm.io/gorm => gorm.io/gorm v1.25.12 gorm.io/gorm => gorm.io/gorm v1.25.12
gorm.io/plugin/dbresolver => gorm.io/plugin/dbresolver v1.5.3 gorm.io/plugin/dbresolver => gorm.io/plugin/dbresolver v1.5.3

2
go.sum
View file

@ -1522,6 +1522,8 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/nginxui/risefront v1.2.1 h1:CXu4c+bM6iBRVZHXQTUy9ceQa2p3YqIPNEdTPeCjIQ0= github.com/nginxui/risefront v1.2.1 h1:CXu4c+bM6iBRVZHXQTUy9ceQa2p3YqIPNEdTPeCjIQ0=
github.com/nginxui/risefront v1.2.1/go.mod h1:QX3OyvazX3Mi/X2NZKl9ylDrFVUeaogwSMKyEsnRCHE= github.com/nginxui/risefront v1.2.1/go.mod h1:QX3OyvazX3Mi/X2NZKl9ylDrFVUeaogwSMKyEsnRCHE=
github.com/nginxui/risefront v1.2.2 h1:mcKWv+2DnZBC97IwqWQQOXrTvqVWHWGCOEvjdM8Zv8o=
github.com/nginxui/risefront v1.2.2/go.mod h1:QX3OyvazX3Mi/X2NZKl9ylDrFVUeaogwSMKyEsnRCHE=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nikoksr/notify v1.3.0 h1:UxzfxzAYGQD9a5JYLBTVx0lFMxeHCke3rPCkfWdPgLs= github.com/nikoksr/notify v1.3.0 h1:UxzfxzAYGQD9a5JYLBTVx0lFMxeHCke3rPCkfWdPgLs=
github.com/nikoksr/notify v1.3.0/go.mod h1:Xor2hMmkvrCfkCKvXGbcrESez4brac2zQjhd6U2BbeM= github.com/nikoksr/notify v1.3.0/go.mod h1:Xor2hMmkvrCfkCKvXGbcrESez4brac2zQjhd6U2BbeM=

32
main.go
View file

@ -110,15 +110,31 @@ func main() {
Run: Program(ctx, confPath), Run: Program(ctx, confPath),
Name: "nginx-ui", Name: "nginx-ui",
Addresses: []string{fmt.Sprintf("%s:%d", cSettings.ServerSettings.Host, cSettings.ServerSettings.Port)}, Addresses: []string{fmt.Sprintf("%s:%d", cSettings.ServerSettings.Host, cSettings.ServerSettings.Port)},
ErrorHandler: func(kind string, err error) { LogHandler: func(loglevel risefront.LogLevel, kind string, args ...interface{}) {
if errors.Is(err, net.ErrClosed) { switch loglevel {
return 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) && if err != nil && !errors.Is(err, context.DeadlineExceeded) &&