kmsgparser

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2016 License: Apache-2.0 Imports: 8 Imported by: 64

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

This section is empty.

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 wrap a log.Logger from the golang "log" package to create a standard a logger fulfilling this interface as well.

type Message

type Message struct {
	Priority       int
	SequenceNumber int
	Timestamp      time.Time
	Message        string
}

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 provides a channel of messages read from the kernel ring buffer.
	// When first called, it will read the existing ringbuffer, after which it will emit new messages as they occur.
	Parse() <-chan Message
	// SetLogger sets the logger that will be used to report malformed kernel
	// ringbuffer lines or unexpected kmsg read errors.
	SetLogger(Logger)
	// Close closes the underlying kmsg reader for this parser
	Close() error
}

Parser is a parser for the kernel ring buffer found at /dev/kmsg

func NewParser

func NewParser() (Parser, error)

type ReadSeekCloser

type ReadSeekCloser interface {
	io.ReadCloser
	io.Seeker
}

type StandardLogger

type StandardLogger struct {
	*stdlog.Logger
}

StandardLogger adapts the "log" package's 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{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL