From 458d9f8050d4d7a655c9f7a7b1bb5f1c396649ab Mon Sep 17 00:00:00 2001 From: Maximilian Moehl Date: Tue, 26 Nov 2024 16:02:23 +0100 Subject: [PATCH] feat: support syslog message truncation Allow the user to specify a limit at which messages sent via syslog are truncated. --- jobs/gorouter/spec | 3 +++ jobs/gorouter/templates/gorouter.yml.erb | 1 + spec/gorouter_templates_spec.rb | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/jobs/gorouter/spec b/jobs/gorouter/spec index cdebbd5a1..868629acb 100644 --- a/jobs/gorouter/spec +++ b/jobs/gorouter/spec @@ -313,6 +313,9 @@ properties: router.logging.syslog_tag: description: "Tag to use when writing syslog messages" default: "vcap.gorouter" + router.logging.syslog_message_limit: + description: "Limit the number of bytes per access log written to syslog. A value of zero disables the limit." + default: 0 router.logging.syslog_addr: description: "Address of a syslog server to send access logs" default: "localhost:514" diff --git a/jobs/gorouter/templates/gorouter.yml.erb b/jobs/gorouter/templates/gorouter.yml.erb index 1774e6a5b..e33c2a96b 100644 --- a/jobs/gorouter/templates/gorouter.yml.erb +++ b/jobs/gorouter/templates/gorouter.yml.erb @@ -398,6 +398,7 @@ end params['logging'] = { 'syslog' => p('router.logging.syslog_tag'), + 'syslog_truncate' => p('router.logging.syslog_message_limit'), 'syslog_addr' => p('router.logging.syslog_addr'), 'syslog_network' => p('router.logging.syslog_network'), 'level' => p('router.logging_level'), diff --git a/spec/gorouter_templates_spec.rb b/spec/gorouter_templates_spec.rb index 2b90d59df..cf6826059 100644 --- a/spec/gorouter_templates_spec.rb +++ b/spec/gorouter_templates_spec.rb @@ -1386,6 +1386,19 @@ expect(parsed_yaml['logging']['syslog_network']).to eq('tcp') end end + context 'when syslog message length is set' do + before do + deployment_manifest_fragment['router']['logging'] = { 'syslog_message_limit' => 4096 } + end + it 'it properly sets the value' do + expect(parsed_yaml['logging']['syslog_truncate']).to eq(4096) + end + end + context 'when syslog message length is not set' do + it 'it properly sets default values' do + expect(parsed_yaml['logging']['syslog_truncate']).to eq(0) + end + end end end