Skip to content

Commit

Permalink
GH-16361 allow longer pids by adding sys.ai.h2o.log.max.pid.length [n…
Browse files Browse the repository at this point in the history
…ocheck] (#16390)

* GH-16361 allow longer pids by adding sys.ai.h2o.log.max.pid.length

* add comment about sys.ai.h2o.log.max.pid.length
  • Loading branch information
krasinski authored Oct 24, 2024
1 parent 966a1f2 commit 6aa97cc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 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,15 @@ 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);
}

// set sys.ai.h2o.log.max.pid.length to avoid h2o-3 trimming PID in the logs
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 6aa97cc

Please sign in to comment.