Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maxLength configuration option to SysLog #39958

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -687,6 +688,24 @@ private static Handler configureSyslogHandler(final SyslogConfig config, final E
handler.setTruncate(config.truncate);
handler.setUseCountingFraming(config.useCountingFraming);
handler.setLevel(config.level);
if (config.maxLength.isPresent()) {
BigInteger maxLen = config.maxLength.get().asBigInteger();
if (maxLen.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0) {
errorManager.error(
"Using 2GB as the value of maxLength for SyslogHandler as it is the maximum allowed value", null,
ErrorManager.GENERIC_FAILURE);
maxLen = BigInteger.valueOf(Integer.MAX_VALUE);
} else {
BigInteger minimumAllowedMaxLength = BigInteger.valueOf(128);
if (maxLen.compareTo(minimumAllowedMaxLength) < 0) {
errorManager.error(
"Using 128 as the value of maxLength for SyslogHandler as using a smaller value is not allowed",
null, ErrorManager.GENERIC_FAILURE);
maxLen = minimumAllowedMaxLength;
}
}
handler.setMaxLength(maxLen.intValue());
}

Formatter formatter = null;
boolean formatterWarning = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.configuration.MemorySize;

@ConfigGroup
public class SyslogConfig {
Expand Down Expand Up @@ -95,6 +96,15 @@ public class SyslogConfig {
@ConfigItem
Optional<String> filter;

/**
* The maximum length, in bytes, of the message allowed to be sent. The length includes the header and the message.
* <p>
* If not set, the default value is {@code 2048} when {@code sys-log-type} is {@code rfc5424} (which is the default)
* and {@code 1024} when {@code sys-log-type} is {@code rfc3164}
*/
@ConfigItem
Optional<MemorySize> maxLength;

/**
* Syslog async logging config
*/
Expand Down
Loading