log

package
v0.1.78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Ldate         = 1 << iota     // the date in the local time zone: 2009/01/23
	Ltime                         // the time in the local time zone: 01:23:23
	Lmicroseconds                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC                          // if Ldate or Ltime is set, use UTC rather than the local time zone
	Lmsgprefix                    // move the "prefix" from the beginning of the line to before the message
	LstdFlags     = Ldate | Ltime // initial values for the standard logger
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...any)

func DebugContext

func DebugContext(ctx context.Context, msg string, args ...any)

func Enabled

func Enabled(ctx context.Context, level slog.Level) bool

func Error

func Error(msg string, args ...any)

func ErrorContext

func ErrorContext(ctx context.Context, msg string, args ...any)

func Fatal

func Fatal(v ...any)

func Fatalf

func Fatalf(format string, v ...any)

func Fatalln

func Fatalln(v ...any)

func File

func File() string

func Flags

func Flags() int

func Info

func Info(msg string, args ...any)

func InfoContext

func InfoContext(ctx context.Context, msg string, args ...any)

func Level

func Level() *slog.LevelVar

func ListenRotateSignal

func ListenRotateSignal(r Rotatable, sig ...os.Signal)

func Log

func Log(ctx context.Context, level slog.Level, msg string, args ...any)

func LogAttrs

func LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)

func LoggerHandler

func LoggerHandler() slog.Handler

func Output

func Output(calldepth int, s string) error

func Panic

func Panic(v ...any)

func Panicf

func Panicf(format string, v ...any)

func Panicln

func Panicln(v ...any)

func Prefix

func Prefix() string

func Print

func Print(v ...any)

func Printf

func Printf(format string, v ...any)

func Println

func Println(v ...any)

func Rotate

func Rotate()

func SetExtra

func SetExtra(extra io.Writer)

func SetFile

func SetFile(file string)

func SetFlags

func SetFlags(flag int)

func SetHandler

func SetHandler(h slog.Handler)

func SetLevel

func SetLevel(level slog.Level)

func SetOutput

func SetOutput(file string, extra io.Writer)

func SetPrefix

func SetPrefix(prefix string)

func Warn

func Warn(msg string, args ...any)

func WarnContext

func WarnContext(ctx context.Context, msg string, args ...any)

func Writer

func Writer() io.Writer

Types

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

func Default

func Default() *Logger

func New

func New(file, prefix string, flag int) *Logger

func With

func With(args ...any) *Logger

func WithGroup

func WithGroup(name string) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

func (*Logger) DebugContext

func (l *Logger) DebugContext(ctx context.Context, msg string, args ...any)

func (*Logger) Enabled

func (l *Logger) Enabled(ctx context.Context, level slog.Level) bool

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

func (*Logger) ErrorContext

func (l *Logger) ErrorContext(ctx context.Context, msg string, args ...any)

func (*Logger) File

func (l *Logger) File() string

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

func (*Logger) InfoContext

func (l *Logger) InfoContext(ctx context.Context, msg string, args ...any)

func (*Logger) Level

func (l *Logger) Level() *slog.LevelVar

func (*Logger) Log

func (l *Logger) Log(ctx context.Context, level slog.Level, msg string, args ...any)

func (*Logger) LogAttrs

func (l *Logger) LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)

func (*Logger) LoggerHandler

func (l *Logger) LoggerHandler() slog.Handler

func (*Logger) Rotate

func (l *Logger) Rotate()

func (*Logger) SetExtra

func (l *Logger) SetExtra(extra io.Writer)

func (*Logger) SetFile

func (l *Logger) SetFile(file string)

func (*Logger) SetHandler

func (l *Logger) SetHandler(h slog.Handler)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level slog.Level)

func (*Logger) SetOutput

func (l *Logger) SetOutput(file string, extra io.Writer)

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

func (*Logger) WarnContext

func (l *Logger) WarnContext(ctx context.Context, msg string, args ...any)

func (*Logger) With

func (l *Logger) With(args ...any) *Logger

func (*Logger) WithGroup

func (l *Logger) WithGroup(name string) *Logger

func (*Logger) Write

func (l *Logger) Write(b []byte) (int, error)

type Rotatable

type Rotatable interface {
	Rotate()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL