{"id":18475504,"url":"https://github.com/i-al-istannen/logging-proxy","last_synced_at":"2025-05-13T15:15:56.316Z","repository":{"id":199052883,"uuid":"702051556","full_name":"I-Al-Istannen/logging-proxy","owner":"I-Al-Istannen","description":"An annotation processor that generates proxy classes which log method calls and then delegate to the original implementation","archived":false,"fork":false,"pushed_at":"2023-11-19T16:42:42.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-16T19:47:46.028Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/I-Al-Istannen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-08T11:01:00.000Z","updated_at":"2023-11-18T03:53:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"953ec26e-583f-4b68-b456-93c4b3d9bbf7","html_url":"https://github.com/I-Al-Istannen/logging-proxy","commit_stats":null,"previous_names":["i-al-istannen/logging-proxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/I-Al-Istannen%2Flogging-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/I-Al-Istannen%2Flogging-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/I-Al-Istannen%2Flogging-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/I-Al-Istannen%2Flogging-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/I-Al-Istannen","download_url":"https://codeload.github.com/I-Al-Istannen/logging-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969291,"owners_count":21992265,"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","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":[],"created_at":"2024-11-06T10:34:38.509Z","updated_at":"2025-05-13T15:15:51.263Z","avatar_url":"https://github.com/I-Al-Istannen.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eLogging Proxy\u003c/h1\u003e\n\u003c/div\u003e\n\n## What is this?\nA small annotation processor (and example usage) that generates proxy classes\nat compile-time using an annotation processor.\n\n## Why create this?\nThis is useful if you load the actual implementation from somewhere else (e.g.\na student submission), but want a simple interface to program tests against.\nIf you just use your own implementation, the students will only receive the\nassertion failures — but no history up to them.\nThis project automates generating a proxy at compile-time that traces all calls\nmade by the testing infrastructure and allows you to present the full call\nhistory to students in any way you like.\n\n## Use in your project\n1. Add the jitpack repository\n   ```xml\n   \u003crepositories\u003e\n     \u003crepository\u003e\n       \u003cid\u003ejitpack.io\u003c/id\u003e\n       \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n     \u003c/repository\u003e\n   \u003c/repositories\u003e\n   ```\n2. Add it as a depdendency\n   ```xml\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.github.I-Al-Istannen\u003c/groupId\u003e\n      \u003cartifactId\u003elogging-proxy\u003c/artifactId\u003e\n      \u003cversion\u003e6880313241395d6350518d0b2b15d5ee068b20e9\u003c/version\u003e\n    \u003c/dependency\u003e\n   ```\n3. Configure your maven compiler plugin to use the processor\n   ```xml\n   \u003cplugin\u003e\n     \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n     \u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n     \u003cconfiguration\u003e\n       \u003cannotationProcessorPaths\u003e\n         \u003cdependency\u003e\n           \u003cgroupId\u003ecom.github.I-Al-Istannen\u003c/groupId\u003e\n           \u003cartifactId\u003elogging-proxy\u003c/artifactId\u003e\n           \u003cversion\u003e6880313241395d6350518d0b2b15d5ee068b20e9\u003c/version\u003e\n         \u003c/dependency\u003e\n       \u003c/annotationProcessorPaths\u003e\n     \u003c/configuration\u003e\n   \u003c/plugin\u003e\n   ```\n\n## Example\nConsider the following simple shim (or real implementation) for a student task.\n```java\n@GenerateTestProxy\npublic class Calculator {\n  @ProxyMethod\n  public int add(int a, int b) {\n    return a + b;\n  }\n\n  public void notLogged() {} // Calls are not logged. Maybe useful for setup methods.\n\n  @ProxyMethod\n  public static int addTwo(int a, int b) {\n    return a + b;\n  }\n}\n```\n\n\u003cbr\u003e\nThese annotations are enough to trigger generation of the following proxy class.\n\n```java\npackage de.ialistannen.loggingproxy.example;\nimport de.ialistannen.loggingproxy.TestLogger;\nclass CalculatorProxy {\n    public int add(int a, int b) {\n        $testLogger$.onMethodCallStart(\"add\", a, b);\n        int result = $inner$.add(a, b);\n        $testLogger$.onMethodReturn(\"add\", result);\n        return result;\n    }\n\n    public int addStatic(int a, int b) {\n        $testLogger$.onMethodCallStart(\"addTwo\", a, b);\n        int result = Calculator.addTwo(a, b);\n        $testLogger$.onMethodReturn(\"addTwo\", result);\n        return result;\n    }\n\n    TestLogger $testLogger$;\n\n    public CalculatorProxy(TestLogger logger, Calculator inner) {\n        $testLogger$ = logger;\n        $inner$ = inner;\n    }\n\n    Calculator $inner$;\n}\n```\n\u003cbr\u003e\n\nThis can then easily be used to test the calculator and provide feedback, for\nexample using property based testing:\n```java\n  @Property(tries = 5)\n  void test(@ForAll int a, @ForAll int b) {\n    CalculatorProxy proxy = new CalculatorProxy(new MyTestLogger(), new Calculator());\n    assertThat(proxy.add(a, b)).isEqualTo(a + b);\n  }\n\n  @Property(tries = 5)\n  void testStatic(@ForAll int a, @ForAll int b) {\n    CalculatorProxy proxy = new CalculatorProxy(new MyTestLogger(), new Calculator());\n    assertThat(proxy.addStatic(a, b)).isEqualTo(a + b);\n  }\n\n  private static class MyTestLogger implements TestLogger {\n    @Override\n    public void onMethodCallStart(String method, Object... arguments) {\n      String args = Arrays.stream(arguments)\n        .map(Objects::toString)\n        .collect(Collectors.joining(\", \", \"(\", \")\"));\n      System.out.println(\"---\u003e \" + method + args);\n    }\n\n    @Override\n    public void onMethodReturn(String method, Object returnValue) {\n      System.out.println(\"\u003c--- \" + returnValue);\n    }\n  }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-al-istannen%2Flogging-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi-al-istannen%2Flogging-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-al-istannen%2Flogging-proxy/lists"}