Skip to content

Commit

Permalink
Merge branch 'master' into dependabot-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis authored Nov 29, 2020
2 parents 8b75e23 + 8c8f190 commit b10e72b
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Description of the change

> Description here
## Type of change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Related issues

> Fix [#1]()
## Checklists

### Development

- [ ] Lint rules pass locally
- [ ] The code changed/added as part of this pull request has been covered with tests
- [ ] All tests related to the changed code pass in development

### Code review

- [ ] This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
- [ ] "Ready for review" label attached to the PR and reviewers mentioned in a comment
- [ ] Changes have been reviewed by at least one other engineer
- [ ] Issue from task tracker has a link to this pull request
10 changes: 10 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Validate Gradle Wrapper"
on: [push, pull_request]

jobs:
validation:
name: "Gradle wrapper validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.7.4-SNAPSHOT
VERSION_NAME=1.7.6-SNAPSHOT
GROUP=com.rollbar

POM_DESCRIPTION=For connecting your applications built on the JVM to Rollbar for Error Reporting
Expand Down
1 change: 1 addition & 0 deletions rollbar-log4j2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ dependencies {
api project(':rollbar-java')

api group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
annotationProcessor 'org.apache.logging.log4j:log4j-core:2.11.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class RollbarAppender extends AppenderBase<ILoggingEvent> {

private static final String CUSTOM_THREAD_NAME_KEY = "threadName";

private static final String CUSTOM_ARGUMENT_ARRAY_KEY = "argumentArray";


private Rollbar rollbar;

private String accessToken;
Expand Down Expand Up @@ -215,6 +218,8 @@ private Map<String, Object> buildCustom(ILoggingEvent event) {
custom.put(CUSTOM_MDC_NAME_KEY, this.buildMdc(event));
custom.put(CUSTOM_MAKER_NAME_KEY, this.getMarker(event));

custom.put(CUSTOM_ARGUMENT_ARRAY_KEY, event.getArgumentArray());

Map<String, Object> rootCustom = new HashMap<>();
rootCustom.put(CUSTOM_NAMESPACE_KEY, custom);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class RollbarAppenderTest {
static {
MDC.put("mdc_key_1", "mdc_value_1");
}

private static String NESTED_EXCEPTION_MESSAGE = "This is the nested exception message";

private static final Exception NESTED_EXCEPTION =
Expand All @@ -53,6 +52,7 @@ public class RollbarAppenderTest {
private static final Exception EXCEPTION =
new IllegalArgumentException(EXCEPTION_MESSAGE, NESTED_EXCEPTION);

private static final Object[] ARGUMENT_ARRAY = {"arg_1", 17};
@Rule
public MockitoRule rule = MockitoJUnit.rule();

Expand Down Expand Up @@ -104,11 +104,12 @@ public void shouldLogEventWithAllInformationFromThrowableProxyWithThrowable() {
when(event.getThrowableProxy()).thenReturn(rootThrowableProxy);
when(event.getMDCPropertyMap()).thenReturn(MDC);
when(event.getFormattedMessage()).thenReturn(FORMATTED_MESSAGE);
when(event.getArgumentArray()).thenReturn(ARGUMENT_ARRAY);

sut.append(event);

Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
new HashMap<String, Object>(MDC), MARKER_NAME, THREAD_NAME);
new HashMap<String, Object>(MDC), MARKER_NAME, THREAD_NAME, ARGUMENT_ARRAY);

verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}
Expand All @@ -121,11 +122,12 @@ public void shouldLogEventWhenNoMarker() {
when(event.getThrowableProxy()).thenReturn(rootThrowableProxy);
when(event.getMDCPropertyMap()).thenReturn(MDC);
when(event.getFormattedMessage()).thenReturn(FORMATTED_MESSAGE);
when(event.getArgumentArray()).thenReturn(ARGUMENT_ARRAY);

sut.append(event);

Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
new HashMap<String, Object>(MDC), null, THREAD_NAME);
new HashMap<String, Object>(MDC), null, THREAD_NAME, ARGUMENT_ARRAY);

verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}
Expand All @@ -138,24 +140,45 @@ public void shouldLogEventWhenNoMDC() {
when(event.getLevel()).thenReturn(ch.qos.logback.classic.Level.ERROR);
when(event.getThrowableProxy()).thenReturn(rootThrowableProxy);
when(event.getFormattedMessage()).thenReturn(FORMATTED_MESSAGE);
when(event.getArgumentArray()).thenReturn(ARGUMENT_ARRAY);

sut.append(event);

Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
null, MARKER_NAME, THREAD_NAME, ARGUMENT_ARRAY);

verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}

@Test
public void shouldLogEventWhenNoArgumentArray() {
when(event.getLoggerName()).thenReturn(LOGGER_NAME);
when(event.getMarker()).thenReturn(marker);
when(event.getThreadName()).thenReturn(THREAD_NAME);
when(event.getLevel()).thenReturn(ch.qos.logback.classic.Level.ERROR);
when(event.getThrowableProxy()).thenReturn(rootThrowableProxy);
when(event.getMDCPropertyMap()).thenReturn(MDC);
when(event.getFormattedMessage()).thenReturn(FORMATTED_MESSAGE);
when(event.getArgumentArray()).thenReturn(null);

sut.append(event);

Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
null, MARKER_NAME, THREAD_NAME);
new HashMap<String, Object>(MDC), MARKER_NAME, THREAD_NAME, null);

verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}

private static Map<String, Object> buildExpectedCustom(String loggerName, Map<String, Object> mdc,
String markerName, String threadName) {
String markerName, String threadName, Object[] argumentArray) {
Map<String, Object> rootCustom = new HashMap<>();
Map<String, Object> custom = new HashMap<>();

custom.put("loggerName", loggerName);
custom.put("threadName", threadName);
custom.put("marker", markerName);
custom.put("mdc", mdc);
custom.put("argumentArray", argumentArray);

rootCustom.put("rollbar-logback", custom);

Expand Down

0 comments on commit b10e72b

Please sign in to comment.