Skip to content

Commit

Permalink
Merge pull request #39958 from geoand/#39944
Browse files Browse the repository at this point in the history
Add maxLength configuration option to SysLog
  • Loading branch information
geoand authored Apr 9, 2024
2 parents e999ca5 + 0e33c10 commit 1cc06e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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

0 comments on commit 1cc06e4

Please sign in to comment.