Documentation
¶
Index ¶
- Variables
- func Error(e error) slog.Attr
- func ErrorWithStacktrace(e error, opts *StacktraceOptions) slog.Attr
- func Lazy(key string, f func() slog.Value) slog.Attr
- func LazyGroup(key string, f func() []slog.Attr) slog.Attr
- func New(opts *Opts) (*slog.Logger, error)
- func NewSlowWriter(ctx context.Context, w io.Writer, sizeinbytes int64, duration time.Duration) io.Writer
- func Recovered(v any) slog.Attr
- func RecoveredWithStacktrace(pv any, opts *StacktraceOptions) slog.Attr
- type AutoSaveWriter
- type CompressOptions
- type Flusher
- type IFile
- type LazyType
- type LockFile
- type NoBufferedWriter
- type OpenWriterFnc
- type Opts
- type RollingFile
- type RollingKind
- type RollingOptions
- type SlowCompressOptions
- type StacktraceOptions
- type Syncer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidRollingSize = errors.New("rrscpkgs.logx: rolling size must be greater than 0") ErrInvalidCompressWorkers = errors.New("rrscpkgs.logx: compress workers must be greater than 0") ErrNilRollingOptions = errors.New("rrscpkgs.logx: rolling options is nil") )
View Source
var (
ErrInvalidRollingKind = errors.New("rolling kind is invalid")
)
Functions ¶
func ErrorWithStacktrace ¶
func ErrorWithStacktrace(e error, opts *StacktraceOptions) slog.Attr
func NewSlowWriter ¶
func RecoveredWithStacktrace ¶
func RecoveredWithStacktrace(pv any, opts *StacktraceOptions) slog.Attr
Types ¶
type AutoSaveWriter ¶
type AutoSaveWriter struct {
// contains filtered or unexported fields
}
func NewAutoSaveWriter ¶
func NewAutoSaveWriter(w io.Writer, closes ...func() error) *AutoSaveWriter
func (*AutoSaveWriter) Close ¶
func (afw *AutoSaveWriter) Close() error
type CompressOptions ¶
type CompressOptions struct {
Enable bool `json:"enable" toml:"enable"`
Directly bool `json:"directly" toml:"directly"`
Slow *SlowCompressOptions `json:"slow" toml:"slow"`
}
type LockFile ¶
type LockFile struct {
// contains filtered or unexported fields
}
LockFile for multi process safe
type NoBufferedWriter ¶
type NoBufferedWriter struct {
// contains filtered or unexported fields
}
func NewNoBufferedWriter ¶
func NewNoBufferedWriter(w io.Writer) *NoBufferedWriter
type Opts ¶
type Opts struct {
Filename string `json:"filename" toml:"filename"`
MultiProcessSafe bool `json:"multi_process_safe" toml:"multi_process_safe"`
Level slog.Level `json:"level" toml:"level"`
AddSource bool `json:"add_source" toml:"add_source"`
WithStdout bool `json:"with_stdout" toml:"with_stdout"`
StdoutLevel slog.Level `json:"stdout_level" toml:"stdout_level"`
BufferSize int `json:"buffer_size" toml:"buffer_size"`
Rolling *RollingOptions `json:"rolling" toml:"rolling"`
DisableLocal bool `json:"disable_local" toml:"disable_local"`
Forwards []slog.Handler `json:"-" toml:"-"`
}
type RollingFile ¶
type RollingFile struct {
// contains filtered or unexported fields
}
func NewRollingFile ¶
func NewRollingFile(fp string, opts *RollingOptions) (*RollingFile, error)
func (*RollingFile) Close ¶
func (r *RollingFile) Close() error
type RollingKind ¶
type RollingKind int
const ( RollingKindNone RollingKind = iota RollingKindDaily RollingKindHourly RollingKindMinutely RollingKindSize )
func (RollingKind) String ¶
func (i RollingKind) String() string
func (*RollingKind) UnmarshalJSON ¶
func (i *RollingKind) UnmarshalJSON(text []byte) error
func (*RollingKind) UnmarshalText ¶
func (i *RollingKind) UnmarshalText(text []byte) error
type RollingOptions ¶
type RollingOptions struct {
Kind RollingKind `json:"kind" toml:"rolling_kind"`
FileSize int64 `json:"size" toml:"size"`
Backups int `json:"backups" toml:"backups"`
Compress *CompressOptions `json:"compress" toml:"compress"`
BufferSize int `json:"buffer_size" toml:"buffer_size"`
OpenFile OpenWriterFnc `json:"-" toml:"-"`
}
type SlowCompressOptions ¶
type StacktraceOptions ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.