-
Notifications
You must be signed in to change notification settings - Fork 137
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
Context map feature #65
base: master
Are you sure you want to change the base?
Conversation
Interesting take on this one. Does it support multiple "structured arguments" too or only a single map? I don't understand how the formatting of the map for the message itself works – wouldn't that be |
Nevermind, I saw only now that |
@@ -23,6 +23,7 @@ | |||
private int maxQueueSize = 100 * 1024 * 1024; | |||
private Authentication authentication; | |||
private int maxMessageSize = -1; | |||
private boolean enableContextMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your indentation in this MR seems to be off (inconsistent use of tabs and spaces)
if (arguments == null || arguments.length == 0) return; | ||
Object lastElement = arguments[arguments.length - 1]; | ||
if (lastElement instanceof Map) { | ||
Map<String, Object> indexes = traverseObject(new HashMap<String, Object>(), "context", lastElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to call traverseMap
directly here. It took me a bit to figure out why traverseObject
is performing instanceof
checks again, when lastElement
is already guaranteed to be a map here.
Inspired by Context Map feature from logstash-logback-encoder for adding event-specific custom fields to message.
Example:
Log line:
log.info("Service started in {} seconds", duration/1000, Collections.singletonMap("duration", duration));
Result:
{
"@timestamp": "2014-06-04T15:26:14.464+02:00",
"message": "Service started in 12 seconds",
"duration": 12368,
}