{"id":28441639,"url":"https://github.com/marceloleite2604/spy-root-logger","last_synced_at":"2025-10-03T23:06:59.605Z","repository":{"id":65507611,"uuid":"585258924","full_name":"MarceloLeite2604/spy-root-logger","owner":"MarceloLeite2604","description":"A JUnit5 extension to assist monitoring Logback log events","archived":false,"fork":false,"pushed_at":"2023-01-05T20:18:08.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-07T15:41:16.407Z","etag":null,"topics":["junit5","junit5-extension","logback","logback-appender"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarceloLeite2604.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-04T18:06:42.000Z","updated_at":"2023-01-05T14:26:00.000Z","dependencies_parsed_at":"2023-02-04T14:33:08.111Z","dependency_job_id":null,"html_url":"https://github.com/MarceloLeite2604/spy-root-logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MarceloLeite2604/spy-root-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloLeite2604%2Fspy-root-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloLeite2604%2Fspy-root-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloLeite2604%2Fspy-root-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloLeite2604%2Fspy-root-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarceloLeite2604","download_url":"https://codeload.github.com/MarceloLeite2604/spy-root-logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloLeite2604%2Fspy-root-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278239978,"owners_count":25954098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["junit5","junit5-extension","logback","logback-appender"],"created_at":"2025-06-06T05:06:22.834Z","updated_at":"2025-10-03T23:06:59.599Z","avatar_url":"https://github.com/MarceloLeite2604.png","language":"Java","funding_links":["https://www.paypal.com/donate/?hosted_button_id=C6LPXWCHGRUVQ"],"categories":[],"sub_categories":[],"readme":"# Spy Root Logger\n\nA JUnit5 extension to assist monitoring Logback log events and elaborate tests\nto confirm that events were logged.\n\n## Examples\n\n```java\n  import com.figtreelake.spyrootlogger.SpyRootLogger;\n  import com.figtreelake.spyrootlogger.SpyRootLoggerExtension;\n  import com.figtreelake.spyrootlogger.SpyRootLoggerInject;\n  import org.junit.jupiter.api.BeforeEach;\n  import org.junit.jupiter.api.extension.ExtendWith;\n      \n  import java.util.regex.Pattern;\n         \n  @ExtendWith(SpyRootLoggerExtension.class)\n  class FooTest {\n         \n    private Foo foo;\n         \n    @SpyRootLoggerInject\n    private SpyRootLogger spyRootLogger;\n         \n    @BeforeEach\n    void setUp() {\n      foo = new Foo();\n    }\n         \n    @Test\n    void shouldLogExceptionWhenHandlingRuntimeException() {\n      final var exception = new RuntimeException(\"Dummy exception\");\n   \n      final var responseEntity = foo.handleException(exception);\n         \n      /* Spy Root Logger can be used to check if there is a log event with \n      a specific exception attached. */\n      assertThat(spyRootLogger.findEventsByThrowableAttached(exception))\n          .isNotEmpty();\n    }\n         \n    @Test\n    void shouldLogErrorEventWhenHandlingIllegalStateException() {\n      final var mockedIllegalStateException = mock(IllegalStateException.class);\n   \n      final var responseEntity = foo.handleException(mockedIllegalStateException);\n   \n      /* Spy Root Logger can be used to check how many events of such level were \n      logged */\n      assertThat(spyRootLogger.countErrorEvents()).isPositive();\n    }\n         \n    @Test\n    void shouldLogMessageInformingMessageNotReadableWhenHandlingHttpMessageNotReadableException() {\n      final var mockedHttpMessageNotReadableException = mock(HttpMessageNotReadableException.class);\n         \n      final var messagePattern = Pattern.compile(\"^Failed to read HTTP message\");\n         \n      final var responseEntity = foo.handleException(mockedHttpMessageNotReadableException);\n         \n      /* Spy Root Logger can be used to find log events by regular expressions \n      on its message */\n      assertThat(spyRootLogger.findEventsByMessagePattern(messagePattern))\n        .isNotEmpty();\n    }\n  }\n```\n\n**Note:** Functional examples can be found on [Spy Root Logger Example repository][spy-root-logger-example-repository].\n\n## Usage\n\n1. Be sure to implement your tests using [JUnit5][junit5] framework.\n\n2. Add Spy Root Logger on your project.\n\n   1. For Maven projects add the following on your `pom.xml` file\n      under `\u003cdependencies\u003e` tag.\n      ```xml\n      \u003cdependency\u003e\n        \u003cgroupId\u003ecom.figtreelake\u003c/groupId\u003e\n        \u003cartifactId\u003espy-root-logger\u003c/artifactId\u003e\n        \u003cversion\u003e1.0\u003c/version\u003e\n      \u003c/dependency\u003e\n      ```\n      \n   2. For Gradle projects add the following on your `build.gradle` file\n      under `dependencies` declaration.\n      ```groovy\n      implementation 'com.figtreelake:spy-root-logger:1.0'\n      ```\n      \n   3. You can check the latest version available\n      on [Maven Central repository][maven-central-repository].\n\n3. Annotate your test class with [`@ExtendWith`][extend-with] informing [`SpyRootLoggerExtension`][spy-root-logger-extension]\n   class as value.\n\n4. Add a [`SpyRootLogger`][spy-root-logger] field and annotate it with [`@SpyRootLoggerInject`][spy-root-logger-inject].\n\n   ```java\n      import com.figtreelake.spyrootlogger.SpyRootLogger;\n      import com.figtreelake.spyrootlogger.SpyRootLoggerExtension;\n      import com.figtreelake.spyrootlogger.SpyRootLoggerInject;\n      import org.junit.jupiter.api.extension.ExtendWith;\n   \n      @ExtendWith(SpyRootLoggerExtension.class)\n      class FooTest {\n   \n        @SpyRootLoggerInject\n        private SpyRootLogger spyRootLogger;\n   \n        /* Test declarations... */\n      }\n   ``` \n\n## Contributions\n\nTry out the library. If you like the outcome, give a star for its repository, share or talk about it with your IT friends and colleagues. This is a work I have been doing in my spare time and I really would like to see that people appreciate the time I have invested on it.\n\nIf you liked the project and *really* want to demonstrate your appreciation, you can send me a \"thank you\" coffee. 🙂\n\n[![Yellow PayPal Donation button with \"donate\" text written on it](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)][paypal-donation]\n\n[extend-with]: https://junit.org/junit5/docs/current/user-guide/#extensions-registration-declarative\n[junit5]: https://junit.org/junit5/\n[maven-central-repository]: https://mvnrepository.com/repos/central\n[paypal-donation]: https://www.paypal.com/donate/?hosted_button_id=C6LPXWCHGRUVQ\n[spy-root-logger]: ./src/main/java/com/figtreelake/spyrootlogger/SpyRootLogger.java\n[spy-root-logger-example-repository]: https://github.com/MarceloLeite2604/spy-root-logger-example\n[spy-root-logger-extension]: ./src/main/java/com/figtreelake/spyrootlogger/SpyRootLoggerExtension.java\n[spy-root-logger-inject]: ./src/main/java/com/figtreelake/spyrootlogger/SpyRootLoggerInject.java\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarceloleite2604%2Fspy-root-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarceloleite2604%2Fspy-root-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarceloleite2604%2Fspy-root-logger/lists"}