[bugfix] Trim log entries to 1700 chars before they enter syslog (#493)

* start implementing trimming hook

* add test with very long test

* test syslog w/ unix socket + long (trimmed) msg

* trim long entries with trimhook

* trim to 1700 chars instead
This commit is contained in:
tobi
2022-04-26 17:55:24 +02:00
committed by GitHub
parent 2259838108
commit 728c4a5e38
4 changed files with 122 additions and 3 deletions

View File

@@ -53,3 +53,26 @@ func InitTestSyslog() (*syslog.Server, chan format.LogParts, error) {
return server, channel, nil
}
// InitTestSyslog returns a test syslog running on a unix socket, and a channel for reading
// messages sent to the server, or an error if something goes wrong.
//
// Callers of this function should call Kill() on the server when they're finished with it!
func InitTestSyslogUnixgram(address string) (*syslog.Server, chan format.LogParts, error) {
channel := make(syslog.LogPartsChannel)
handler := syslog.NewChannelHandler(channel)
server := syslog.NewServer()
server.SetFormat(syslog.Automatic)
server.SetHandler(handler)
if err := server.ListenUnixgram(address); err != nil {
return nil, nil, err
}
if err := server.Boot(); err != nil {
return nil, nil, err
}
return server, channel, nil
}