Issue #4567 - Backport of StdErrLog 10.0.x for Throwable behavior change

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2020-02-20 13:45:40 -06:00
parent d453333a48
commit 0e536407a9
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
1 changed files with 16 additions and 20 deletions

View File

@ -92,7 +92,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
@ManagedObject("Jetty StdErr Logging Implementation") @ManagedObject("Jetty StdErr Logging Implementation")
public class StdErrLog extends AbstractLogger public class StdErrLog extends AbstractLogger
{ {
private static final String EOL = System.getProperty("line.separator"); private static final String EOL = System.lineSeparator();
private static final Object[] EMPTY_ARGS = new Object[0]; private static final Object[] EMPTY_ARGS = new Object[0];
// Do not change output format lightly, people rely on this output format now. // Do not change output format lightly, people rely on this output format now.
private static int __tagpad = Integer.parseInt(Log.__props.getProperty("org.eclipse.jetty.util.log.StdErrLog.TAG_PAD", "0")); private static int __tagpad = Integer.parseInt(Log.__props.getProperty("org.eclipse.jetty.util.log.StdErrLog.TAG_PAD", "0"));
@ -132,13 +132,11 @@ public class StdErrLog extends AbstractLogger
__tagpad = pad; __tagpad = pad;
} }
@SuppressWarnings("UnusedAssignment") private int _level;
private int _level = LEVEL_INFO;
// Level that this Logger was configured as (remembered in special case of .setDebugEnabled()) // Level that this Logger was configured as (remembered in special case of .setDebugEnabled())
private int _configuredLevel; private int _configuredLevel;
private PrintStream _stderr = System.err; private PrintStream _stderr = System.err;
@SuppressWarnings("UnusedAssignment") private boolean _source;
private boolean _source = __source;
// Print the long form names, otherwise use abbreviated // Print the long form names, otherwise use abbreviated
private boolean _printLongNames = __long; private boolean _printLongNames = __long;
// The full log name, as provided by the system. // The full log name, as provided by the system.
@ -353,26 +351,24 @@ public class StdErrLog extends AbstractLogger
@Override @Override
public void setDebugEnabled(boolean enabled) public void setDebugEnabled(boolean enabled)
{ {
if (enabled) int level = enabled ? LEVEL_DEBUG : this.getConfiguredLevel();
{ this.setLevel(level);
this._level = LEVEL_DEBUG;
String name = getName();
for (Logger log : Log.getLoggers().values()) for (Logger log : Log.getLoggers().values())
{ {
if (log.getName().startsWith(getName()) && log instanceof StdErrLog) if (log.getName().startsWith(name) && log instanceof StdErrLog)
((StdErrLog)log).setLevel(LEVEL_DEBUG);
}
}
else
{ {
this._level = this._configuredLevel; StdErrLog logger = (StdErrLog)log;
level = enabled ? LEVEL_DEBUG : logger.getConfiguredLevel();
logger.setLevel(level);
}
}
}
for (Logger log : Log.getLoggers().values()) private int getConfiguredLevel()
{ {
if (log.getName().startsWith(getName()) && log instanceof StdErrLog) return _configuredLevel;
((StdErrLog)log).setLevel(((StdErrLog)log)._configuredLevel);
}
}
} }
public int getLevel() public int getLevel()