Documentation ¶
Overview ¶
Example ¶
SetLogFile(os.Stdout) Bad("Bad") Emph("Emph") Error("Error") Good("Good") Info("Info") Warn("Warn")
Output: [✗] Bad [*] Emph [!!] Error [✓] Good [·] Info [!] Warn
Index ¶
- func Bad(a ...any)
- func Badf(format string, a ...any)
- func Badln(a ...any)
- func Emph(a ...any)
- func Emphf(format string, a ...any)
- func Emphln(a ...any)
- func Error(a ...any)
- func Errorf(format string, a ...any)
- func Errorln(a ...any)
- func Fatal(a ...any)
- func FatalIfErr(err error)
- func Fatalf(format string, a ...any)
- func Fatalln(a ...any)
- func Good(a ...any)
- func Goodf(format string, a ...any)
- func Goodln(a ...any)
- func Info(a ...any)
- func Infof(format string, a ...any)
- func Infoln(a ...any)
- func Output(style func(string) string, prefix string, s string)
- func Panic(a ...any)
- func PanicIfErr(err error)
- func Panicf(format string, a ...any)
- func Panicln(a ...any)
- func Print(prefix string, a ...any)
- func Printf(prefix, format string, a ...any)
- func Println(prefix string, a ...any)
- func SetColorsEnabled(b bool)
- func SetLogFile(f *os.File)
- func SetTimestampEnabled(b bool)
- func Warn(a ...any)
- func Warnf(format string, a ...any)
- func Warnln(a ...any)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fatal ¶ added in v1.3.0
func Fatal(a ...any)
Fatal is equivalent to Error() followed by a call to os.Exit(1).
func FatalIfErr ¶ added in v1.4.0
func FatalIfErr(err error)
FatalIfErr is equivalent to Fatal() if err is not nil, otherwise does nothing.
func Fatalln ¶ added in v1.4.0
func Fatalln(a ...any)
Fatalln is equivalent to Errorln() followed by a call to os.Exit(1).
func Output ¶ added in v1.4.0
Output writes a log message to the log file. This is the most basic log function, and is used by the other log functions. May be used to write custom log messages.
The style function is used to format the message (prefix and message). If style is nil, the message is not formatted.
The prefix is the string that is printed before the message.
If timestamp is enabled, the timestamp is printed between the prefix and the message. The timestamp styling is not customizable.
A newline is added to the end of the message, unless the message already ends with a newline.
func Panic ¶ added in v1.4.0
func Panic(a ...any)
Panic is equivalent to Error() followed by a call to panic().
func PanicIfErr ¶ added in v1.4.0
func PanicIfErr(err error)
PanicIfErr is equivalent to Panic() if err is not nil, otherwise does nothing.
func Panicln ¶ added in v1.4.0
func Panicln(a ...any)
Panicln is equivalent to Errorln() followed by a call to panic().
func Print ¶ added in v1.4.0
Print writes a message with custom prefix, without any formatting or coloring, to the log file.
func SetColorsEnabled ¶
func SetColorsEnabled(b bool)
SetColorsEnabled enables or disables colors (and bold formatting) in the log output. Colors are enabled by default.
func SetLogFile ¶
SetLogFile sets the file to write logs messages to. If the file is a TTY colors will be enabled, unless the user has explicitly disabled colors.
func SetTimestampEnabled ¶
func SetTimestampEnabled(b bool)
SetTimestampEnabled enables or disables timestamps in the log output. Timestamps are disabled by default.
Types ¶
This section is empty.