Documentation ¶
Overview ¶
Package ulog exposes logging via a Go interface.
ulog has three implementations of the Logger interface: a Go standard library "log" package Logger, a kernel syslog (dmesg) Logger, and a test Logger that logs via a test's testing.TB.Logf. To use the test logger import "ulog/ulogtest".
Index ¶
- Variables
- type KLog
- func (k *KLog) ClearLog() error
- func (k *KLog) Print(v ...interface{})
- func (k *KLog) Printf(format string, v ...interface{})
- func (k *KLog) Read(b []byte) (int, error)
- func (k *KLog) ReadClear(b []byte) (int, error)
- func (k *KLog) Reinit()
- func (k *KLog) SetConsoleLogLevel(level KLogLevel) error
- func (k *KLog) SetLogLevel(level KLogLevel)
- type KLogLevel
- type Logger
Constants ¶
This section is empty.
Variables ¶
var KernelLog = &KLog{ LogLevel: uintptr(KLogInfo), }
KernelLog is a logger that prints to the kernel syslog buffer.
Default log level is KLogInfo.
If the syslog buffer cannot be written to, KernelLog falls back to Log.
Functions ¶
This section is empty.
Types ¶
type KLog ¶
type KLog struct { // FD for /dev/kmsg if it was openable. *os.File // LogLevel is the LogLevel to print with. // // Should only be accessed atomically. LogLevel uintptr }
KLog is a logger to the kernel syslog buffer.
func (*KLog) Print ¶
func (k *KLog) Print(v ...interface{})
Print formats using the default operands for v and writes to kernel logging.
func (*KLog) SetConsoleLogLevel ¶
SetConsoleLogLevel sets the console level with syslog(2).
After this call, only messages with a level value lower than the one specified will be printed to console by the kernel.
func (*KLog) SetLogLevel ¶
SetLogLevel sets the level that Printf and Print log to syslog with.
type Logger ¶
type Logger interface { Printf(format string, v ...interface{}) Print(v ...interface{}) }
Logger is a log receptacle.
It puts your information somewhere for safekeeping.
Log is a Logger that prints to stderr, like the default log package.
var Null Logger = emptyLogger{}
Null is a logger that prints nothing.