Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = New()
var Env = "TESTKIT_LOG"
Env is the default name of the environment variable that contains the log entries.
Functions ¶
Types ¶
type Level ¶
type Level int8
Level is enum for log levels.
The larger the value, the more verbose the log. For example, if you want to print something only when the configured log level is "info" or higher, you can write:
if configuedLogLevel >= log.Info { // Printed only when the configured log level is "info" or "debug" fmt.Println("something") }
type Leveled ¶
type Leveled struct {
Debug, Info, Error Printer
// contains filtered or unexported fields
}
func (*Leveled) Enabled ¶
Enabled returns true if the given log entry is enabled.
The log entry is enabled if the TESTKIT_LOG environment variable contains the entry. Each entry is separated by a comma, and in the form of "name=level". The name is the name of the component that is logging, and the level is the log level. The level can be one of the following: "debug", "info", "warn", "error".
For example, "kind=debug" enables debug logging for the kind provider. The component that is logging should check if the log entry is enabled before logging.
That said, every component's logging code should look like this:
if l.Enabled("kind=debug") { l.Logf("debug message") } if l.Enabled("terraform=info") { l.Logf("info message") }
Any Logf call that is not wrapped in an Enabled call is considered a bug.
The debug log is only printed if the TESTKIT_LOG environment variable contains any of the following entries: - "kind=debug" - "debug"
The info log is only printed if the TESTKIT_LOG environment variable contains any of the following entries: - "terraform=info" - "info" - "debug"
As said previously, TESTKIT_LOG is a comma-separated list of log entries. TESTKIT_LOG=kind=debug,terraform=info is valid, and enables debug logging for the kind provider and info logging for the terraform provider.
type Printer ¶
type Printer interface {
Printf(format string, a ...interface{})
}
Printer is the interface for loggers to print logs. It can be anything that implements Printf(string, ...interface{}).
type PrinterFunc ¶
type PrinterFunc func(format string, a ...interface{})
func (PrinterFunc) Printf ¶
func (f PrinterFunc) Printf(format string, a ...interface{})