Skip to content

Commit

Permalink
Merge pull request #450 from dmlloyd/legacy-handlers
Browse files Browse the repository at this point in the history
Cater to legacy sub-handlers
  • Loading branch information
jamezp authored Nov 29, 2023
2 parents d852546 + 1f7b169 commit 3c5b9ed
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/org/jboss/logmanager/ExtHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,29 @@ public void publish(final ExtLogRecord record) {
*
* @param record the log record to publish
*/
@SuppressWarnings("deprecation") // record.getFormattedMessage()
protected void publishToNestedHandlers(final ExtLogRecord record) {
if (record != null) {
LogRecord oldRecord = null;
for (Handler handler : getHandlers())
try {
if (handler != null) {
handler.publish(record);
if (handler instanceof ExtHandler || handler.getFormatter() instanceof ExtFormatter) {
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());
oldRecord.setParameters(null);
} else {
oldRecord = record;
}
}
handler.publish(oldRecord);
}
}
} catch (Exception e) {
reportError(handler, "Nested handler publication threw an exception", e, ErrorManager.WRITE_FAILURE);
Expand Down

0 comments on commit 3c5b9ed

Please sign in to comment.