Documentation ¶
Index ¶
- func AddWriter(lw LogWriter) error
- func AsyncWrite()
- func Debug(v ...any)
- func Debugf(format string, v ...any)
- func Debugln(v ...any)
- func Error(v ...any)
- func Errorf(format string, v ...any)
- func Errorln(v ...any)
- func Fatal(v ...any)
- func Fatalf(format string, v ...any)
- func Fatalln(v ...any)
- func Flush()
- func HideLocation()
- func Info(v ...any)
- func Infof(format string, v ...any)
- func Infoln(v ...any)
- func InitLogger(logger *Logger)
- func SetCallDepth(d int)
- func SetLevel(l Level)
- func Start()
- func Stop()
- func Warn(v ...any)
- func Warnf(format string, v ...any)
- func Warnln(v ...any)
- type BufPool
- type ConsoleWriter
- type FileWriter
- type Level
- type LogWriter
- type Logger
- func (logger *Logger) AddWriter(writer LogWriter) error
- func (logger *Logger) AsyncWrite()
- func (logger *Logger) Debug(v ...any)
- func (logger *Logger) Debugf(format string, v ...any)
- func (logger *Logger) Debugln(v ...any)
- func (logger *Logger) Error(v ...any)
- func (logger *Logger) Errorf(format string, v ...any)
- func (logger *Logger) Errorln(v ...any)
- func (logger *Logger) Fatal(v ...any)
- func (logger *Logger) Fatalf(format string, v ...any)
- func (logger *Logger) Fatalln(v ...any)
- func (logger *Logger) Flush()
- func (logger *Logger) GetLevel() (l Level)
- func (logger *Logger) HideLocation()
- func (logger *Logger) Info(v ...any)
- func (logger *Logger) Infof(format string, v ...any)
- func (logger *Logger) Infoln(v ...any)
- func (logger *Logger) SetCallDepth(d int)
- func (logger *Logger) SetLevel(l Level)
- func (logger *Logger) Start()
- func (logger *Logger) Stop()
- func (logger *Logger) Warn(v ...any)
- func (logger *Logger) Warnf(format string, v ...any)
- func (logger *Logger) Warnln(v ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetCallDepth ¶
func SetCallDepth(d int)
SetCallDepth sets the global defaultLogger's call depth.
Types ¶
type BufPool ¶
type BufPool struct {
// contains filtered or unexported fields
}
BufPool wraps sync.Pool to make it handy.
type ConsoleWriter ¶
type ConsoleWriter struct {
// contains filtered or unexported fields
}
ConsoleWriter is responsible for writing log to console.
func NewConsoleWriter ¶
func NewConsoleWriter() *ConsoleWriter
NewConsoleWriter returns a new instance of ConsoleWriter.
func (*ConsoleWriter) GetLevel ¶
func (cw *ConsoleWriter) GetLevel() Level
GetLevel returns the log level.
func (*ConsoleWriter) SetLevel ¶
func (cw *ConsoleWriter) SetLevel(l Level)
SetLevel sets the log level.
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter is responsible for writing log to file.
func NewFileWriter ¶
func NewFileWriter(filepath string) *FileWriter
NewFileWriter returns a new instance of NewFileWriter.
func (*FileWriter) GetLevel ¶
func (fw *FileWriter) GetLevel() Level
GetLevel returns the log level.
type LogWriter ¶
type LogWriter interface { Init() error SetLevel(Level) GetLevel() Level Write(msg string, level Level) error Flush() error Close() error }
LogWriter defines writer's API.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the core struct of ilog package. It packs message and sends it to the writer.
func NewConsoleLogger ¶
func NewConsoleLogger() *Logger
NewConsoleLogger returns a Logger instance with a console writer.
func (*Logger) AsyncWrite ¶
func (logger *Logger) AsyncWrite()
AsyncWrite sets logger's syncWrite to false.
func (*Logger) HideLocation ¶
func (logger *Logger) HideLocation()
HideLocation sets logger's showLocation to false.
func (*Logger) SetCallDepth ¶
SetCallDepth sets the logger's call depth.