Documentation
¶
Index ¶
- Constants
- Variables
- func CaptureStdout(f func()) ([]string, error)
- func DefaultEncoderConfig(WithStack bool) zapcore.EncoderConfig
- func DefaultParseTime(value string) (time.Time, error)
- func DiffDay(t1, t2 time.Time) int
- func DiffDayWithLayout(t1, t2 string, layout string) (int, error)
- func Error(logger *zap.SugaredLogger, err error)
- func FilterMethod(filterMethods []string, method string) bool
- func FilterURL(filterURLs []string, url string) bool
- func GetDayStartAndLatest(day time.Time) (time.Time, time.Time)
- func GetEnv(key, fallback string) string
- func JSONMarshal(v interface{}) ([]byte, error)
- func MarshalJSON(msg interface{}) ([]byte, error)
- func MarshalParam(v interface{}) string
- func MaxRuneCount(maxLen int) func(s string) error
- func NewApmSpan(ctx context.Context, name, spanType string) *apm.Span
- func NewServerSkywalkingHTTPMiddleware(tracer *go2sky.Tracer, opts ...func(*handler)) (func(http.Handler) http.Handler, error)
- func NewUUID() string
- func NewUnaryClientSkywalkingInterceptor(tracer *go2sky.Tracer) grpc.UnaryClientInterceptor
- func NewUnaryServerAccessLogInterceptor(logger *zap.SugaredLogger, apmTracer *apm.Tracer) grpc.UnaryServerInterceptor
- func NewUnaryServerSkywalkingInterceptor(tracer *go2sky.Tracer, opts ...Option) grpc.UnaryServerInterceptor
- func Param(param []byte) string
- func ParseTime(layout string, value string) (time.Time, error)
- func SetServiceName(name string)
- func SetTrace(ctx context.Context, name string, apmTracer *apm.Tracer) context.Context
- func SpanIDFromContext(ctx context.Context) string
- func Time(year int, month time.Month, day, hour, min int) time.Time
- func Tomorrow() time.Time
- func TraceIDFromContext(ctx context.Context) string
- func Track(logger *zap.SugaredLogger, message interface{})
- func TrackEncoderConfig() zapcore.EncoderConfig
- func WithExtraTags(tags map[string]string) func(*handler)
- func WithFilterMethod(methods []string) func(*options)
- func WithFilterURL(urls []string) func(*handler)
- func WithOperation(operation operation) func(*handler)
- func WithReportTags(tags []string) func(*options)
- func Yesterday() time.Time
- type AccessLog
- type BaseMixin
- type BaseSchema
- type CodeError
- type GetExtraField
- type LogType
- type Logger
- type LoggerOpt
- type Option
- type Period
- type RequestLog
- type UnionLog
- func (l UnionLog) Error(ctx context.Context, logger *zap.SugaredLogger, err error)
- func (l UnionLog) Errorf(ctx context.Context, logger *zap.SugaredLogger, template string, ...)
- func (l UnionLog) GetExtraFields(ctx context.Context, baseInfo []interface{}) []interface{}
- func (l UnionLog) Log(ctx context.Context, logger *zap.SugaredLogger)
- func (l UnionLog) Track(ctx context.Context, logger *zap.SugaredLogger, msg interface{})
- func (l UnionLog) Trackf(ctx context.Context, logger *zap.SugaredLogger, template string, ...)
- type ZError
- type ZErrorOption
Constants ¶
View Source
const ( ReqTag = "[请求参数]" RespTag = "[响应结果]" HTTP2Protocol = "HTTP/2" LocalHost = "127.0.0.1" ComponentIDGrpcClient = 5013 ComponentIDGrpcGo = 23 )
View Source
const ( // DateLayout 日期序列化. DateLayout = "2006-01-02" // DateTimeLayout 时间序列化 DateTimeLayout = "2006-01-02T15:04:05" // DateTimeLayoutWithoutT 没有T的时间序列化 // Deprecated DateTimeLayoutWithoutT = ISO8601Local // DateTimeLayoutChinese 中文时间序列化 DateTimeLayoutChinese = "2006年01月02日 15时04分05秒" // ISO8601Local 本地ISO8601日期序列化. ISO8601Local = "2006-01-02 15:04:05" )
Variables ¶
View Source
var (
ComponentIDGOHttpServer int32 = 5004
)
Functions ¶
func DefaultEncoderConfig ¶ added in v0.0.10
func DefaultEncoderConfig(WithStack bool) zapcore.EncoderConfig
func DefaultParseTime ¶ added in v0.0.8
DefaultParseTime 默认时间解析.
func DiffDayWithLayout ¶ added in v0.0.23
DiffDayWithLayout 两个时间差多少天.
func Error ¶
func Error(logger *zap.SugaredLogger, err error)
func FilterMethod ¶ added in v0.0.23
FilterMethod filter method not proceed trace.
func GetDayStartAndLatest ¶ added in v0.0.23
GetDayStartAndLatest 获取某天的开始和结束.
func JSONMarshal ¶
JSONMarshal 类似json.Marshal(), 但不转义特殊符号
func MarshalJSON ¶
func MarshalParam ¶ added in v0.0.23
func MarshalParam(v interface{}) string
func MaxRuneCount ¶ added in v0.0.9
MaxRuneCount 字符串最大长度(包括中文)
func NewApmSpan ¶
NewApmSpan 根据context,在当前transaction中生成新的span记录
func NewServerSkywalkingHTTPMiddleware ¶ added in v0.0.23
func NewUnaryClientSkywalkingInterceptor ¶ added in v0.0.23
func NewUnaryClientSkywalkingInterceptor(tracer *go2sky.Tracer) grpc.UnaryClientInterceptor
NewUnaryClientSkywalkingInterceptor skywalking client interceptor.
func NewUnaryServerAccessLogInterceptor ¶
func NewUnaryServerAccessLogInterceptor(logger *zap.SugaredLogger, apmTracer *apm.Tracer) grpc.UnaryServerInterceptor
NewUnaryServerAccessLogInterceptor returns a new unary server interceptors tha log access log
func NewUnaryServerSkywalkingInterceptor ¶ added in v0.0.23
func NewUnaryServerSkywalkingInterceptor(tracer *go2sky.Tracer, opts ...Option) grpc.UnaryServerInterceptor
NewUnaryServerSkywalkingInterceptor skywalking server interceptor. nolint: govet
func SetServiceName ¶
func SetServiceName(name string)
func SpanIDFromContext ¶ added in v0.0.9
func TraceIDFromContext ¶ added in v0.0.9
func Track ¶
func Track(logger *zap.SugaredLogger, message interface{})
func TrackEncoderConfig ¶ added in v0.0.10
func TrackEncoderConfig() zapcore.EncoderConfig
func WithExtraTags ¶ added in v0.0.23
func WithFilterMethod ¶ added in v0.0.23
func WithFilterMethod(methods []string) func(*options)
func WithFilterURL ¶ added in v0.0.23
func WithFilterURL(urls []string) func(*handler)
func WithOperation ¶ added in v0.0.23
func WithOperation(operation operation) func(*handler)
func WithReportTags ¶ added in v0.0.23
func WithReportTags(tags []string) func(*options)
Types ¶
type AccessLog ¶
type AccessLog struct { ClientIP string Method string Request string Protocol string Agent string LogType string GrpcStatus string Payload []byte Response []byte Duration int64 StatusCode int }
func (AccessLog) Log ¶
func (l AccessLog) Log(logger *zap.SugaredLogger)
func (AccessLog) LogWithContext ¶ added in v0.0.9
func (l AccessLog) LogWithContext(ctx context.Context, logger *zap.SugaredLogger)
type BaseSchema ¶
BaseSchema 替换ent.Schema使用,包含套路字段
func (BaseSchema) Mixin ¶
func (BaseSchema) Mixin() []ent.Mixin
type GetExtraField ¶ added in v0.0.22
type LoggerOpt ¶
type LoggerOpt struct { CustomEncoderConfig *zapcore.EncoderConfig CustomEncoderConfigs map[zapcore.Level]*zapcore.EncoderConfig EnableStdout bool EnableFile bool IsUnion bool IsJSONEncoder bool }
type Period ¶ added in v0.0.8
Period 时间区间.
func ParseDateTimePeriod ¶ added in v0.0.8
ParseDateTimePeriod 解析时间区间.
type RequestLog ¶
type RequestLog struct { Method string Request string StatusDescription string Payload []byte Response []byte Duration int64 }
func (RequestLog) Log ¶
func (l RequestLog) Log(logger *zap.SugaredLogger)
func (RequestLog) LogWithContext ¶ added in v0.0.9
func (l RequestLog) LogWithContext(ctx context.Context, logger *zap.SugaredLogger)
type UnionLog ¶ added in v0.0.13
type UnionLog struct { ExtraFields map[string]GetExtraField ClientIP string Protocol string Agent string Method string Request string GrpcStatus string LogType string Payload []byte Response []byte Duration int64 StatusCode int }
func (UnionLog) GetExtraFields ¶ added in v0.0.22
func (UnionLog) Log ¶ added in v0.0.13
func (l UnionLog) Log(ctx context.Context, logger *zap.SugaredLogger)
type ZError ¶ added in v0.0.16
ZError nolint: govet // may be we need err stack
func NewZError ¶ added in v0.0.16
func NewZError(ctx context.Context, code interface{}, message string, options ...ZErrorOption) *ZError
func (ZError) ErrMessage ¶ added in v0.0.21
type ZErrorOption ¶ added in v0.0.18
type ZErrorOption func(*ZError)
func WithError ¶ added in v0.0.18
func WithError(err error) ZErrorOption
Click to show internal directories.
Click to hide internal directories.