# README
Handlers
handler -> buffered -> rotated -> writer(os.File)
@startuml
!theme materia
skinparam backgroundColor #fefefc
start
:Handler;
:buffered;
:rotated;
:writer(os.File);
stop
@enduml
# Functions
BufferWrapper new instance.
JSONFileHandler create new FileHandler with JSON formatter.
LineBufferedFile handler.
LineBuffOsFile handler.
LineBuffWriter handler.
MustFileHandler create file handler.
MustRotateFile handler instance.
MustSimpleFile new instance.
MustSizeRotateFile instance.
MustTimeRotateFile instance.
NewBuffered create new BufferedHandler.
NewBufferedHandler create new BufferedHandler.
NewBuffFileHandler create file handler with buff size.
NewBuilder create.
NewConfig new config instance with some default settings.
NewConsole create new ConsoleHandler.
NewConsoleHandler create new ConsoleHandler.
NewEmailHandler instance.
NewEmptyConfig new config instance.
NewFileHandler create new FileHandler.
NewFlushCloseHandler create new FlushCloseHandler
Usage: buf := new(bytes.Buffer) h := handler.NewFlushCloseHandler(&buf, slog.AllLevels)
f, err := os.OpenFile("my.log", ...) h := handler.NewFlushCloseHandler(f, slog.AllLevels).
NewFlushCloser create new FlushCloseHandler.
NewGroupedHandler create new GroupedHandler.
NewHandler create a new instance.
NewIOWriteCloserHandler create new WriteCloserHandler
Usage: buf := new(bytes.Buffer) h := handler.NewIOWriteCloserHandler(&buf, slog.AllLevels)
f, err := os.OpenFile("my.log", ...) h := handler.NewIOWriteCloserHandler(f, slog.AllLevels).
NewIOWriter create a new instance.
NewIOWriterHandler create new IOWriterHandler
Usage: buf := new(bytes.Buffer) h := handler.NewIOWriterHandler(&buf, slog.AllLevels)
f, err := os.OpenFile("my.log", ...) h := handler.NewIOWriterHandler(f, slog.AllLevels).
NewMultiFileHandler instance.
NewRotateFile instance.
NewRotateFileHandler instance It supports splitting log files by time and size.
NewSimple create a new instance.
NewSimpleFile new instance.
NewSimpleFileHandler instance
Usage: h, err := NewSimpleFileHandler("/tmp/error.log")
custom formatter h.SetFormatter(slog.NewJSONFormatter()) slog.PushHandler(h) slog.Info("log message").
NewSimpleHandler create new SimpleHandler
Usage: buf := new(bytes.Buffer) h := handler.NewSimpleHandler(&buf, slog.InfoLevel)
f, err := os.OpenFile("my.log", ...) h := handler.NewSimpleHandler(f, slog.InfoLevel).
NewSizeRotateFile instance.
NewSizeRotateFileHandler instance.
NewSyncCloseHandler create new SyncCloseHandler
Usage: f, err := os.OpenFile("my.log", ...) h := handler.NewSyncCloseHandler(f, slog.AllLevels).
NewSyncCloser create new SyncCloseHandler.
NewSysLogHandler instance.
NewTimeRotateFile instance.
NewTimeRotateFileHandler instance.
NewWriteCloser create a new instance.
QuickOpenFile like os.OpenFile.
WithBuffMode setting.
WithBuffSize setting.
WithLogfile setting.
WithLogLevels setting.
WithMaxSize setting.
WithRotateTime setting.
WithUseJSON setting.
# Constants
the buff mode consts.
the buff mode consts.
Deprecated: Please use define constants on pkg rotatefile.
Deprecated: Please use define constants on pkg rotatefile.
Deprecated: Please use define constants on pkg rotatefile.
Deprecated: Please use define constants on pkg rotatefile.
Deprecated: Please use define constants on pkg rotatefile.
only use for tests.
# Variables
DefaultBufferSize sizes the buffer associated with each log file.
DefaultFileFlags for create/open file.
DefaultFilePerm perm and flags for create log file.
# Structs
Builder struct for create handler.
Config struct.
ConsoleHandler definition.
EmailHandler struct.
EmailOption struct.
FlushCloseHandler definition.
GroupedHandler definition.
IOWriterHandler definition.
LevelsWithFormatter struct definition
- support set log formatter - support setting multi log levels
Deprecated: please use slog.LevelsWithFormatter instead.
LevelWithFormatter struct definition
- support set log formatter - only support set one log level
Deprecated: please use slog.LevelWithFormatter instead.
LockWrapper struct.
MultiFileHandler definition.
NopFlushClose no operation.
SimpleHandler definition.
SyncCloseHandler definition.
SysLogHandler struct.
WriteCloserHandler definition.
# Interfaces
FlushCloseWriter is the interface satisfied by logging destinations.
FlushWriter is the interface satisfied by logging destinations.
FormatterWriterHandler interface.
SyncCloseWriter is the interface satisfied by logging destinations.