Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOGMGR-239] Add level check to queue replay #233

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.jboss.logmanager.ExtHandler;
import org.jboss.logmanager.ExtLogRecord;
import org.jboss.logmanager.LogContext;
import org.jboss.logmanager.StandardOutputStreams;
import org.jboss.logmanager.formatters.PatternFormatter;

Expand All @@ -44,6 +45,24 @@ public class DelayedHandler extends ExtHandler {
private volatile boolean activated = false;
private volatile boolean callerCalculationRequired = false;

private final LogContext logContext;

/**
* Construct a new instance.
*/
public DelayedHandler() {
this(null);
}

/**
* Construct a new instance, with the given log context used to recheck log levels on replay.
*
* @param logContext the log context to use for level checks on replay, or {@code null} for none
*/
public DelayedHandler(LogContext logContext) {
this.logContext = logContext;
}

@Override
protected void doPublish(final ExtLogRecord record) {
// If activated just delegate
Expand Down Expand Up @@ -198,8 +217,9 @@ public final boolean isActivated() {
private synchronized void activate() {
// Always attempt to drain the queue
ExtLogRecord record;
final LogContext logContext = this.logContext;
while ((record = logRecords.pollFirst()) != null) {
if (isEnabled() && isLoggable(record)) {
if (isEnabled() && isLoggable(record) && (logContext == null || logContext.getLogger(record.getLoggerName()).isLoggable(record.getLevel()))) {
jamezp marked this conversation as resolved.
Show resolved Hide resolved
publishToChildren(record);
}
}
Expand Down