util

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package util contains util helper functions used by servers which protoc-gen-grpc-gateway generates.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ease-gateway 请求和响应详情日志. 支持格式包括:
	// 1. RequestRestFormat
	// 2. ResponseRestFormat
	RestLogger = glog.Context(nil, glog.FileName{Name: "gateway-rest"})

	// request rest log format.
	// [request]traceId,serviceName,httpMethod,path,{reqInfo}
	// external {reqInfo}: source,client,appVersion,u:uid,c:cid,a:aid,d:did,remoteAddr,url
	// ldap {reqInfo}: remoteAddr,url
	RequestRestFormat = "[request]%s,%s,%s,%s,%s"

	// response rest log format.
	// [response]traceId,code,msg
	ResponseRestFormat = "[response]%s,%d,%s"
)

gateway-rest日志

View Source
var (
	// ease-gateway 访问统计日志. 支持格式包括:
	// 1. StatFormat
	StatLogger = glog.Context(nil, glog.FileName{Name: "gateway-stat"})

	// stat log format.
	// traceId,serviceName,httpMethod,path,client,ok:isSuccess,code,ms:response-ms
	StatFormat = "%s,%s,%s,%s,%s,ok:%s,%d,ms:%g"
)

gateway-stat日志

View Source
var (
	// gateway错误日志.
	ErrorLogger = glog.Context(nil, glog.FileName{Name: "gateway-error"})

	// error log format.
	ErrorFormat = "%s,%s"
)

gateway-error日志

View Source
var (
	// gateway限流日志.
	LimitLogger = glog.Context(nil, glog.FileName{Name: "gateway-limit"})

	// traceId[limit type]service,httpMethod,path,limitInfo.
	LimitFormat = "%s[%s]%s,%s,%s,%s"
)

gateway-limit日志

View Source
var (
	// gateway默认日志文件, 排除上面的剩下的日志.
	DefaultLogger = glog.Context(nil, glog.FileName{Name: "gateway-default"})

	// default log format.
	DefaultFormat = "%s,%s"
)

gateway-default日志

View Source
var (
	// ease-gateway 配置操作相关日志.
	ConfigLogger = glog.Context(nil, glog.FileName{Name: "gateway-config"})
)

gateway-config日志

Functions

func BufferWriteString

func BufferWriteString(args ...string) string

BufferWriteString method used to splice newline string

func CalPage

func CalPage(total uint64, pageSize int) int

CalPage 计算总页数.

func Flush

func Flush()

Flush be used to flush logs immediately.

func LogColorErrorf

func LogColorErrorf(logger *glog.Logger, format string, args ...interface{})

LogColorErrorf logs in colored format for ErrorLogger.

func LogColorInfof

func LogColorInfof(logger *glog.Logger, format string, args ...interface{})

LogColorInfof logs in colored format for RestLogger/ConfigLogger/StatLogger/ DefaultLogger.

func Logef

func Logef(logger *glog.Logger, format string, args ...interface{})

Logef is used to record format error logs for ErrorLogger.

func Logf

func Logf(logger *glog.Logger, format string, args ...interface{})

Logf is used to record format logs for RestLogger/ConfigLogger/ StatLogger/DefaultLogger.

func MsStamp

func MsStamp() int64

MsStamp 返回毫秒时间戳.

func Sha1

func Sha1(b []byte) string

Sha1 生成sha1加密串.

func VLogef

func VLogef(logger *glog.Logger, level int32, format string, args ...interface{})

VLogef is used to record format error logs for ErrorLogger guarded by the value of level.

func VLogf

func VLogf(logger *glog.Logger, level int32, format string, args ...interface{})

VLogf is used to record format logs for RestLogger/ConfigLogger/ StatLogger/DefaultLogger guarded by the value of level.

Types

This section is empty.

Directories

Path Synopsis
Package glog contains glog helper functions used by servers which protoc-gen-grpc-gateway generates.
Package glog contains glog helper functions used by servers which protoc-gen-grpc-gateway generates.
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL