Documentation
¶
Index ¶
- Variables
- func Close() error
- func CtxDebug(ctx context.Context, format string, args ...interface{})
- func CtxError(ctx context.Context, format string, args ...interface{})
- func CtxFatal(ctx context.Context, format string, args ...interface{})
- func CtxInfo(ctx context.Context, format string, args ...interface{})
- func CtxNotice(ctx context.Context, format string, args ...interface{})
- func CtxWarn(ctx context.Context, format string, args ...interface{})
- func Debug(format string, args ...interface{})
- func Error(format string, args ...interface{})
- func Fatal(format string, args ...interface{})
- func Flush() error
- func GetCaller(depth int) *runtime.Frame
- func GetCallerLocation(caller *runtime.Frame) (string, int)
- func GetLocalIP() string
- func GetLogIDFromCtx(ctx context.Context) string
- func GetRemoteIP(req *http.Request) string
- func Info(format string, args ...interface{})
- func InjectLogIDToCtx(ctx context.Context, logID string) context.Context
- func Notice(format string, args ...interface{})
- func SetCallDepth(depth int)
- func SetFormatter(formatter Formatter)
- func SetLevel(level Level)
- func SetWriter(writer LogWriter)
- func Warn(format string, args ...interface{})
- type AsyncWriter
- type BufferWriter
- type ConsoleWriter
- type FileOption
- type FileWriter
- type Formatter
- type Level
- type LogWriter
- type Logger
- func (logger *Logger) Close() error
- func (logger *Logger) CtxDebug(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) CtxError(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) CtxFatal(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) CtxInfo(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) CtxNotice(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) CtxWarn(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Debug(format string, args ...interface{})
- func (logger *Logger) Error(format string, args ...interface{})
- func (logger *Logger) Fatal(format string, args ...interface{})
- func (logger *Logger) Flush() error
- func (logger *Logger) GetWriter() LogWriter
- func (logger *Logger) Info(format string, args ...interface{})
- func (logger *Logger) Logf(ctx context.Context, level Level, format string, args ...interface{})
- func (logger *Logger) Notice(format string, args ...interface{})
- func (logger *Logger) SetCallDepth(depth int)
- func (logger *Logger) SetFormatter(formatter Formatter)
- func (logger *Logger) SetLevel(level Level)
- func (logger *Logger) SetWriter(writer LogWriter)
- func (logger *Logger) Warn(format string, args ...interface{})
- type RotationWindow
- type TextFormatter
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidLogLevel = errors.New("logger: invalid log level")
Functions ¶
func GetLocalIP ¶
func GetLocalIP() string
func GetLogIDFromCtx ¶
func GetRemoteIP ¶
func SetCallDepth ¶
func SetCallDepth(depth int)
func SetFormatter ¶
func SetFormatter(formatter Formatter)
Types ¶
type AsyncWriter ¶
type AsyncWriter struct {
LogWriter
// contains filtered or unexported fields
}
func (*AsyncWriter) Close ¶
func (w *AsyncWriter) Close() error
func (*AsyncWriter) Flush ¶
func (w *AsyncWriter) Flush() error
func (*AsyncWriter) Write ¶
func (w *AsyncWriter) Write(log []byte) error
type BufferWriter ¶
type BufferWriter struct {
// contains filtered or unexported fields
}
func (*BufferWriter) Bytes ¶
func (bw *BufferWriter) Bytes() []byte
func (*BufferWriter) Close ¶
func (bw *BufferWriter) Close() error
func (*BufferWriter) Flush ¶
func (bw *BufferWriter) Flush() error
func (*BufferWriter) Reset ¶
func (bw *BufferWriter) Reset() error
func (*BufferWriter) String ¶
func (bw *BufferWriter) String() string
func (*BufferWriter) Write ¶
func (bw *BufferWriter) Write(formatLog []byte) error
type ConsoleWriter ¶
type ConsoleWriter struct {
// contains filtered or unexported fields
}
func (*ConsoleWriter) Close ¶
func (cw *ConsoleWriter) Close() error
func (*ConsoleWriter) Flush ¶
func (cw *ConsoleWriter) Flush() error
func (*ConsoleWriter) Write ¶
func (cw *ConsoleWriter) Write(formatLog []byte) error
type FileOption ¶
type FileOption func(writer *FileWriter)
func SetLimitFiles ¶
func SetLimitFiles(n int) FileOption
type FileWriter ¶
FileWriter provides a file rotated output to loggers, it is thread-safe and uses memory buffer to boost file writing performance.
func (*FileWriter) Close ¶
func (w *FileWriter) Close() error
func (*FileWriter) Flush ¶
func (w *FileWriter) Flush() error
func (*FileWriter) Write ¶
func (w *FileWriter) Write(formatLog []byte) error
type LogWriter ¶
func NewAsyncWriter ¶
func NewConsoleWriter ¶
func NewConsoleWriter() LogWriter
func NewFileWriter ¶
func NewFileWriter(filename string, window RotationWindow, options ...FileOption) LogWriter
NewFileWriter creates a FileWriter.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewDefaultLogger ¶
func NewDefaultLogger() *Logger
func (*Logger) SetCallDepth ¶
func (*Logger) SetFormatter ¶
type RotationWindow ¶
type RotationWindow int8
RotationWindow allows to claim which rotation window provider uses.
const ( // Daily means rotate daily. Daily RotationWindow = iota // Hourly means rotate hourly. Hourly )
type TextFormatter ¶
type TextFormatter struct {
// contains filtered or unexported fields
}
func NewDefaultTextFormatter ¶
func NewDefaultTextFormatter() *TextFormatter
func NewTextFormatter ¶
func NewTextFormatter(enableColor bool) *TextFormatter
func (*TextFormatter) Format ¶
func (f *TextFormatter) Format(l log) ([]byte, error)
func (*TextFormatter) SetColor ¶
func (f *TextFormatter) SetColor(enable bool)
func (*TextFormatter) SetQuote ¶
func (f *TextFormatter) SetQuote(enable bool)
func (*TextFormatter) SetTimestamp ¶
func (f *TextFormatter) SetTimestamp(enable bool)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.