Skip to content

Commit

Permalink
feat: allow flush level OFF (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Feb 1, 2021
1 parent c0e02ba commit b7898d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -211,7 +211,10 @@ public synchronized void start() {
MonitoredResource resource = getMonitoredResource(getProjectId());
defaultWriteOptions =
new WriteOption[] {WriteOption.logName(getLogName()), WriteOption.resource(resource)};
getLogging().setFlushSeverity(severityFor(getFlushLevel()));
Level flushLevel = getFlushLevel();
if (flushLevel != Level.OFF) {
getLogging().setFlushSeverity(severityFor(flushLevel));
}
loggingEnhancers = new ArrayList<>();
List<LoggingEnhancer> resourceEnhancers = MonitoredResourceUtil.getResourceEnhancers();
loggingEnhancers.addAll(resourceEnhancers);
Expand Down
Expand Up @@ -112,6 +112,14 @@ public void testFlushLevelConfigUpdatesLoggingFlushSeverity() {
assertThat(capturedArgument.getValue().iterator().next()).isEqualTo(logEntry);
}

@Test
public void testFlushLevelConfigSupportsFlushLevelOff() {
loggingAppender.setFlushLevel(Level.OFF);
loggingAppender.start();
Severity foundSeverity = logging.getFlushSeverity();
assertThat(foundSeverity).isEqualTo(null);
}

@Test
public void testFilterLogsOnlyLogsAtOrAboveLogLevel() {
Map<String, Object> jsonContent = new HashMap<>();
Expand Down

0 comments on commit b7898d2

Please sign in to comment.