mirror of
https://github.com/grafana/grafana.git
synced 2025-09-20 05:02:31 +08:00
style(dataproxy): renames log functions
This commit is contained in:
@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
auditLogger log.Logger = log.New("data-proxy-log")
|
dataproxyLogger log.Logger = log.New("data-proxy-log")
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewReverseProxy(ds *m.DataSource, proxyPath string, targetUrl *url.URL) *httputil.ReverseProxy {
|
func NewReverseProxy(ds *m.DataSource, proxyPath string, targetUrl *url.URL) *httputil.ReverseProxy {
|
||||||
@ -129,14 +129,15 @@ func ProxyDataSourceRequest(c *middleware.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyLog(ds.Type, c)
|
logProxyRequest(ds.Type, c)
|
||||||
|
|
||||||
proxy.ServeHTTP(c.Resp, c.Req.Request)
|
proxy.ServeHTTP(c.Resp, c.Req.Request)
|
||||||
c.Resp.Header().Del("Set-Cookie")
|
c.Resp.Header().Del("Set-Cookie")
|
||||||
}
|
}
|
||||||
|
|
||||||
func proxyLog(dataSourceType string, c *middleware.Context) {
|
func logProxyRequest(dataSourceType string, c *middleware.Context) {
|
||||||
if setting.DataProxyLogging {
|
if !setting.DataProxyLogging {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var body string
|
var body string
|
||||||
if c.Req.Request.Body != nil {
|
if c.Req.Request.Body != nil {
|
||||||
@ -144,14 +145,14 @@ func proxyLog(dataSourceType string, c *middleware.Context) {
|
|||||||
c.Req.Request.Body = ioutil.NopCloser(bytes.NewBuffer(buffer))
|
c.Req.Request.Body = ioutil.NopCloser(bytes.NewBuffer(buffer))
|
||||||
body = string(buffer)
|
body = string(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
auditLogger.Info("Proxying incoming request",
|
|
||||||
"userid", c.UserId,
|
|
||||||
"orgid", c.OrgId,
|
|
||||||
"username", c.Login,
|
|
||||||
"datasource", dataSourceType,
|
|
||||||
"uri", c.Req.RequestURI,
|
|
||||||
"method", c.Req.Request.Method,
|
|
||||||
"body", body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataproxyLogger.Info("Proxying incoming request",
|
||||||
|
"userid", c.UserId,
|
||||||
|
"orgid", c.OrgId,
|
||||||
|
"username", c.Login,
|
||||||
|
"datasource", dataSourceType,
|
||||||
|
"uri", c.Req.RequestURI,
|
||||||
|
"method", c.Req.Request.Method,
|
||||||
|
"body", body)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user