Documentation ¶
Index ¶
- Constants
- func Debug(ctx context.Context, msg string, fields Fields)
- func Error(ctx context.Context, msg string, fields Fields)
- func Fatal(v ...any)
- func FatalContext(ctx context.Context, msg string, fields Fields)
- func Fatalf(format string, v ...any)
- func Fatalln(v ...any)
- func Flags() int
- func Info(ctx context.Context, msg string, fields Fields)
- func Output(calldepth int, s string) error
- func Panic(v ...any)
- func PanicContext(ctx context.Context, msg string, fields Fields)
- func Panicf(format string, v ...any)
- func Panicln(v ...any)
- func Prefix() string
- func Print(v ...any)
- func Printf(format string, v ...any)
- func Println(v ...any)
- func SetFlags(flag int)
- func SetOutput(w io.Writer)
- func SetPrefix(prefix string)
- func Trace(ctx context.Context, msg string, fields Fields)
- func Warn(ctx context.Context, msg string, fields Fields)
- func With(parent context.Context, fields Fields) context.Context
- func Writer() io.Writer
- type Fields
- type Level
- type Logger
- func (l *Logger) Debug(ctx context.Context, msg string, fields Fields)
- func (l *Logger) Error(ctx context.Context, msg string, fields Fields)
- func (l *Logger) Fatal(v ...any)
- func (l *Logger) FatalContext(ctx context.Context, msg string, fields Fields)
- func (l *Logger) Fatalf(format string, v ...any)
- func (l *Logger) Fatalln(v ...any)
- func (l *Logger) Flags() int
- func (l *Logger) Info(ctx context.Context, msg string, fields Fields)
- func (l *Logger) Level() Level
- func (l *Logger) Output(calldepth int, s string) error
- func (l *Logger) OutputContext(ctx context.Context, calldepth int, level Level, msg string, fields Fields) error
- func (l *Logger) Panic(v ...any)
- func (l *Logger) PanicContext(ctx context.Context, msg string, fields Fields)
- func (l *Logger) Panicf(format string, v ...any)
- func (l *Logger) Panicln(v ...any)
- func (l *Logger) Prefix() string
- func (l *Logger) Print(v ...any)
- func (l *Logger) Printf(format string, v ...any)
- func (l *Logger) Println(v ...any)
- func (l *Logger) SetFlags(flag int)
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetPrefix(prefix string)
- func (l *Logger) Trace(ctx context.Context, msg string, fields Fields)
- func (l *Logger) Warn(ctx context.Context, msg string, fields Fields)
- func (l *Logger) Writer() io.Writer
Constants ¶
const ( Ldate = 1 << iota // the date in the local time zone in RFC3339: 2009-01-23 Ltime // the time in the local time zone in RFC3339: 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 | Lmicroseconds // initial values for the standard logger )
Variables ¶
This section is empty.
Functions ¶
func FatalContext ¶
FatalContext writes the output for a fatal level logging event.
func Fatalln ¶
func Fatalln(v ...any)
Fatalln is equivalent to Println() followed by a call to os.Exit(1).
func Flags ¶
func Flags() int
Flags returns the output flags for the standard logger. The flag bits are Ldate, Ltime, and so on.
func PanicContext ¶
PanicContext writes the output for an panic level logging event.
func Panicln ¶
func Panicln(v ...any)
Panicln is equivalent to Println() followed by a call to panic().
func Print ¶
func Print(v ...any)
Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.
func Printf ¶
Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
func Println ¶
func Println(v ...any)
Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.
func SetFlags ¶
func SetFlags(flag int)
SetFlags sets the output flags for the standard logger. The flag bits are Ldate, Ltime, and so on.
func SetPrefix ¶
func SetPrefix(prefix string)
SetPrefix sets the output prefix for the standard logger.
Types ¶
type Level ¶
type Level int
Level defines log levels.
const ( // LevelDebug defines debug log level. LevelDebug Level = iota // LevelInfo defines info log level. LevelInfo // LevelWarn defines warn log level. LevelWarn // LevelError defines error log level. LevelError // LevelFatal defines fatal log level. LevelFatal // LevelPanic defines panic log level. LevelPanic // LevelNo defines an absent log level. LevelNo // LevelDisabled disables the logger. LevelDisabled // LevelTrace defines trace log level. LevelTrace Level = -1 )
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func Default ¶
func Default() *Logger
Default returns the standard logger used by the package-level output functions.
func (*Logger) FatalContext ¶
FatalContext writes the output for a fatal level logging event.
func (*Logger) Flags ¶
Flags returns the output flags for the logger. The flag bits are Ldate, Ltime, and so on.
func (*Logger) OutputContext ¶
func (l *Logger) OutputContext(ctx context.Context, calldepth int, level Level, msg string, fields Fields) error
Output writes the output for a logging event.
func (*Logger) PanicContext ¶
PanicContext writes the output for an panic level logging event.
func (*Logger) Print ¶
Print calls l.OutputContext to print to the logger. Arguments are handled in the manner of fmt.Print.
func (*Logger) Printf ¶
Printf calls l.OutputContext to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Println ¶
Println calls l.OutputContext to print to the logger. Arguments are handled in the manner of fmt.Println.
func (*Logger) SetFlags ¶
SetFlags sets the output flags for the logger. The flag bits are Ldate, Ltime, and so on.