https://github.com/hantmac/beegoaccesslog
Baseed on beego/logs implete Nginx-like access log format
https://github.com/hantmac/beegoaccesslog
Last synced: 3 months ago
JSON representation
Baseed on beego/logs implete Nginx-like access log format
- Host: GitHub
- URL: https://github.com/hantmac/beegoaccesslog
- Owner: hantmac
- License: mit
- Created: 2019-01-04T12:47:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-04T13:16:31.000Z (over 6 years ago)
- Last Synced: 2025-01-18T10:27:32.984Z (5 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BeegoAccessLog
Baseed on beego/logs implete Nginx-like access log format
# How to use?
- If you use beego, and you want to log some params like request host,request ip, user-agent and request method,statusCode,etc..
this package is for you.
- In functions of controller , use the folowing code:
```
type TestController struct {
beego.Controller
}
func (this *TestController) GetAll() {
beginTime := h.GetString("beginTime")beegoInput := this.Ctx.Request
ss,err := models.GetAllThings(limit,offset,beginTime)
if err != nil {
this.Data["json"] = err
ss.Base.StatusCode = 404
ss.Base.Success = false
accessLog := BeegoAccessLog.FormatAccessLog(int64(ss.Base.StatusCode),beegoInput)
beego.Debug(accessLog)
}
accessLog := BeegoAccessLog.FormatAccessLog(int64(ss.Base.StatusCode),beegoInput)
beego.Debug(accessLog)}
```