Documentation
¶
Overview ¶
Package kmsgparser implements a parser for the Linux `/dev/kmsg` format. More information about this format may be found here: https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg Some parts of it are slightly inspired by rsyslog's contrib module: https://github.com/rsyslog/rsyslog/blob/v8.22.0/contrib/imkmsg/kmsg.c
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithLogger ¶
func WithLogger(log Logger) func(p *parser)
func WithNoFollow ¶
func WithNoFollow() func(p *parser)
WithNoFollow configures Parser to stop reading and close the channel when it reaches the end of the kmsg buffer.
Types ¶
type Logger ¶
type Logger interface {
Warningf(string, ...interface{})
Infof(string, ...interface{})
Errorf(string, ...interface{})
}
Logger is a glog compatible logging interface The StandardLogger struct can be used to convert a log.Logger into this interface.
type Message ¶
Message represents a given kmsg logline, including its timestamp (as calculated based on offset from boot time), its possibly multi-line body, and so on. More information about these mssages may be found here: https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg
type Parser ¶
type Parser interface {
// SeekEnd moves the parser to the end of the kmsg queue.
SeekEnd() error
// Parse reads from kmsg and provides a channel of messages.
// Parse will always close the provided channel before returning.
// Parse may be canceled by calling 'Close' on the parser.
//
// The caller should drain the channel after calling [Close]. The caller must
// not close the channel passed in.
Parse(chan<- Message) error
Close() error
}
Parser is a parser for the kernel ring buffer found at /dev/kmsg
type StandardLogger ¶
StandardLogger adapts the log.Logger interface to be a Logger.
func (*StandardLogger) Errorf ¶
func (s *StandardLogger) Errorf(fmt string, args ...interface{})
func (*StandardLogger) Infof ¶
func (s *StandardLogger) Infof(fmt string, args ...interface{})
func (*StandardLogger) Warningf ¶
func (s *StandardLogger) Warningf(fmt string, args ...interface{})