diff options
| author | 2022-04-26 17:55:24 +0200 | |
|---|---|---|
| committer | 2022-04-26 17:55:24 +0200 | |
| commit | 728c4a5e380cd2feef6f0f49422b3dd8297c71db (patch) | |
| tree | 4be01a63275f8180c0a63c488ad3f0d3e6118bc4 /testrig | |
| parent | [bugfix] Fix CWs not showing sometimes (#488) (diff) | |
| download | gotosocial-728c4a5e380cd2feef6f0f49422b3dd8297c71db.tar.xz | |
[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
Diffstat (limited to 'testrig')
| -rw-r--r-- | testrig/log.go | 23 | 
1 files changed, 23 insertions, 0 deletions
| diff --git a/testrig/log.go b/testrig/log.go index 5e60cad56..68d548260 100644 --- a/testrig/log.go +++ b/testrig/log.go @@ -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 +} | 
