Documentation
¶
Overview ¶
Package kuttilog implements a simple levelled logging system. The SetLevel function sets the current level. The Print, Printf and Println functions all take a level parameter, and only log if it is less than or equal to the current level.
The package provides a Logger interface, so that the actual output can vary between implementations. The SetLogger method can be called with an appropriate implementation. There is a default implementation, which uses a standard output logger created using the Go standard log package.
Levels begin at 0, and can go up to a implemetation-specific maximum. The default logger provides five levels: Quiet(0), Minimal(1), Info(2), Verbose(3) and Debug(4).
Index ¶
Constants ¶
const ( Quiet = 0 Minimal = 1 Info = 2 Verbose = 3 Debug = 4 )
Default Log levels
Variables ¶
This section is empty.
Functions ¶
func MaxLevel ¶
func MaxLevel() int
MaxLevel returns the highest level permitted by the current logger.
func Print ¶
func Print(level int, v ...interface{})
Print prints to the log, if the level is <= current log level. Arguments are handled in the manner of fmt.Print.
func Printf ¶
Printf prints to the log, if the level is <= current log level. Arguments are handled in the manner of fmt.Printf.
func Println ¶
func Println(level int, v ...interface{})
Println prints to the log, if the level is <= current log level. Arguments are handled in the manner of fmt.Println.
func Setloglevel ¶
func Setloglevel(newlevel int)
Setloglevel sets the current log level. If level is below 0 or greater than MaxLevel, it is not changed.
Types ¶
type Logger ¶
type Logger interface {
MaxLevel() int // The maximum level permitted by this logger
LevelPrefix(level int) string // The logger-supplied prefix string for a level.
Print(v ...interface{})
Printf(format string, v ...interface{})
Println(v ...interface{})
}
Logger contains methods for implemetation-specific logging. Exact destination, formatting etc. is implementation-specific. Kuttilog will call each print method only if needed. It will also append a level prefix string as the first item output. Implementations can provide their own prefix strings.