Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(a ...interface{})
- func DebugF(format string, a ...interface{})
- func DebugW(keyValues ...interface{})
- func Error(a ...interface{})
- func ErrorF(format string, a ...interface{})
- func ErrorW(keyValues ...interface{})
- func Fatal(a ...interface{})
- func FatalF(format string, a ...interface{})
- func FatalW(keyValues ...interface{})
- func Info(a ...interface{})
- func InfoF(format string, a ...interface{})
- func InfoW(keyValues ...interface{})
- func Log(level Level, keyValues ...interface{}) error
- func SetLogger(logger Logger)
- func Value(ctx context.Context, v interface{}) interface{}
- func Warn(a ...interface{})
- func WarnF(format string, a ...interface{})
- func WarnW(keyValues ...interface{})
- type Filter
- type FilterOption
- type Helper
- func (h *Helper) Debug(a ...interface{})
- func (h *Helper) DebugF(format string, a ...interface{})
- func (h *Helper) DebugW(keyValues ...interface{})
- func (h *Helper) Enabled(level Level) bool
- func (h *Helper) Error(a ...interface{})
- func (h *Helper) ErrorF(format string, a ...interface{})
- func (h *Helper) ErrorW(keyValues ...interface{})
- func (h *Helper) Fatal(a ...interface{})
- func (h *Helper) FatalF(format string, a ...interface{})
- func (h *Helper) FatalW(keyValues ...interface{})
- func (h *Helper) Info(a ...interface{})
- func (h *Helper) InfoF(format string, a ...interface{})
- func (h *Helper) InfoW(keyValues ...interface{})
- func (h *Helper) Log(level Level, keyValues ...interface{}) error
- func (h *Helper) Warn(a ...interface{})
- func (h *Helper) WarnF(format string, a ...interface{})
- func (h *Helper) WarnW(keyValues ...interface{})
- func (h *Helper) WithContext(ctx context.Context) *Helper
- func (h *Helper) WithValues(kv ...interface{}) *Helper
- type HelperOption
- type Level
- type Logger
- type Valuer
Constants ¶
const LevelKey = "level"
Variables ¶
var ( // DefaultCaller is a Valuer that returns the file and line. DefaultCaller = Caller(4) // DefaultTimestamp is a Valuer that returns the current wallclock time. DefaultTimestamp = Timestamp(time.RFC3339) )
var DefaultLogger = NewStdLogger(log.Writer())
var DefaultMessageKey = "type"
DefaultMessageKey default message key.
Functions ¶
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a logger filter.
func NewFilter ¶
func NewFilter(logger Logger, opts ...FilterOption) *Filter
NewFilter new a logger filter.
type FilterOption ¶
type FilterOption func(*Filter)
FilterOption is filter option.
func FilterFunc ¶
func FilterFunc(f func(level Level, keyValues ...interface{}) bool) FilterOption
FilterFunc with filter func.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper is a logger helper.
func GetGlobalHelper ¶
func GetGlobalHelper() *Helper
func NewHelper ¶
func NewHelper(logger Logger, opts ...HelperOption) *Helper
NewHelper new a logger helper.
func (*Helper) Debug ¶
func (h *Helper) Debug(a ...interface{})
Debug logs a message at debug level.
func (*Helper) DebugW ¶
func (h *Helper) DebugW(keyValues ...interface{})
DebugW logs a message at debug level.
func (*Helper) Enabled ¶
Enabled returns true if the given level above this level. It delegates to the underlying *Filter.
func (*Helper) Error ¶
func (h *Helper) Error(a ...interface{})
Error logs a message at error level.
func (*Helper) ErrorW ¶
func (h *Helper) ErrorW(keyValues ...interface{})
ErrorW logs a message at error level.
func (*Helper) Fatal ¶
func (h *Helper) Fatal(a ...interface{})
Fatal logs a message at fatal level.
func (*Helper) FatalW ¶
func (h *Helper) FatalW(keyValues ...interface{})
FatalW logs a message at fatal level.
func (*Helper) InfoW ¶
func (h *Helper) InfoW(keyValues ...interface{})
InfoW logs a message at info level.
func (*Helper) WarnW ¶
func (h *Helper) WarnW(keyValues ...interface{})
WarnW logs a message at warn level.
func (*Helper) WithContext ¶
WithContext returns a shallow copy of h with its context changed to ctx. The provided ctx must be non-nil.
func (*Helper) WithValues ¶
type HelperOption ¶
type HelperOption func(*Helper)
HelperOption is Helper option.
func WithSprint ¶
func WithSprint(sprint func(...interface{}) string) HelperOption
WithSprint with sprint
func WithSprintf ¶
func WithSprintf(sprintf func(format string, a ...interface{}) string) HelperOption
WithSprintf with sprintf