Documentation ¶
Overview ¶
reference: https://github.com/uber-go/zap/blob/master/buffer/buffer.go
Index ¶
- Variables
- func Blue(msg string) string
- func Cyan(msg string) string
- func Green(msg string) string
- func HiBlue(msg string) string
- func HiCyan(msg string) string
- func HiGreen(msg string) string
- func HiMagenta(msg string) string
- func HiRed(msg string) string
- func HiWhite(msg string) string
- func HiYellow(msg string) string
- func Magenta(msg string) string
- func Red(msg string) string
- func White(msg string) string
- func Yellow(msg string) string
- type Buffer
- func (b *Buffer) AppendBool(v bool)
- func (b *Buffer) AppendByte(v byte)
- func (b *Buffer) AppendBytes(v []byte)
- func (b *Buffer) AppendFloat(f float64, bitSize int)
- func (b *Buffer) AppendInt(i int64)
- func (b *Buffer) AppendQuote(s string)
- func (b *Buffer) AppendString(s string)
- func (b *Buffer) AppendTime(t time.Time, layout string)
- func (b *Buffer) AppendUint(i uint64)
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) Clone() *Buffer
- func (b *Buffer) Len() int
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) TrimNewline()
- func (b *Buffer) TryGrow(size int)
- func (b *Buffer) Write(bs []byte) (int, error)
- func (b *Buffer) WriteByte(v byte) error
- func (b *Buffer) WriteString(s string) (int, error)
- type CallerFormatter
- type CallerOption
- type ColorAttr
- type ConsoleEncoder
- type EncoderType
- type Field
- func Any(key string, value any) Field
- func Array(key string, value ...any) Field
- func ArrayT[T any](key string, value ...T) Field
- func Bool(key string, value bool) Field
- func Duration(key string, value time.Duration) Field
- func Error(key string, value error) Field
- func Float32(key string, value float32) Field
- func Float64(key string, value float64) Field
- func Int(key string, value int) Field
- func Int16(key string, value int16) Field
- func Int32(key string, value int32) Field
- func Int64(key string, value int64) Field
- func Int8(key string, value int8) Field
- func Object(key string, value ...Field) Field
- func String(key string, value string) Field
- func Time(key string, value time.Time) Field
- func UInt(key string, value uint) Field
- func UInt16(key string, value uint16) Field
- func UInt32(key string, value uint32) Field
- func UInt64(key string, value uint64) Field
- func UInt8(key string, value uint8) Field
- type FieldType
- type JsonEncoder
- type LevelOption
- type LevelType
- type LogContext
- func (lc *LogContext) BuildConsoleLogger(level LevelType) Logger
- func (lc *LogContext) BuildFileLogger(level LevelType, writer io.Writer) Logger
- func (lc *LogContext) Copy() *LogContext
- func (lc *LogContext) WithCaller(enable bool, option CallerOption) *LogContext
- func (lc *LogContext) WithColorfulset(enable bool, attr TextColorAttri) *LogContext
- func (lc *LogContext) WithEncoder(encoder EncoderType) *LogContext
- func (lc *LogContext) WithEscapeQuote(enable bool) *LogContext
- func (lc *LogContext) WithFields(fields ...Field) *LogContext
- func (lc *LogContext) WithLevel(enable bool, option LevelOption) *LogContext
- func (lc *LogContext) WithMsgKey(key string) *LogContext
- func (lc *LogContext) WithNewFields(fields ...Field) *LogContext
- func (lc *LogContext) WithReflectValue(enable bool) *LogContext
- func (lc *LogContext) WithTime(enable bool, option TimeOption) *LogContext
- func (lc *LogContext) WithWriter(writer WriteSyncer) *LogContext
- type Logger
- type LoggerX
- func (l *LoggerX) Debug(msg string, fields ...Field)
- func (l *LoggerX) Debugf(format string, args ...any)
- func (l *LoggerX) Error(msg string, fields ...Field)
- func (l *LoggerX) ErrorWith(err error)
- func (l *LoggerX) Errorf(format string, args ...any)
- func (l *LoggerX) Fatal(msg string, fields ...Field)
- func (l *LoggerX) FatalWith(err error)
- func (l *LoggerX) Fatalf(format string, args ...any)
- func (l *LoggerX) Info(msg string, fields ...Field)
- func (l *LoggerX) Infof(format string, args ...any)
- func (l *LoggerX) Panic(msg string, fields ...Field)
- func (l *LoggerX) PanicWith(err error)
- func (l *LoggerX) Panicf(format string, args ...any)
- func (l *LoggerX) Trace(msg string, fields ...Field)
- func (l *LoggerX) Tracef(format string, args ...any)
- func (l *LoggerX) Warn(msg string, fields ...Field)
- func (l *LoggerX) Warnf(format string, args ...any)
- func (l *LoggerX) With(fields ...Field) Logger
- type TextColorAttri
- type TimeOption
- type WriteSyncer
Constants ¶
This section is empty.
Variables ¶
var ConsoleEncoderSplitCharacter = byte('\t')
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a thin wrapper around a byte slice. It's intended to be pooled, so the only way to construct one is via a Pool.
func (*Buffer) AppendBool ¶
AppendBool appends a bool to the underlying buffer.
func (*Buffer) AppendByte ¶
AppendByte writes a single byte to the Buffer.
func (*Buffer) AppendBytes ¶
AppendBytes writes the given slice of bytes to the Buffer.
func (*Buffer) AppendFloat ¶
AppendFloat appends a float to the underlying buffer. It doesn't quote NaN or +/- Inf.
func (*Buffer) AppendInt ¶
AppendInt appends an integer to the underlying buffer (assuming base 10).
func (*Buffer) AppendQuote ¶
func (*Buffer) AppendString ¶
AppendString writes a string to the Buffer.
func (*Buffer) AppendTime ¶
AppendTime appends the time formatted using the specified layout.
func (*Buffer) AppendUint ¶
AppendUint appends an unsigned integer to the underlying buffer (assuming base 10).
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset resets the underlying byte slice. Subsequent writes re-use the slice's backing array.
func (*Buffer) TrimNewline ¶
func (b *Buffer) TrimNewline()
TrimNewline trims any final "\n" byte from the end of the buffer.
type CallerFormatter ¶
type CallerFormatter uint8
const ( // package/file:line ShortFile CallerFormatter = iota // /full/path/to/package/file:line FullFile // package/file:line package.func ShortFileFunc // /full/path/to/package/file:line package.func FullFileFunc )
type CallerOption ¶
type CallerOption struct { // caller key, default: "caller" CallerKey string // file key of caller, default: "file" FileKey string // function key of caller, default: "func" FuncKey string // caller formatter, default: ShortFileCaller Formatter CallerFormatter // caller skips increases the number of callers skipped by caller annotation. // when building wrappers around the Logger, supplying this Option prevents logx from always // reporting the wrapper code as the caller. default: 0 CallerSkip int }
type ConsoleEncoder ¶
type ConsoleEncoder struct { *LogContext // contains filtered or unexported fields }
func (*ConsoleEncoder) Encode ¶
func (enc *ConsoleEncoder) Encode(buf *Buffer, msg string, fields []Field) error
func (*ConsoleEncoder) Init ¶
func (enc *ConsoleEncoder) Init()
type JsonEncoder ¶
type JsonEncoder struct { *LogContext // contains filtered or unexported fields }
func (*JsonEncoder) Encode ¶
func (enc *JsonEncoder) Encode(buf *Buffer, msg string, fields []Field) error
func (*JsonEncoder) Init ¶
func (enc *JsonEncoder) Init()
type LevelOption ¶
type LogContext ¶
type LogContext struct {
// contains filtered or unexported fields
}
func NewLogContext ¶
func NewLogContext() *LogContext
func (*LogContext) BuildConsoleLogger ¶
func (lc *LogContext) BuildConsoleLogger(level LevelType) Logger
func (*LogContext) BuildFileLogger ¶
func (lc *LogContext) BuildFileLogger(level LevelType, writer io.Writer) Logger
func (*LogContext) Copy ¶
func (lc *LogContext) Copy() *LogContext
func (*LogContext) WithCaller ¶
func (lc *LogContext) WithCaller(enable bool, option CallerOption) *LogContext
func (*LogContext) WithColorfulset ¶
func (lc *LogContext) WithColorfulset(enable bool, attr TextColorAttri) *LogContext
func (*LogContext) WithEncoder ¶
func (lc *LogContext) WithEncoder(encoder EncoderType) *LogContext
func (*LogContext) WithEscapeQuote ¶
func (lc *LogContext) WithEscapeQuote(enable bool) *LogContext
func (*LogContext) WithFields ¶
func (lc *LogContext) WithFields(fields ...Field) *LogContext
func (*LogContext) WithLevel ¶
func (lc *LogContext) WithLevel(enable bool, option LevelOption) *LogContext
func (*LogContext) WithMsgKey ¶
func (lc *LogContext) WithMsgKey(key string) *LogContext
func (*LogContext) WithNewFields ¶
func (lc *LogContext) WithNewFields(fields ...Field) *LogContext
func (*LogContext) WithReflectValue ¶
func (lc *LogContext) WithReflectValue(enable bool) *LogContext
func (*LogContext) WithTime ¶
func (lc *LogContext) WithTime(enable bool, option TimeOption) *LogContext
func (*LogContext) WithWriter ¶
func (lc *LogContext) WithWriter(writer WriteSyncer) *LogContext
type Logger ¶
type Logger interface { Trace(msg string, fields ...Field) Debug(msg string, fields ...Field) Info(msg string, fields ...Field) Warn(msg string, fields ...Field) Error(msg string, fields ...Field) Fatal(msg string, fields ...Field) Panic(msg string, fields ...Field) Tracef(format string, args ...any) Debugf(format string, args ...any) Infof(format string, args ...any) Warnf(format string, args ...any) Errorf(format string, args ...any) Panicf(format string, args ...any) Fatalf(format string, args ...any) PanicWith(err error) ErrorWith(err error) FatalWith(err error) With(fields ...Field) Logger }
type TextColorAttri ¶
type TimeOption ¶
type WriteSyncer ¶
func AddSync ¶
func AddSync(w io.Writer) WriteSyncer