mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user