Skip to content

Commit

Permalink
Add class for additional custom attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental committed Jun 21, 2021
1 parent 2097e4d commit 393e920
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.github.ankurcha
name=gcloud-logging-slf4j-logback
version=1.1.11
version=1.2.0
17 changes: 17 additions & 0 deletions src/main/java/com/google/cloud/logging/CustomAttributes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.google.cloud.logging;

import java.util.Map;

public class CustomAttributes {

private final Map<String, Object> attributes;

public Map<String, Object> getAttributes() {
return attributes;
}

public CustomAttributes(Map<String, Object> attributes) {
this.attributes = attributes;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ protected Map toJsonMap(ILoggingEvent event) {
if (arg instanceof HttpRequestContext) {
reqCtx = (HttpRequestContext) arg;
}

if (arg instanceof CustomAttributes) {
Map<String, Object> attributes = ((CustomAttributes) arg).getAttributes();
if (attributes != null) {
builder.putAll(attributes);
}
}
}
}

Expand Down

0 comments on commit 393e920

Please sign in to comment.