Documentation ¶
Index ¶
- Constants
- Variables
- func AddHook(hook Hook)
- func Debugf(ctx context.Context, format string, args ...interface{})
- func ErrorStack(ctx context.Context, err error)
- func ErrorWW(err error) string
- func Errorf(ctx context.Context, format string, args ...interface{})
- func Fatalf(ctx context.Context, format string, args ...interface{})
- func FromTraceIDContext(ctx context.Context) string
- func GetClientIP(c *gin.Context) string
- func GetTraceID(c *gin.Context) string
- func Infof(ctx context.Context, format string, args ...interface{})
- func InitLogger(ctx context.Context) (func(), error)
- func Printf(ctx context.Context, format string, args ...interface{})
- func SetFormatter(format string)
- func SetLevel(level string)
- func SetOutput(out io.Writer)
- func SetVersion(v string)
- func Stack(skip int) []byte
- func Stack2(skip int, max int) []byte
- func Stack3(skip, max int, short bool) []byte
- func Warnf(ctx context.Context, format string, args ...interface{})
- func Whereis(short bool) []byte
- type Entry
- func (e *Entry) Debugf(format string, args ...interface{})
- func (e *Entry) Errorf(format string, args ...interface{})
- func (e *Entry) Fatalf(format string, args ...interface{})
- func (e *Entry) Infof(format string, args ...interface{})
- func (e *Entry) Printf(format string, args ...interface{})
- func (e *Entry) Warnf(format string, args ...interface{})
- func (e *Entry) WithField(key string, value interface{}) *Entry
- func (e *Entry) WithFields(fields map[string]interface{}) *Entry
- type Hook
- type Logger
- type UserInfo
Constants ¶
View Source
const ( Prefix = "zgo" KeyUserInfo = Prefix + "/user-info" KeyTraceID = Prefix + "/tract-id" )
定义上下文中的键
View Source
const ( TraceIDKey = "trace_id" UserIDKey = "user_id" RoleIDKey = "role_id" VersionKey = "version" HostnameKey = "hostname" StackKey = "stack" LogVerKey = "@version" NamespaceKey = "@namespace" )
定义键名
Variables ¶
View Source
var ( // ShowShortName 显示短的名字 ShowShortName = true )
Functions ¶
func FromTraceIDContext ¶
FromTraceIDContext 从上下文中获取跟踪ID
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry 定义统一的日志写入方式
func (*Entry) WithFields ¶
WithFields 结构化字段写入
Click to show internal directories.
Click to hide internal directories.