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-177] Add a new DelayedHandler which will queue messages until… #164

Merged

Conversation

jamezp
Copy link
Member

@jamezp jamezp commented Jan 10, 2018

… at least one child handler is set.

https://issues.jboss.org/browse/LOGMGR-177

Simply adds a DelayedHandler which will queue messages until a child handler is added. Once added the queue is drained and any log messages published after activation will be directly published to child handlers.

private final Deque<ExtLogRecord> logRecords = new ArrayDeque<>();

private volatile boolean activated = false;
private volatile int callerCalculationState = -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could just be a volatile boolean forceCallerCalculation...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but then you wouldn't know if it was explicitly set to false. If explicitly set I want to avoid the super invocation.

* @param value {@code false} to explicitly disable the caller information otherwise {@code false} to always
* ensure the caller information is recorded
*/
public void setCallerCalculationRequired(final boolean value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forceCallerCalculation = value

}
// It's possible being a delayed handler that this could report a false negative. However since the this can
// manually be overridden it's best to assume we don't want the caller information.
return super.isCallerCalculationRequired();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this whole method to:
return forceCallerCalculation || super.isCallerCalculationRequired();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IOW we never want to force not calculating the caller, but we also don't want to calculate the caller unless we must.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay fair point. I guess that really does make more sense in a case where the formatter may really want the caller information, but the user made a mistake of setting it to false.

@jamezp jamezp force-pushed the LOGMGR-177-delayed-handler-delegate branch from db20976 to eebd7b8 Compare January 10, 2018 21:37
@jamezp jamezp force-pushed the LOGMGR-177-delayed-handler-delegate branch from eebd7b8 to 11e2ec1 Compare January 10, 2018 21:49
@jamezp jamezp merged commit cbf7f14 into jboss-logging:master Jan 10, 2018
@jamezp jamezp deleted the LOGMGR-177-delayed-handler-delegate branch January 10, 2018 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants