Documentation ΒΆ
Index ΒΆ
- Constants
- func FromContext(ctx context.Context) *slog.Logger
- func NewContext(ctx context.Context, l *slog.Logger) context.Context
- type FileWriter
- type FileWriterOption
- func WithCompress(compress bool) FileWriterOption
- func WithFileName(fileName string) FileWriterOption
- func WithMaxCount(maxCount int) FileWriterOption
- func WithMaxTime(maxTime time.Duration) FileWriterOption
- func WithPath(path string) FileWriterOption
- func WithRotateSize(rotateSize int) FileWriterOption
- func WithRotateTimeLayout(rotateTimeLayout string) FileWriterOption
- type FileWriterOptionFn
- type FileWriterOptions
- type Handler
- type HandlerOptions
- type MultiHandler
Constants ΒΆ
View Source
const ( SizeMB = 1024 * 1024 RotateTimeLayoutEveryYear = "2006" RotateTimeLayoutEveryMonth = "200601" RotateTimeLayoutEveryDay = "20060102" RotateTimeLayoutEveryHour = "2006010215" RotateTimeLayoutEveryMinutes = "200601021504" RotateTimeLayoutEverySecond = "20060102150405" )
Variables ΒΆ
This section is empty.
Functions ΒΆ
func FromContext ΒΆ
FromContext returns the Logger stored in ctx by NewContext, or the default Logger if there is none.
Types ΒΆ
type FileWriter ΒΆ
type FileWriter struct {
// contains filtered or unexported fields
}
func NewFileWriter ΒΆ
func NewFileWriter(opts ...FileWriterOption) (*FileWriter, error)
type FileWriterOption ΒΆ
type FileWriterOption interface {
// contains filtered or unexported methods
}
func WithCompress ΒΆ
func WithCompress(compress bool) FileWriterOption
func WithFileName ΒΆ
func WithFileName(fileName string) FileWriterOption
func WithMaxCount ΒΆ
func WithMaxCount(maxCount int) FileWriterOption
func WithMaxTime ΒΆ
func WithMaxTime(maxTime time.Duration) FileWriterOption
func WithPath ΒΆ
func WithPath(path string) FileWriterOption
func WithRotateSize ΒΆ
func WithRotateSize(rotateSize int) FileWriterOption
func WithRotateTimeLayout ΒΆ
func WithRotateTimeLayout(rotateTimeLayout string) FileWriterOption
type FileWriterOptionFn ΒΆ
type FileWriterOptionFn struct {
// contains filtered or unexported fields
}
func NewFileWriterOptionFn ΒΆ
func NewFileWriterOptionFn(f func(*FileWriterOptions)) *FileWriterOptionFn
type FileWriterOptions ΒΆ
type FileWriterOptions struct { Path string FileName string MaxTime time.Duration MaxCount int RotateTimeLayout string // RotateSize is the maximum size in MB of the log file before it gets rotated. // It defaults to 100 MB. RotateSize int Compress bool }
func (FileWriterOptions) NewFileWriter ΒΆ
func (opts FileWriterOptions) NewFileWriter() (*FileWriter, error)
type Handler ΒΆ
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ΒΆ
func NewHandler(w io.Writer, opts *HandlerOptions) *Handler
type HandlerOptions ΒΆ
type HandlerOptions struct { Level slog.Leveler Prefix string AddSource bool AddCaller bool AddStackTrace bool ReplaceAttr func(groups []string, a slog.Attr) slog.Attr }
func (HandlerOptions) NewHandler ΒΆ
func (opts HandlerOptions) NewHandler(w io.Writer) *Handler
type MultiHandler ΒΆ
type MultiHandler struct {
// contains filtered or unexported fields
}
func NewMultiHandler ΒΆ
func NewMultiHandler(handlers ...slog.Handler) *MultiHandler
Click to show internal directories.
Click to hide internal directories.