refactor: improve variable naming in nginx log filtering functions and enhance error message clarity

This commit is contained in:
Jacky 2025-04-02 11:13:10 +00:00
parent 56f4e5b87f
commit 7a9b7d552d
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
2 changed files with 7 additions and 7 deletions

View file

@ -129,20 +129,20 @@ func GetLogList(c *gin.Context) {
filters := []func(*cache.NginxLogCache) bool{}
if c.Query("type") != "" {
filters = append(filters, func(cache *cache.NginxLogCache) bool {
return cache.Type == c.Query("type")
filters = append(filters, func(entry *cache.NginxLogCache) bool {
return entry.Type == c.Query("type")
})
}
if c.Query("name") != "" {
filters = append(filters, func(cache *cache.NginxLogCache) bool {
return strings.Contains(cache.Name, c.Query("name"))
filters = append(filters, func(entry *cache.NginxLogCache) bool {
return strings.Contains(entry.Name, c.Query("name"))
})
}
if c.Query("path") != "" {
filters = append(filters, func(cache *cache.NginxLogCache) bool {
return strings.Contains(cache.Path, c.Query("path"))
filters = append(filters, func(entry *cache.NginxLogCache) bool {
return strings.Contains(entry.Path, c.Query("path"))
})
}

View file

@ -83,7 +83,7 @@ func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan ch
stat, err := os.Stat(logPath)
if os.IsNotExist(err) {
errChan <- errors.New("[error] log path not exists " + logPath)
errChan <- errors.New("[error] Log path does not exist: " + logPath)
return
}