Skip to content

Commit eccc7c7

Browse files
eric-martinDarin Howard
authored andcommitted
SF-6298: Config Override for Stackify Logger Internal Logging
1 parent c073669 commit eccc7c7

4 files changed

Lines changed: 39 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
target
55
coverage.ec
66
.idea
7-
*.iml
7+
*.iml
8+
/bin/

src/main/java/com/stackify/api/common/ApiConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public class ApiConfiguration {
6464
*/
6565
private final Boolean skipJson;
6666

67+
/**
68+
* Allow logging from com.stackify.*
69+
*/
70+
private final Boolean allowComDotStackify;
71+
6772
/**
6873
* @return the apiUrl
6974
*/

src/main/java/com/stackify/api/common/ApiConfigurations.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ public class ApiConfigurations {
4343
* @return ApiConfiguration
4444
*/
4545
public static ApiConfiguration fromPropertiesWithOverrides(final String apiUrl, final String apiKey, final String application, final String environment) {
46+
return fromPropertiesWithOverrides(apiUrl, apiKey, application, environment, null);
47+
}
48+
49+
/**
50+
* Explicitly configure the API
51+
* @param apiUrl API URL
52+
* @param apiKey API Key
53+
* @param application Configured application name
54+
* @param environment Configured environment name
55+
* @param allowComDotStackify Configured allow com.stackify.* logging
56+
* @return ApiConfiguration
57+
*/
58+
public static ApiConfiguration fromPropertiesWithOverrides(final String apiUrl, final String apiKey, final String application, final String environment, final String allowComDotStackify) {
4659
ApiConfiguration props = ApiConfigurations.fromProperties();
4760

4861
String mergedApiUrl = ((apiUrl != null) && (0 < apiUrl.length())) ? apiUrl : props.getApiUrl();
@@ -56,6 +69,7 @@ public static ApiConfiguration fromPropertiesWithOverrides(final String apiUrl,
5669
builder.application(mergedApplication);
5770
builder.environment(mergedEnvironment);
5871
builder.envDetail(EnvironmentDetails.getEnvironmentDetail(mergedApplication, mergedEnvironment));
72+
builder.allowComDotStackify(Boolean.valueOf(allowComDotStackify));
5973

6074
return builder.build();
6175
}

src/main/java/com/stackify/api/common/log/LogAppender.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public class LogAppender<T> implements Closeable {
6868

6969
private final boolean skipJson;
7070

71+
/**
72+
* Allow logging from com.stackify.*
73+
*/
74+
private boolean allowComDotStackify = false;
75+
7176
/**
7277
* Constructor
7378
* @param logger Logger project name
@@ -117,6 +122,12 @@ public void activate(final ApiConfiguration apiConfig) {
117122

118123
LogSender sender = new LogSender(apiConfig, objectMapper, this.masker, this.skipJson);
119124

125+
// set allowComDotStackify
126+
127+
if (Boolean.TRUE.equals(apiConfig.getAllowComDotStackify())) {
128+
this.allowComDotStackify = true;
129+
}
130+
120131
// build the background service to asynchronously post errors to Stackify
121132
// startup the background service
122133

@@ -152,11 +163,13 @@ public void append(final T event) {
152163

153164
// skip internal logging
154165

155-
String className = eventAdapter.getClassName(event);
156-
157-
if (className != null) {
158-
if (className.startsWith(COM_DOT_STACKIFY)) {
159-
return;
166+
if (!allowComDotStackify) {
167+
String className = eventAdapter.getClassName(event);
168+
169+
if (className != null) {
170+
if (className.startsWith(COM_DOT_STACKIFY)) {
171+
return;
172+
}
160173
}
161174
}
162175

0 commit comments

Comments
 (0)