Skip to content

Commit b8cfd93

Browse files
committed
fix: logging middleware context
1 parent 1626c61 commit b8cfd93

File tree

17 files changed

+884
-752
lines changed

17 files changed

+884
-752
lines changed

api/audit/middleware.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package audit
2+
3+
import (
4+
"github.com/0xJacky/Nginx-UI/model"
5+
"github.com/gin-gonic/gin"
6+
"github.com/spf13/cast"
7+
"github.com/uozi-tech/cosy/logger"
8+
)
9+
10+
func LoggingMiddleware() gin.HandlerFunc {
11+
return logger.AuditMiddleware(func(c *gin.Context, logMap map[string]string) {
12+
var userId uint64
13+
if user, ok := c.Get("user"); ok {
14+
userId = user.(*model.User).ID
15+
}
16+
logMap["user_id"] = cast.ToString(userId)
17+
})
18+
}

api/certificate/certificate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/go-acme/lego/v4/certcrypto"
1515
"github.com/spf13/cast"
1616
"github.com/uozi-tech/cosy"
17+
"github.com/uozi-tech/cosy/logger"
1718
)
1819

1920
type APICertificate struct {
@@ -57,6 +58,8 @@ func Transformer(certModel *model.Cert) (certificate *APICertificate) {
5758
}
5859

5960
func GetCertList(c *gin.Context) {
61+
s := logger.NewSessionLogger(c)
62+
s.Info("GetCertList")
6063
cosy.Core[model.Cert](c).SetFussy("name", "domain").
6164
SetTransformer(func(m *model.Cert) any {
6265
info, _ := cert.GetCertInfo(m.SSLCertificatePath)

api/nginx_log/advanced_indexing_settings.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package nginx_log
33
import (
44
"net/http"
55

6+
"github.com/0xJacky/Nginx-UI/internal/kernel"
7+
"github.com/0xJacky/Nginx-UI/internal/nginx_log"
68
"github.com/0xJacky/Nginx-UI/settings"
79
"github.com/gin-gonic/gin"
810
"github.com/uozi-tech/cosy"
@@ -18,6 +20,9 @@ func EnableAdvancedIndexing(c *gin.Context) {
1820
return
1921
}
2022

23+
// Start the nginx_log services
24+
nginx_log.InitializeModernServices(kernel.Context)
25+
2126
c.JSON(http.StatusOK, gin.H{
2227
"message": "Advanced indexing enabled successfully",
2328
})
@@ -33,6 +38,9 @@ func DisableAdvancedIndexing(c *gin.Context) {
3338
return
3439
}
3540

41+
// Stop the nginx_log services
42+
nginx_log.StopModernServices()
43+
3644
c.JSON(http.StatusOK, gin.H{
3745
"message": "Advanced indexing disabled successfully",
3846
})

app/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@fingerprintjs/fingerprintjs": "^4.6.2",
1919
"@formkit/auto-animate": "^0.8.4",
2020
"@simplewebauthn/browser": "^13.1.2",
21-
"@uozi-admin/curd": "^4.15.5",
21+
"@uozi-admin/curd": "^4.15.8",
2222
"@uozi-admin/request": "^2.8.4",
2323
"@vue/reactivity": "^3.5.21",
2424
"@vue/shared": "^3.5.21",
@@ -30,7 +30,7 @@
3030
"@xterm/addon-fit": "^0.10.0",
3131
"@xterm/xterm": "^5.5.0",
3232
"ant-design-vue": "^4.2.6",
33-
"apexcharts": "^5.3.4",
33+
"apexcharts": "^5.3.5",
3434
"axios": "^1.11.0",
3535
"dayjs": "^1.11.18",
3636
"echarts": "^6.0.0",
@@ -48,7 +48,7 @@
4848
"splitpanes": "^4.0.4",
4949
"sse.js": "^2.7.0",
5050
"universal-cookie": "^8.0.1",
51-
"unocss": "^66.5.0",
51+
"unocss": "^66.5.1",
5252
"uuid": "^11.1.0",
5353
"vite-plugin-build-id": "0.5.0",
5454
"vue": "^3.5.21",
@@ -62,7 +62,7 @@
6262
"vuedraggable": "^4.1.0"
6363
},
6464
"devDependencies": {
65-
"@antfu/eslint-config": "^5.2.2",
65+
"@antfu/eslint-config": "^5.3.0",
6666
"@iconify-json/fa": "1.2.2",
6767
"@iconify-json/tabler": "^1.2.22",
6868
"@iconify/tools": "^4.1.2",
@@ -87,7 +87,7 @@
8787
"unplugin-auto-import": "^20.1.0",
8888
"unplugin-vue-components": "^29.0.0",
8989
"unplugin-vue-define-options": "^1.5.5",
90-
"vite": "^7.1.4",
90+
"vite": "^7.1.5",
9191
"vite-plugin-inspect": "^11.3.3",
9292
"vite-svg-loader": "^5.1.0",
9393
"vue-tsc": "^3.0.6"

0 commit comments

Comments
 (0)