Documentation ¶
Index ¶
- Constants
- func Debug(format string, v ...any)
- func Error(format string, v ...any)
- func Fatal(v ...any)
- func Fatalf(format string, v ...any)
- func Fatalln(v ...any)
- func Flags() int
- func Info(format string, v ...any)
- func Level() int
- func LevelString() string
- func Log(level int, format string, v ...any)
- func Output(calldepth int, s string) error
- func Panic(v ...any)
- 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 SetLevel(level int)
- func SetOutput(w io.Writer)
- func SetPrefix(prefix string)
- func Warn(format string, v ...any)
- func Writer() io.Writer
- type Logger
- func (l *Logger) Debug(format string, v ...any)
- func (l *Logger) Error(format string, v ...any)
- func (l *Logger) Fatal(v ...any)
- func (l *Logger) Fatalf(format string, v ...any)
- func (l *Logger) Fatalln(v ...any)
- func (l *Logger) Flags() int
- func (l *Logger) Info(format string, v ...any)
- func (l *Logger) Level() int
- func (l *Logger) LevelString() string
- func (l *Logger) Log(level int, format string, v ...any)
- func (l *Logger) Output(calldepth int, s string, level ...int) error
- func (l *Logger) Panic(v ...any)
- 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 int)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetPrefix(prefix string)
- func (l *Logger) Warn(format string, v ...any)
- func (l *Logger) Writer() io.Writer
- type RotateFile
- type TimedRotateFile
Constants ¶
const ( FlagDate = 1 << iota // the date in the local time zone: 2009/01/23 FlagTime // the time in the local time zone: 01:23:23 FlagMtime // microsecond resolution: 01:23:23.123123. assumes Ltime. FlagLFile // full file name and line number: /a/b/c/d.go:23 FlagSFile // final file name element and line number: d.go:23. overrides Llongfile FlagUTC // if Ldate or Ltime is set, use UTC rather than the local time zone FlagPrefix // move the "prefix" from the beginning of the line to before the message FlagLevel FlagStd = FlagDate | FlagTime | FlagLevel // initial values for the standard logger LevelError = iota LevelWarn LevelInfo LevelDebug )
Variables ¶
This section is empty.
Functions ¶
func Fatal ¶ added in v0.1.1
func Fatal(v ...any)
Fatal is equivalent to Print() followed by a call to os.Exit(1).
func Fatalln ¶ added in v0.1.2
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 LevelString ¶ added in v0.1.2
func LevelString() string
func Output ¶ added in v0.1.2
Output writes the output for a logging event. The string s contains the text to print after the prefix specified by the flags of the Logger. A newline is appended if the last character of s is not already a newline. Calldepth is the count of the number of frames to skip when computing the file name and line number if Llongfile or Lshortfile is set; a value of 1 will print the details for the caller of Output.
func Panic ¶ added in v0.1.1
func Panic(v ...any)
Panic is equivalent to Print() followed by a call to panic().
func Panicln ¶ added in v0.1.2
func Panicln(v ...any)
Panicln is equivalent to Println() followed by a call to panic().
func Prefix ¶ added in v0.1.2
func Prefix() string
Prefix returns the output prefix for the standard logger.
func Print ¶ added in v0.1.2
func Print(v ...any)
Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.
func Printf ¶ added in v0.1.2
Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
func Println ¶ added in v0.1.2
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.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger represents an active logging object that generates lines of output to an io.Writer. Each logging operation makes a single call to the Writer's Write method. A Logger can be used simultaneously from multiple goroutines; it guarantees to serialize access to the Writer.
func Default ¶
func Default() *Logger
Default returns the standard logger used by the package-level output functions.
func (*Logger) Fatal ¶ added in v0.1.1
Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
func (*Logger) Fatalln ¶ added in v0.1.2
Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
func (*Logger) Flags ¶
Flags returns the output flags for the logger. The flag bits are Ldate, Ltime, and so on.
func (*Logger) LevelString ¶ added in v0.1.2
func (*Logger) Panic ¶ added in v0.1.1
Panic is equivalent to l.Print() followed by a call to panic().
func (*Logger) Panicln ¶ added in v0.1.2
Panicln is equivalent to l.Println() followed by a call to panic().
func (*Logger) Print ¶ added in v0.1.2
Print calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Print.
func (*Logger) Printf ¶ added in v0.1.2
Printf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Println ¶ added in v0.1.2
Println calls l.Output 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.
type RotateFile ¶ added in v0.1.2
type RotateFile struct {
// contains filtered or unexported fields
}
func NewRotateFile ¶ added in v0.1.2
func NewRotateFile(fileName string, backupCount int, fileSize int64, async bool) (*RotateFile, error)
fileName: log file path: a/b/c.log backupCount: backup files, if backupCount=3: a.log a.log-2023-12-01 a.log-2023-12-02 a.log-2023-12-03 fileSize: log file max size, default size 16m async: asynchronous write
func (*RotateFile) Close ¶ added in v0.1.2
func (self *RotateFile) Close() error
func (*RotateFile) IsAsync ¶ added in v0.1.2
func (self *RotateFile) IsAsync() bool
type TimedRotateFile ¶ added in v0.1.2
type TimedRotateFile struct {
// contains filtered or unexported fields
}
func NewTimedRotateFile ¶ added in v0.1.2
func NewTimedRotateFile(fileName string, backupCount int, fileSize int64, async bool) (*TimedRotateFile, error)
backup yesterday's files at 00:00 every day fileName: log file path: a/b/c.log backupCount: backup files, if backupCount=3: a.log a.log-2023-12-01 a.log-2023-12-02 a.log-2023-12-03 fileSize: log file max size, default size 16m async: asynchronous write
func (*TimedRotateFile) Close ¶ added in v0.1.2
func (self *TimedRotateFile) Close() error
func (*TimedRotateFile) IsAsync ¶ added in v0.1.2
func (self *TimedRotateFile) IsAsync() bool