diff --git a/config/config.go b/config/config.go index ef0419a8..f9a09556 100644 --- a/config/config.go +++ b/config/config.go @@ -89,6 +89,7 @@ func SetConfigFilePath(path string) { filePath = path } func SetLogLevels() { + log.SetLogLevel("application", int(GetUint64("logApplication"))) log.SetLogLevel("backup", int(GetUint64("logBackup"))) log.SetLogLevel("cache", int(GetUint64("logCache"))) log.SetLogLevel("csv", int(GetUint64("logCsv"))) diff --git a/log/log.go b/log/log.go index 5842cf88..6a103d8d 100644 --- a/log/log.go +++ b/log/log.go @@ -18,18 +18,20 @@ var ( // log levels contextLevel = map[string]int{ - "backup": 1, - "cache": 1, - "csv": 1, - "mail": 1, - "ldap": 1, - "scheduler": 1, - "server": 1, - "transfer": 1, + "application": 1, + "backup": 1, + "cache": 1, + "csv": 1, + "mail": 1, + "ldap": 1, + "scheduler": 1, + "server": 1, + "transfer": 1, } ) -func Get(dateFrom pgtype.Int8, dateTo pgtype.Int8, limit int, offset int, byString string) ([]types.Log, int, error) { +func Get(dateFrom pgtype.Int8, dateTo pgtype.Int8, limit int, offset int, + context string, byString string) ([]types.Log, int, error) { logs := make([]types.Log, 0) total := 0 @@ -40,11 +42,15 @@ func Get(dateFrom pgtype.Int8, dateTo pgtype.Int8, limit int, offset int, byStri qb.Set("FROM", "instance.log AS l") qb.Add("JOIN", "LEFT JOIN app.module AS m ON m.id = l.module_id") + if context != "" { + qb.Add("WHERE", `l.context::TEXT = {CONTEXT}`) + qb.AddPara("{CONTEXT}", context) + } + if byString != "" { qb.Add("WHERE", `( - l.context::TEXT ILIKE {NAME} OR - l.message ILIKE {NAME} OR - m.name ILIKE {NAME} + l.message ILIKE {NAME} OR + m.name ILIKE {NAME} )`) qb.AddPara("{NAME}", fmt.Sprintf("%%%s%%", byString)) } diff --git a/request/request_log.go b/request/request_log.go index 81ae8002..2ccc8e2c 100644 --- a/request/request_log.go +++ b/request/request_log.go @@ -14,6 +14,7 @@ func LogGet(reqJson json.RawMessage) (interface{}, error) { err error req struct { ByString string `json:"byString"` + Context string `json:"context"` DateFrom pgtype.Int8 `json:"dateFrom"` DateTo pgtype.Int8 `json:"dateTo"` Limit int `json:"limit"` @@ -28,8 +29,8 @@ func LogGet(reqJson json.RawMessage) (interface{}, error) { if err := json.Unmarshal(reqJson, &req); err != nil { return nil, err } - res.Logs, res.Total, err = log.Get(req.DateFrom, - req.DateTo, req.Limit, req.Offset, req.ByString) + res.Logs, res.Total, err = log.Get(req.DateFrom, req.DateTo, + req.Limit, req.Offset, req.Context, req.ByString) if err != nil { return nil, err diff --git a/www/comps/admin/adminLogs.js b/www/comps/admin/adminLogs.js index e5d49411..64a16746 100644 --- a/www/comps/admin/adminLogs.js +++ b/www/comps/admin/adminLogs.js @@ -38,6 +38,18 @@ let MyAdminLogs = { :offset="offset" :total="total" /> +