-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from toweroy/update-sentry-dep
Update SentryAppender to use sentry-logback dependency
- Loading branch information
Showing
3 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
|
||
package com.spotify.logging; | ||
|
||
import static com.spotify.logging.LoggingConfigurator.addSentryAppender; | ||
import static com.spotify.logging.LoggingConfigurator.getSyslogAppender; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
@@ -47,8 +48,10 @@ | |
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; | ||
import ch.qos.logback.classic.net.SyslogAppender; | ||
import ch.qos.logback.core.ConsoleAppender; | ||
import ch.qos.logback.core.status.Status; | ||
import com.google.common.collect.FluentIterable; | ||
import com.spotify.logging.logback.CustomLogstashEncoder; | ||
import io.sentry.logback.SentryAppender; | ||
import net.logstash.logback.composite.loggingevent.ArgumentsJsonProvider; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
@@ -107,6 +110,31 @@ public void testGetSyslogAppenderRespectsNewLineReplacement() { | |
appender.getSuffixPattern()); | ||
} | ||
|
||
@Test | ||
public void testGetSentryAppenderNoErrorsWithDsnOption() { | ||
SentryAppender sentryAppender = | ||
addSentryAppender( | ||
"https://[email protected]/0", LoggingConfigurator.Level.ERROR); | ||
|
||
assertEquals( | ||
0, | ||
sentryAppender.getContext().getStatusManager().getCopyOfStatusList().stream() | ||
.filter( | ||
status -> { | ||
if (status.getLevel() == Status.WARN | ||
&& status | ||
.getMessage() | ||
.contains( | ||
"Failed to init Sentry during appender initialization: DSN is " | ||
+ "required. Use empty string to disable SDK.")) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}) | ||
.count()); | ||
} | ||
|
||
private String getLoggingContextHostnameProperty() { | ||
final Logger accessPointLogger = (Logger) LoggerFactory.getLogger("logger"); | ||
final LoggerContext loggerContext = accessPointLogger.getLoggerContext(); | ||
|