diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..daa61fb2 --- /dev/null +++ b/.github/pull_request_template.md @@ -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 diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 00000000..0bde8aec --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -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 diff --git a/gradle.properties b/gradle.properties index cf692965..f42eccd6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/rollbar-log4j2/build.gradle b/rollbar-log4j2/build.gradle index a5b9ac23..96b89ead 100644 --- a/rollbar-log4j2/build.gradle +++ b/rollbar-log4j2/build.gradle @@ -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' } \ No newline at end of file diff --git a/rollbar-logback/src/main/java/com/rollbar/logback/RollbarAppender.java b/rollbar-logback/src/main/java/com/rollbar/logback/RollbarAppender.java index 5ce22a03..571bd335 100644 --- a/rollbar-logback/src/main/java/com/rollbar/logback/RollbarAppender.java +++ b/rollbar-logback/src/main/java/com/rollbar/logback/RollbarAppender.java @@ -35,6 +35,9 @@ public class RollbarAppender extends AppenderBase { private static final String CUSTOM_THREAD_NAME_KEY = "threadName"; + private static final String CUSTOM_ARGUMENT_ARRAY_KEY = "argumentArray"; + + private Rollbar rollbar; private String accessToken; @@ -215,6 +218,8 @@ private Map 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 rootCustom = new HashMap<>(); rootCustom.put(CUSTOM_NAMESPACE_KEY, custom); diff --git a/rollbar-logback/src/test/java/com/rollbar/logback/RollbarAppenderTest.java b/rollbar-logback/src/test/java/com/rollbar/logback/RollbarAppenderTest.java index 8f9171a3..5ef81380 100644 --- a/rollbar-logback/src/test/java/com/rollbar/logback/RollbarAppenderTest.java +++ b/rollbar-logback/src/test/java/com/rollbar/logback/RollbarAppenderTest.java @@ -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 = @@ -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(); @@ -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 expectedCustom = buildExpectedCustom(LOGGER_NAME, - new HashMap(MDC), MARKER_NAME, THREAD_NAME); + new HashMap(MDC), MARKER_NAME, THREAD_NAME, ARGUMENT_ARRAY); verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false); } @@ -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 expectedCustom = buildExpectedCustom(LOGGER_NAME, - new HashMap(MDC), null, THREAD_NAME); + new HashMap(MDC), null, THREAD_NAME, ARGUMENT_ARRAY); verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false); } @@ -138,17 +140,37 @@ 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 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 expectedCustom = buildExpectedCustom(LOGGER_NAME, - null, MARKER_NAME, THREAD_NAME); + new HashMap(MDC), MARKER_NAME, THREAD_NAME, null); verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false); } private static Map buildExpectedCustom(String loggerName, Map mdc, - String markerName, String threadName) { + String markerName, String threadName, Object[] argumentArray) { Map rootCustom = new HashMap<>(); Map custom = new HashMap<>(); @@ -156,6 +178,7 @@ private static Map buildExpectedCustom(String loggerName, Map