Documentation ¶
Index ¶
Constants ¶
const ( // MaxFrameLength is the maximum message size to parse MaxFrameLength = 10240 // OptimalFrameLength is the initial buffer size for scanning OptimalFrameLength = 1024 )
const FlexibleSyslogTimeFormat = "2006-01-02T15:04:05.999999Z07:00"
FlexibleSyslogTimeFormat accepts both 'Z' and TZ notation for event time.
const HumanTimeFormat = "2006-01-02T15:04:05.000000-07:00"
HumanTimeFormat defines the human friendly time format used in CLI/UI.
const L15Error = "L15: Error displaying log lines. Please try again."
L15Error is the message returned with an L15 error
const SyslogTimeFormat = "2006-01-02T15:04:05.999999-07:00"
SyslogTimeFormat defines the exact time format used in our logs.
Variables ¶
var ( // ErrBadFrame is returned when the scanner cannot parse syslog message boundaries ErrBadFrame = errors.New("bad frame") // ErrInvalidStructuredData is returned when structure data has any value other than '-' (blank) ErrInvalidStructuredData = errors.New("invalid structured data") // ErrInvalidPriVal is returned when pri-val is not properly formatted ErrInvalidPriVal = errors.New("invalid pri-val") )
var ErrInvalidMessage = errors.New("invalid message")
ErrInvalidMessage returned when trying to encode an invalid syslog message
Functions ¶
func Encode ¶
Encode serializes a syslog message into their wire format ( octet-framed syslog ) Disabling RFC 5424 compliance is the default and needed due to https://github.com/heroku/logplex/issues/204
func SyslogSplitFunc ¶ added in v0.0.31
SyslogSplitFunc splits the data based on the defined length prefix. format: 64 <190>1 2019-07-20T17:50:10.879238Z shuttle token shuttle - - 99\n65 <190>1 2019-07-20T17:50:10.879238Z shuttle token shuttle - - 100\n ^ frame size ^ boundary
func TruncatingSyslogSplitFunc ¶ added in v0.0.31
TruncatingSyslogSplitFunc enforces a maximum line length after parsing.
Types ¶
type Encoder ¶
Encoder abstracts away how messages are written out
type Message ¶
type Message struct { Timestamp time.Time Hostname string Application string Process string ID string Message string Version uint16 Priority uint8 RFCCompliant bool }
Message is a syslog message
type Scanner ¶
Scanner is the general purpose primitive for parsing message bodies coming from log-shuttle, logfwd, logplex and all sorts of logging components.
func NewDrainScanner ¶
func NewDrainScanner(r io.Reader, opts ...ScannerOption) Scanner
NewDrainScanner returns a scanner for use with drain endpoints. The primary difference is that it's loose and doesn't check for structured data.
func NewScanner ¶
func NewScanner(r io.Reader, opts ...ScannerOption) Scanner
NewScanner is a syslog octet frame stream parser
type ScannerOption ¶ added in v0.0.31
type ScannerOption func(*syslogScanner)
func RFCCompliant ¶ added in v0.0.31
func RFCCompliant(compliant bool) ScannerOption
func WithBuffer ¶ added in v0.0.31
func WithBuffer(optimalFrameLength, maxFrameLength int) ScannerOption
func WithSplit ¶ added in v0.0.31
func WithSplit(splitFunc bufio.SplitFunc) ScannerOption