Documentation
¶
Index ¶
- Constants
- Variables
- func AddFlags(fs *flag.FlagSet)
- func Close() error
- func Debug(args ...any)
- func DebugS(msg string, kvs ...any)
- func Debugf(format string, args ...any)
- func Error(args ...any)
- func ErrorS(err error, msg string, kvs ...any)
- func Errorf(format string, args ...any)
- func Fatal(args ...any)
- func FatalS(msg string, kvs ...any)
- func Fatalf(format string, args ...any)
- func Info(args ...any)
- func InfoS(msg string, kvs ...any)
- func Infof(format string, args ...any)
- func InitManager(name string, kvs ...any)
- func SetHandler(h Handler)
- func SetLevel(l Level)
- func SetLogger(l *Logger)
- func SetOutput(w io.Writer)
- func Warn(args ...any)
- func WarnS(msg string, kvs ...any)
- func Warnf(format string, args ...any)
- func Writer() io.Writer
- type Handler
- type JsonHandler
- type Kind
- type Level
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(args ...any)
- func (l *Logger) DebugS(msg string, kvs ...any)
- func (l *Logger) Debugf(format string, args ...any)
- func (l *Logger) Error(args ...any)
- func (l *Logger) ErrorS(err error, msg string, kvs ...any)
- func (l *Logger) Errorf(format string, args ...any)
- func (l *Logger) Fatal(args ...any)
- func (l *Logger) FatalS(msg string, kvs ...any)
- func (l *Logger) Fatalf(format string, args ...any)
- func (l *Logger) Info(args ...any)
- func (l *Logger) InfoS(msg string, kvs ...any)
- func (l *Logger) Infof(format string, args ...any)
- func (l *Logger) Log(level klog.Level, kvs ...any) error
- func (l *Logger) SetHandler(h Handler)
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) Warn(args ...any)
- func (l *Logger) WarnS(msg string, kvs ...any)
- func (l *Logger) Warnf(format string, args ...any)
- func (l *Logger) With(kvs ...any) *Logger
- func (l *Logger) WithContext(ctx context.Context) *Logger
- func (l *Logger) Writer() io.Writer
- type Manager
- type Options
- func (o *Options) Copy() *Options
- func (*Options) Descriptor() ([]byte, []int)deprecated
- func (x *Options) GetDir() string
- func (x *Options) GetFormat() string
- func (x *Options) GetLevel() string
- func (x *Options) GetMaxBackups() int64
- func (x *Options) GetMaxSize() int64
- func (x *Options) GetOutput() string
- func (*Options) ProtoMessage()
- func (x *Options) ProtoReflect() protoreflect.Message
- func (x *Options) Reset()
- func (x *Options) String() string
- type TextHandler
- type Value
- type Valuer
Constants ¶
View Source
const ( KindAny = slog.KindAny KindBool = slog.KindBool KindDuration = slog.KindDuration KindFloat64 = slog.KindFloat64 KindInt64 = slog.KindInt64 KindString = slog.KindString KindTime = slog.KindTime KindUint64 = slog.KindUint64 KindGroup = slog.KindGroup KindLogValuer = slog.KindLogValuer )
Variables ¶
View Source
var ( MessageKey = "msg" LevelKey = "level" ErrKey = "err" NameKey = "logger" // ErrorHandler is called whenever fails to write an event on its // output. default an error is printed on the stderr. This handler must // be thread safe and non-blocking. ErrorHandler func(err error) = func(err error) { _, _ = fmt.Fprintf(os.Stderr, "log: write failed, %v\n", err) } // Sprint is used to concatenate log message components into a single string. // It formats its arguments using the default behavior (fmt.Sprint). // The caller can replace this function to customize the log message formatting. Sprint func(a ...any) string = fmt.Sprint // Sprintf is used to format log messages with a specific format string. // It formats its arguments using the default behavior (fmt.Sprintf). // The caller can replace this function to customize the format or behavior of the log messages. Sprintf func(format string, a ...any) string = fmt.Sprintf )
View Source
var ( // DefaultCaller is a Valuer that returns the file and line. DefaultCaller = Caller(6) // DefaultTimestamp is a Valuer that returns the current wallclock time. DefaultTimestamp = Timestamp(time.RFC3339) )
View Source
var File_log_log_proto protoreflect.FileDescriptor
View Source
var (
Group = slog.Group
)
Functions ¶
func SetHandler ¶
func SetHandler(h Handler)
Types ¶
type Handler ¶
type Handler interface { With(kvs ...any) Handler Log(ctx context.Context, w io.Writer, level Level, msg string, kvs ...any) error }
func JsonWithName ¶
func TextWithName ¶
type JsonHandler ¶
type JsonHandler struct {
// contains filtered or unexported fields
}
func (*JsonHandler) With ¶
func (j *JsonHandler) With(kvs ...any) Handler
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) SetHandler ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) AddWithSuffix ¶
type Options ¶
type Options struct { Format string `protobuf:"bytes,1,opt,name=format,proto3" json:"format,omitempty"` Level string `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"` Output string `protobuf:"bytes,3,opt,name=output,proto3" json:"output,omitempty"` Dir string `protobuf:"bytes,4,opt,name=dir,proto3" json:"dir,omitempty"` MaxSize int64 `protobuf:"varint,5,opt,name=maxSize,proto3" json:"maxSize,omitempty"` //MB MaxBackups int64 `protobuf:"varint,6,opt,name=maxBackups,proto3" json:"maxBackups,omitempty"` // contains filtered or unexported fields }
func (*Options) Descriptor
deprecated
func (*Options) GetMaxBackups ¶
func (*Options) GetMaxSize ¶
func (*Options) ProtoMessage ¶
func (*Options) ProtoMessage()
func (*Options) ProtoReflect ¶
func (x *Options) ProtoReflect() protoreflect.Message
type TextHandler ¶
type TextHandler struct {
// contains filtered or unexported fields
}
func (*TextHandler) With ¶
func (h *TextHandler) With(kvs ...any) Handler
Source Files
¶
Click to show internal directories.
Click to hide internal directories.