-
-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minimum event level filter for logback
warning: this breaks current behavior, since default filter level is WARN, events with lower levels will not be recorded anymore. See logback/README to change filter level.
- Loading branch information
Showing
6 changed files
with
96 additions
and
2 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
77 changes: 77 additions & 0 deletions
77
...gback/src/test/java/net/kencochrane/raven/logback/SentryAppenderEventLevelFilterTest.java
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package net.kencochrane.raven.logback; | ||
|
||
import ch.qos.logback.classic.Level; | ||
import ch.qos.logback.core.Context; | ||
import mockit.Injectable; | ||
import mockit.Tested; | ||
import mockit.Verifications; | ||
import net.kencochrane.raven.Raven; | ||
import net.kencochrane.raven.event.Event; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author Felipe G Almeida | ||
*/ | ||
public class SentryAppenderEventLevelFilterTest { | ||
@Tested | ||
private SentryAppender sentryAppender = null; | ||
@Injectable | ||
private Raven mockRaven = null; | ||
@Injectable | ||
private Context mockContext = null; | ||
|
||
@BeforeMethod | ||
public void setUp() throws Exception { | ||
new MockUpStatusPrinter(); | ||
sentryAppender = new SentryAppender(mockRaven); | ||
sentryAppender.setContext(mockContext); | ||
} | ||
|
||
@DataProvider(name = "levels") | ||
private Object[][] levelConversions() { | ||
return new Object[][]{ | ||
{"ALL", 5}, | ||
{"TRACE", 5}, | ||
{"DEBUG", 4}, | ||
{"INFO", 3}, | ||
{"WARN", 2}, | ||
{"ERROR", 1}, | ||
{"error", 1}, | ||
{"xxx", 2}, | ||
{null, 2}}; | ||
} | ||
|
||
@Test(dataProvider = "levels") | ||
public void testLevelFilter(final String minLevel, final Integer expectedEvents) throws Exception { | ||
sentryAppender.setMinLevel(minLevel); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.TRACE, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.DEBUG, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.INFO, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.WARN, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.ERROR, null, null, null).getMockInstance()); | ||
|
||
new Verifications() {{ | ||
mockRaven.sendEvent((Event) any); | ||
minTimes = expectedEvents; | ||
maxTimes = expectedEvents; | ||
}}; | ||
} | ||
|
||
@Test | ||
public void testDefaultLevelFilter() throws Exception { | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.TRACE, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.DEBUG, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.INFO, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.WARN, null, null, null).getMockInstance()); | ||
sentryAppender.append(new MockUpLoggingEvent(null, null, Level.ERROR, null, null, null).getMockInstance()); | ||
|
||
new Verifications() {{ | ||
mockRaven.sendEvent((Event) any); | ||
minTimes = 2; | ||
maxTimes = 2; | ||
}}; | ||
} | ||
|
||
} |
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