Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/rel-3.46.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
h2o-ops committed Oct 25, 2024
2 parents 5c8584c + 6aa97cc commit 99f80a7
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 99f80a7

Please sign in to comment.