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 e3131fa commit 64e381c
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.holidaycheck.soil
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 64e381c

Please sign in to comment.