Skip to content

Commit

Permalink
GH-16361 allow longer pids by adding sys.ai.h2o.log.max.pid.length
Browse files Browse the repository at this point in the history
  • Loading branch information
krasinski committed Sep 16, 2024
1 parent 5deeb84 commit 68947a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions h2o-core/src/main/java/water/util/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ abstract public class Log {
public static final byte INFO = 3;
public static final byte DEBUG= 4;
public static final byte TRACE= 5;

public static final String[] LVLS = { "FATAL", "ERRR", "WARN", "INFO", "DEBUG", "TRACE" };
private static final String PROP_MAX_PID_LENGTH = H2O.OptArgs.SYSTEM_PROP_PREFIX + "log.max.pid.length";

private static int _level = INFO;
private static boolean _quiet = false;
Expand Down Expand Up @@ -262,7 +262,14 @@ public static String getLogFilePath(String level) {

private static String getHostPortPid() {
String host = H2O.SELF_ADDRESS.getHostAddress();
return fixedLength(host + ":" + H2O.API_PORT + " ", 22) + fixedLength(H2O.PID + " ", 6);
return fixedLength(host + ":" + H2O.API_PORT + " ", 22) + fixedLength(H2O.PID + " ", maximumPidLength() + 2);
}

private static int maximumPidLength() {
String maxPidPropertyValue = System.getProperty(PROP_MAX_PID_LENGTH);
return maxPidPropertyValue != null
? Integer.parseInt(maxPidPropertyValue)
: 4;
}

private static synchronized Logger createLog4j() {
Expand Down

0 comments on commit 68947a1

Please sign in to comment.