Skip to content

Commit

Permalink
Merge pull request #35638 from dmlloyd/preserve
Browse files Browse the repository at this point in the history
Preserve format style when adding after-shutdown message
  • Loading branch information
geoand authored Aug 31, 2023
2 parents c352f20 + 46d460d commit e19ef9f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.logging.LogRecord;

import org.jboss.logging.Logger;
import org.jboss.logmanager.ExtLogRecord;

public class LogCleanupFilter implements Filter {

Expand All @@ -30,7 +31,12 @@ public boolean isLoggable(LogRecord record) {
//we also use this filter to add a warning about errors generated after shutdown
if (record.getLevel().intValue() >= org.jboss.logmanager.Level.ERROR.intValue() && shutdownNotifier.shutdown) {
if (!record.getMessage().endsWith(SHUTDOWN_MESSAGE)) {
record.setMessage(record.getMessage() + SHUTDOWN_MESSAGE);
if (record instanceof ExtLogRecord) {
ExtLogRecord elr = (ExtLogRecord) record;
elr.setMessage(record.getMessage() + SHUTDOWN_MESSAGE, elr.getFormatStyle());
} else {
record.setMessage(record.getMessage() + SHUTDOWN_MESSAGE);
}
}
}
// Only allow filtering messages of warning level and lower
Expand Down

0 comments on commit e19ef9f

Please sign in to comment.