Documentation ¶
Overview ¶
use function
Index ¶
- Constants
- Variables
- func AccessInfo(msg string, fields ...zap.Field)
- func AddIgnoreReqUri(uri ...string)
- func BizArchive(format string, params ...interface{})
- func Debug(params ...interface{})
- func Debugf(format string, params ...interface{})
- func Error(params ...interface{})
- func Errorf(format string, params ...interface{})
- func FlushLog()
- func GinLogger() gin.HandlerFunc
- func GrpcLogger() grpc.UnaryServerInterceptor
- func Info(params ...interface{})
- func Infof(format string, params ...interface{})
- func IsExist(path string) bool
- func Recover(v ...interface{})
- func Recoverf(format string, params ...interface{})
- func RpcInfo(params ...interface{})
- func RpcInfof(format string, params ...interface{})
- func SetLogPrintMaxReqParamLen(maxReqParamLen int)
- func SetLogPrintMaxRespLen(maxRespLen int)
- func SetLogRequestParam(ctx context.Context, body interface{})
- func Setup(projectName string, confPath string, defaultLogPath string, ...) error
- func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func Warn(params ...interface{})
- func Warnf(format string, params ...interface{})
- type Filter
- type LogConfig
- type Logger
- type LoggerConfig
Examples ¶
Constants ¶
View Source
const ( LOGID = "logId" REFERER = "referer" COOKIE = "cookie" CLIENT_IP = "client_ip" LOCAL_IP = "local_ip" MODULE = "module" UA = "ua" HOST = "host" URI = "uri" TRACE = "trace" NOTICES = "notice" MONITOR = "monitor" RESPONSE = "response" REQUEST = "request" CODE = "code" COST = "cost" METHOD = "method" ERR = "err" )
View Source
const (
REQUEST_PARAM_CTX = "REQUEST_PARAM_CTX"
)
Variables ¶
View Source
var ( LOCALIP = net.GetLocalIPv4() MaxRespLen = 0 MaxReqParamLen = 4096 IgnoreReqUris = make([]string, 0) )
Functions ¶
func AccessInfo ¶
Example ¶
fields := []zap.Field{ zap.String(LOGID, "123123"), zap.String(URI, "/source/get"), zap.String(REFERER, "www.google.com"), zap.Any(COOKIE, "cookie:1231"), zap.String(CLIENT_IP, "192.168.7.3"), zap.String(LOCAL_IP, LOCALIP), zap.String(UA, "web-chrome"), zap.String(HOST, "www.baidu.com"), zap.String(MODULE, "live"), zap.String("request_param", "a=1&b=2"), zap.String(NOTICES, "notices"), zap.String(MONITOR, "{'monitor':true}"), zap.Int(CODE, 200), zap.String(RESPONSE, "response"), zap.Int64(COST, 100), } AccessInfo("", fields...)
Output:
func BizArchive ¶
func BizArchive(format string, params ...interface{})
func FlushLog ¶
func FlushLog()
flush main, biz, access, panic, rpc log Sync flushes any buffered log entries.
func SetLogPrintMaxReqParamLen ¶
func SetLogPrintMaxReqParamLen(maxReqParamLen int)
func SetLogPrintMaxRespLen ¶
func SetLogPrintMaxRespLen(maxRespLen int)
func SetLogRequestParam ¶
func Setup ¶
func Setup(projectName string, confPath string, defaultLogPath string, traceLogger tapper.ITraceLog) error
setup log with those params: project name for tapper log log.json config path, default log path for log.json undefined log path tapper user defined trace log obj
Example ¶
err := Setup("testProject", "./", "./log", nil) if err != nil { println(err) } Example_Info() Example_Infof() ExampleAccessInfo()
Output:
func TimeEncoder ¶
func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
Types ¶
type LogConfig ¶
type LogConfig struct { Logs []LoggerConfig `json:"logs"` RotateByHour bool `json:"rotateByHour"` }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
from zap json_encoder.go change to encoder
|
from zap json_encoder.go change to encoder |
internal
|
|
bufferpool
Package bufferpool houses zap's shared internal buffer pool.
|
Package bufferpool houses zap's shared internal buffer pool. |
Click to show internal directories.
Click to hide internal directories.