Documentation
¶
Index ¶
- Constants
- func AddWriter(w Writer)
- func Close()
- func Debug(msg string, args ...interface{})
- func DebugF(format string, formatArgs []interface{}, args ...interface{})
- func EncodeLogToInterface(l Log, f LogFormat) interface{}
- func Error(msg string, args ...interface{})
- func ErrorF(format string, formatArgs []interface{}, args ...interface{})
- func Fatal(msg string, args ...interface{})
- func FatalF(format string, formatArgs []interface{}, args ...interface{})
- func GetTime() string
- func Info(msg string, args ...interface{})
- func InfoF(format string, formatArgs []interface{}, args ...interface{})
- func IsValidLogFormat(s string) bool
- func Panic(msg string, args ...interface{})
- func PanicF(format string, formatArgs []interface{}, args ...interface{})
- func RemoveAnsiString(s string) string
- func SetLogger(l *SLogger)
- func Stat(msg string, args ...interface{})
- func Warn(msg string, args ...interface{})
- func WarnF(format string, formatArgs []interface{}, args ...interface{})
- func WithStdIoWriter(opt *ToStdStreamWriterOptions) *toStdStreamWriter
- func WithToChanWriter(opt *ToChanWriterOptions) *toChanWriter
- type Log
- type LogBuffer
- type LogFormat
- type LogLevel
- type LogLevelString
- type SLogger
- type StdStream
- type ToChanWriterOptions
- type ToFileWriter
- type ToFileWriterOptions
- type ToHttpWriter
- type ToHttpWriterOptions
- type ToStdStreamWriterOptions
- type Writer
Constants ¶
View Source
const ( ColorDarkBLue = "\u001b[38;2;0;51;204m" ColorDarkGreen = "\033[38;2;0;153;0m" ColorDarkPurple = "\033[38;2;102;0;153m" ColorGreen = "\033[32m" ColorBlue = "\033[34m" ColorRed = "\033[31m" ColorOrange = "\033[33m" ColorPurple = "\033[35m" ColorYellow = "\033[93m" ColorPink = "\033[95m" ColorWhite = "\033[0m" FontBold = "\u001b[1m" FontNormal = "\u001b[0m" )
View Source
const ( PadWidth = 50 Truncate = false )
Variables ¶
This section is empty.
Functions ¶
func EncodeLogToInterface ¶
func IsValidLogFormat ¶
func RemoveAnsiString ¶
func WithStdIoWriter ¶
func WithStdIoWriter(opt *ToStdStreamWriterOptions) *toStdStreamWriter
func WithToChanWriter ¶
func WithToChanWriter(opt *ToChanWriterOptions) *toChanWriter
Types ¶
type Log ¶
type Log struct {
Type string `json:"level"`
Level LogLevel `json:"-"`
TypeColor string `json:"-"`
Time string `json:"time"`
Timestamp time.Time `json:"timestamp"`
Msg string `json:"msg"`
MsgColor string `json:"-"`
Args map[string]interface{} `json:"args"`
ArgKeys []string `json:"-"`
Str string `json:"-"`
}
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
func NewLogBuffer ¶
type LogLevelString ¶
type LogLevelString string
const ( DebugLevelString LogLevelString = "debug" InfoLevelString LogLevelString = "info" WarnLevelString LogLevelString = "warn" ErrorLevelString LogLevelString = "error" FatalLevelString LogLevelString = "fatal" PanicLevelString LogLevelString = "panic" )
type SLogger ¶
type SLogger struct {
Buffer *LogBuffer
// contains filtered or unexported fields
}
var Slog *SLogger = &SLogger{ Buffer: NewLogBuffer(1000), writers: []Writer{ &toStdStreamWriter{ Stream: StdOut, format: FormatAnsi, level: InfoLevel, }, }, }
set default logger
type ToChanWriterOptions ¶
type ToFileWriter ¶
type ToFileWriter struct {
// contains filtered or unexported fields
}
func WithToFileWriter ¶
func WithToFileWriter(opt *ToFileWriterOptions) *ToFileWriter
func (*ToFileWriter) Close ¶
func (w *ToFileWriter) Close()
func (*ToFileWriter) FileName ¶
func (w *ToFileWriter) FileName() string
func (*ToFileWriter) Format ¶
func (w *ToFileWriter) Format() LogFormat
func (*ToFileWriter) Level ¶
func (w *ToFileWriter) Level() LogLevel
func (*ToFileWriter) Write ¶
func (w *ToFileWriter) Write(l *Log) error
type ToFileWriterOptions ¶
type ToHttpWriter ¶
type ToHttpWriter struct {
// contains filtered or unexported fields
}
func WithToHttpWriter ¶
func WithToHttpWriter(opt *ToHttpWriterOptions) *ToHttpWriter
func (*ToHttpWriter) Close ¶
func (w *ToHttpWriter) Close()
func (*ToHttpWriter) Level ¶
func (w *ToHttpWriter) Level() LogLevel
func (*ToHttpWriter) Write ¶
func (w *ToHttpWriter) Write(l *Log) error
type ToHttpWriterOptions ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.