log.go 974 字节
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5
package alert

import (
	"strconv"

黄孟柱 已提交
6
	log "github.com/eolinker/goku-api-gateway/goku-log"
E
eoLinker API Management 已提交
7 8
)

Y
Your Name 已提交
9
//AlertLog 记录告警日志
E
eoLinker API Management 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
func AlertLog(requestURL, targetServer, targetURL, requestMethod, proxyMethod, headerList, queryParamList, formParamList, responseHeaderList string, responseStatus int, host, strategyID, strategyName, requestID string) {

	fields := log.Fields{
		"request_id":          requestID,
		"strategy_name":       strategyName,
		"strategy_id":         strategyID,
		"node_host":           host,
		"request_method":      requestMethod,
		"request_url":         requestURL,
		"target_method":       proxyMethod,
		"target_server":       targetServer,
		"target_url":          targetURL,
		"request_query":       queryParamList,
		"request_header":      headerList,
		"request_form_param":  formParamList,
		"response_statusCode": strconv.Itoa(responseStatus),
		"response_header":     responseHeaderList,
	}

	log.WithFields(fields).Warning("alert")

	return
}