mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
feat(logging): add LogHandler for structured logging and improve error handling in getLatestRelease
This commit is contained in:
parent
5c2621aaa6
commit
f4b32d9538
2 changed files with 6 additions and 0 deletions
|
@ -44,6 +44,8 @@ func (t *TRelease) GetAssetsMap() (m map[string]TReleaseAsset) {
|
|||
func getLatestRelease() (data TRelease, err error) {
|
||||
resp, err := http.Get(GetGithubLatestReleaseAPIUrl())
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "service.getLatestRelease http.Get err")
|
||||
return
|
||||
}
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
|
|
4
main.go
4
main.go
|
@ -116,6 +116,10 @@ func main() {
|
|||
}
|
||||
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) &&
|
||||
!errors.Is(err, context.Canceled) &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue