Documentation
¶
Overview ¶
Package kmsg provides access to kernel log.
Index ¶
Constants ¶
const ( CPUCaller = 'C' ThreadCaller = 'T' )
Types of callers a kmsg can originate from.
ref: https://elixir.bootlin.com/linux/v6.6.22/source/kernel/printk/printk.c#L629
const MaxLineLength = 1024 - 48
MaxLineLength to be passed to kmsg, see https://github.com/torvalds/linux/blob/master/kernel/printk/printk.c#L450.
Variables ¶
This section is empty.
Functions ¶
func SetupLogger ¶
SetupLogger configures the logger to write to the kernel ring buffer via /dev/kmsg.
If logger is nil, default `log` logger is redirectred.
If extraWriter is not nil, logs will be copied to it as well.
Types ¶
type Caller ¶ added in v0.1.5
type Caller struct {
Type CallerType
ID uint32
}
Caller struct containing the type and ID from kmsg logs with PRINTK_CALLER support.
type CallerType ¶ added in v0.1.5
type CallerType byte
CallerType is a single char byte caller type in kmsg logs with PRINTK_CALLER support.
type Facility ¶
type Facility int
Facility is an attribute of kernel log message.
type Message ¶
type Message struct {
Timestamp time.Time
Message string
Facility Facility
Priority Priority
SequenceNumber int64
Clock int64
Caller Caller
}
Message is a parsed kernel log message.
func ParseMessage ¶
ParseMessage parses internal kernel log format.
Reference: https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg
type Reader ¶
type Reader interface {
// Scan and issue parsed messages.
//
// Scan stops when context is canceled or when EOF is reached
// in NoFollow mode.
Scan(ctx context.Context) <-chan Packet
// Close releases resources associated with the Reader.
Close() error
}
Reader for /dev/kmsg messages.