Documentation ¶
Index ¶
- Constants
- Variables
- func BootSetup() error
- func Debug(msg string)
- func Debugf(format string, v ...interface{})
- func MockLogger() (buf *bytes.Buffer, restore func())
- func NoGuardDebugf(format string, v ...interface{})
- func Notice(msg string)
- func Noticef(format string, v ...interface{})
- func Panicf(format string, v ...interface{})
- func SetLogger(l Logger)
- func SimpleSetup(opts *LoggerOptions) error
- func StartupStageTimestamp(stage string)
- func WithLoggerLock(f func())
- type Log
- type Logger
- type LoggerOptions
Constants ¶
const ( // DefaultFlags are passed to the default console log.Logger DefaultFlags = log.Ldate | log.Ltime | log.Lmicroseconds | log.Lshortfile )
Variables ¶
var NullLogger = nullLogger{}
NullLogger is a logger that does nothing
Functions ¶
func BootSetup ¶
func BootSetup() error
BootSetup creates a logger meant to be used when running from initramfs, where we want to consider the quiet kernel option.
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf records something in the debug log
func MockLogger ¶
MockLogger replaces the existing logger with a buffer and returns the log buffer and a restore function.
func NoGuardDebugf ¶
func NoGuardDebugf(format string, v ...interface{})
NoGuardDebugf records something in the debug log
func SimpleSetup ¶
func SimpleSetup(opts *LoggerOptions) error
SimpleSetup creates the default (console) logger
func StartupStageTimestamp ¶
func StartupStageTimestamp(stage string)
StartupStageTimestamp produce snap startup timings message.
func WithLoggerLock ¶
func WithLoggerLock(f func())
WithLoggerLock invokes f with the global logger lock, useful for tests involving goroutines with MockLogger.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
func (*Log) NoGuardDebug ¶
NoGuardDebug always prints the message, w/o gating it based on environment variables or other configurations.
type Logger ¶
type Logger interface { // Notice is for messages that the user should see Notice(msg string) // Debug is for messages that the user should be able to find if they're debugging something Debug(msg string) // NoGuardDebug is for messages that we always want to print (e.g., configurations // were checked by the caller, etc) NoGuardDebug(msg string) }
A Logger is a fairly minimal logging tool.
type LoggerOptions ¶
type LoggerOptions struct { // ForceDebug can be set if we want debug traces even if not directly // enabled by environment or kernel command line. ForceDebug bool }