Skip to content

Add a NoFormat option (just forwarding log line) #84

@fmaylinch

Description

@fmaylinch

I created this myself, but it could be added to the library. For logs that do not conform to standards.

// --- Dummy format that just puts the whole log line in logParts["content"] ---

// Actually, the syslog.RFC3164 format also puts the unparsed "content" field,
// but wastes times trying to parse lines that have a custom format.

var noFormat = &NoFormat{}

type NoFormat struct{}

func (f NoFormat) GetParser(line []byte) format.LogParser {
	return &noFormatParser{string(line)}
}

func (f NoFormat) GetSplitFunc() bufio.SplitFunc {
	return nil // not used
}

type noFormatParser struct {
	line string
}

func (c noFormatParser) Dump() format.LogParts {
	return format.LogParts{
		"content": string(c.line),
	}
}

func (c noFormatParser) Parse() error {
	return nil // doesn't parse anything
}

func (c noFormatParser) Location(location *time.Location) {
	// not used
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions