Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileWriter ¶ added in v0.4.0
func NewFileWriter(path string) (io.WriteCloser, error)
NewFileWriter returns a writer that writes to the specified file.
func NewRotatorWriter ¶ added in v0.4.0
NewRotatorWriter returns a writer that writes to the specified file and rotates the file (zips the log to a numbered gz file and creates a new uncompressed log file) when the specified size is reached. If maxFiles is zero, the log is not rotated. Be sure to Close the returned writer.
Types ¶
type LazyHex ¶ added in v0.4.0
type LazyHex []byte
LazyHex is a helper type for when logging a byte slice as a hexadecimal string, but only when it is actually printed. For example, in a debug log that may not be printed unless the logging level is set to debug. Note that in printf style logging with %x this is not an issue, but with the pervasive trend of providing key value pairs, this is not possible.
type Level ¶
type Level int
func ParseLevel ¶ added in v0.2.0
ParseLevel parses a string into a log level. Use Level.String to go from a Level to a string.
func (Level) MarshalText ¶ added in v0.4.0
func (Level) String ¶ added in v0.4.0
String returns the string representation of the log level. Use ParseLevel to go from a string to a Level.
func (*Level) UnmarshalText ¶ added in v0.4.0
type Logger ¶
type Logger interface { KVLogger // (msg string, args ...any) where args are key-value pairs Loggerf // (msg string, args ...any) where args are printf like arguments Loggerln // (a ...any) in the manner of println LoggerMaker }
var DiscardLogger Logger = &discardLogger{} // New(WithWriter(io.Discard))
func NewStdoutLogger ¶ added in v0.4.0
func NewStdoutLogger() Logger
type LoggerMaker ¶ added in v0.4.0
type Option ¶ added in v0.4.0
type Option func(*options)