package kmsgparser

import "github.com/euank/go-kmsg-parser/kmsgparser"

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

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 {
	// 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 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{})

Source Files

kmsgparser.go log.go

Version
v1.0.0 (latest)
Published
Nov 14, 2016
Platform
js/wasm
Imports
8 packages
Last checked
now

Tools for package owners.