Skip to content

Commit

Permalink
Cater to legacy handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Nov 28, 2023
1 parent 393579f commit d34ac96
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/org/jboss/logmanager/LoggerNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.logging.Filter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;

import io.smallrye.common.constraint.Assert;
import io.smallrye.common.ref.PhantomReference;
Expand Down Expand Up @@ -428,10 +429,26 @@ void setUseParentHandlers(final boolean useParentHandlers) {
}
}

@SuppressWarnings("deprecation") // record#getFormattedMessage
void publish(final ExtLogRecord record) {
LogRecord oldRecord = null;
for (Handler handler : getHandlers())
try {
handler.publish(record);
if (handler instanceof ExtHandler) {
handler.publish(record);
} else {
// old-style handlers generally don't know how to handle printf formatting
if (oldRecord == null) {
if (record.getFormatStyle() == ExtLogRecord.FormatStyle.PRINTF) {
// reformat it in a simple way, but only for legacy handler usage
oldRecord = new ExtLogRecord(record);
oldRecord.setMessage(record.getFormattedMessage());
} else {
oldRecord = record;
}
}
handler.publish(oldRecord);
}
} catch (VirtualMachineError e) {
throw e;
} catch (Throwable t) {
Expand Down

0 comments on commit d34ac96

Please sign in to comment.