package
0.4.3
Repository: https://github.com/heroku/x.git
Documentation: pkg.go.dev

# README

logplex/encoding

What's this?

A set of libraries we use to parse messages, and to also publish these same syslog RFC5424 messages.

How to use?

We have 2 scanners available. If you're trying to build a logplex compatible ingress, you can use the regular scanner.

Scanner

func handler(w http.ResponseWriter, r *http.Request) {
	s := NewScanner(r.Body)

	for s.Scan() {
		log.Printf("%+v", scanner.Message())
	}

	if s.Err() != nil {
		log.Printf("err: %v", s.Err())
	}
}

DrainScanner

If the intent is to write an application which acts as a heroku drain, then using the DrainScanner is preferrable -- primarily because it doesn't require structured data.

func handler(w http.ResponseWriter, r *http.Request) {
	s := NewDrainScanner(r.Body)

	for s.Scan() {
		log.Printf("%+v", scanner.Message())
	}

	if s.Err() != nil {
		log.Printf("err: %v", s.Err())
	}
}

# Functions

Decode converts a rfc5424 message to our model.
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.
NewDrainScanner returns a scanner for use with drain endpoints.
NewPlain creates a plain encoder.
NewScanner is a syslog octet frame stream parser.
NewSSE instantiates a new SSE encoder.
No description provided by the author
SyslogSplitFunc splits the data based on the defined length prefix.
TruncatingSyslogSplitFunc enforces a maximum line length after parsing.
No description provided by the author
No description provided by the author

# Constants

FlexibleSyslogTimeFormat accepts both 'Z' and TZ notation for event time.
HumanTimeFormat defines the human friendly time format used in CLI/UI.
L15Error is the message returned with an L15 error.
MaxFrameLength is the maximum message size to parse.
OptimalFrameLength is the initial buffer size for scanning.
SyslogTimeFormat defines the exact time format used in our logs.

# Variables

ErrBadFrame is returned when the scanner cannot parse syslog message boundaries.
ErrInvalidMessage returned when trying to encode an invalid syslog message.
ErrInvalidPriVal is returned when pri-val is not properly formatted.
ErrInvalidStructuredData is returned when structure data has any value other than '-' (blank).

# Structs

Message is a syslog message.

# Interfaces

Encoder abstracts away how messages are written out.
Scanner is the general purpose primitive for parsing message bodies coming from log-shuttle, logfwd, logplex and all sorts of logging components.

# Type aliases

No description provided by the author