{"id":18791014,"url":"https://github.com/hansbug/debug_logger","last_synced_at":"2025-10-11T02:11:18.205Z","repository":{"id":103902234,"uuid":"128177502","full_name":"HansBug/debug_logger","owner":"HansBug","description":"debug_logger for java projects","archived":false,"fork":false,"pushed_at":"2018-05-07T06:05:30.000Z","size":250,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T14:41:43.381Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HansBug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2018-04-05T08:15:46.000Z","updated_at":"2023-05-12T15:41:23.000Z","dependencies_parsed_at":"2023-07-26T03:45:51.978Z","dependency_job_id":null,"html_url":"https://github.com/HansBug/debug_logger","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/HansBug/debug_logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HansBug%2Fdebug_logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HansBug%2Fdebug_logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HansBug%2Fdebug_logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HansBug%2Fdebug_logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HansBug","download_url":"https://codeload.github.com/HansBug/debug_logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HansBug%2Fdebug_logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005916,"owners_count":26083995,"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-11T02:00:06.511Z","response_time":55,"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":[],"created_at":"2024-11-07T21:14:25.231Z","updated_at":"2025-10-11T02:11:18.201Z","avatar_url":"https://github.com/HansBug.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# debug_logger\n\n`debug_logger` is a powerful debug helper based on the debug informations in the standard output. It can easily manage the output of the debug information, which will help us a lot when debugging.[CHINESE DOCUMENTATION HERE](https://github.com/HansBug/debug_logger/blob/master/debug_logger%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3.md)\n\n## How to start\n\n### Initialize\nFirstly, we should initialize the config of the `DebugHelper` at the beginning of the entry point, like this:\n```java\nimport com.hansbug.debug.DebugHelper;\n\npublic abstract class Main {\n    public static void main(String[] args) {\n        DebugHelper.setSettingsFromArguments(args);\n    }\n}\n```\nAfter this, we can use the `DebugHelper`.\n\n### Let's debug\nThe usage of `DebugHelper` in the program is very easy. You can add this into your program anywhere you like to output the debug information.\n```java\nDebugHelper.debugPrintln(2, \"My debug information\");\n```\nWhen you use the `--debug 2`(or more than 2) in the command line, this will create a line of output(**in the standard output**).\n```\n[DEBUG-2][xxxx.java:233 TestClass.testMethod] My debug information\n```\n`xxxx.java:233 TestClass.testMethod` represents the position where you put the `debugPrintln`, in this case it means _the 233rd line_ of the `xxxx.java`, in the method `testMethod` of the class `TestClass`.\n\nWhen you use the `--debug 1`, there will be nothing output because we the **debug level** of this piece of debug information is `2`, while what we need is only `1`.\n \n### Command line configuration\n\n* **-D \\\u003clevel\\\u003e, --debug \\\u003clevel\\\u003e** define the debug level. The maximum of the debug level is `5` and the minimum is `1`.\n* **--debug_package_name \\\u003cpackage_name\\\u003e** define the limit of the package name(full name, just like `com.hansbug.debug`)\n* **--debug_file_name \\\u003cfile_name\\\u003e** define the limit of the file name(short file name, just like `Main.java`, `DebugHelper.java`)\n* **--debug_class_name \\\u003cclass_name\\\u003e** define the limit of the class name(short class name, **including inner classes**, like `TestClassA`, `TestInnerClassA`(instead of `TestClassA.TestInnerClassA`))\n* **--debug_method_name \\\u003cmethod_name\\\u003e** define the limit of the method name(just like `toString`, `\u003cinit\u003e`(constructor method))\n* **--debug_include_children** define whether record the log in subroutines that called by the method in the limit above.\n* **--debug_show_thread** define whether show the name of threads which execute the `debugPrintln`.\n\n#### ATTENTION\n\n* If `--debug`(or `-D`) not detected, debug mode is DISABLED and file logger will not be processed.\n* If debug level is invalid, there will be exception thrown out.\n* **All the limit above is regular-expression-supported!**\n* **Remember to initialize the configurations at the beginning!!!**\n\n#### Example  \nYou can try to run the `Main.main` in the `test` directory to see and try the example.\n\nThe command line arguments should be added before running the demo.\n\nIn the `Main.main` in the `test` directory, when we run it without any arguments, its output should like this:\n```\nx: 1, y: -1\nx: 3, y: 6\n[thread_2] 0\n[thread_1] 0\n[thread_2] 1\n[thread_1] 1\n[thread_2] 2\n[thread_1] 2\n[thread_2] 3\n[thread_2] 4\n[thread_1] 3\n[thread_1] 4\n[thread_1] 5\n[thread_1] 6\n[thread_1] 7\n[thread_1] 8\n```\n\nif the arguments `--debug 1` is added, its standard output will be:\n```\n[DEBUG-1][Main.java:62 Main.testDebugHelper] ksdhjf\nx: 1, y: -1\nx: 3, y: 6\n[DEBUG-1][TestThread.java:18 TestThread.run] [Thread - \"thread_1\"] start\n[DEBUG-1][TestThread.java:18 TestThread.run] [Thread - \"thread_2\"] start\n[thread_2] 0\n[thread_1] 0\n[thread_2] 1\n[thread_1] 1\n[thread_2] 2\n[thread_1] 2\n[thread_2] 3\n[thread_2] 4\n[thread_1] 3\n[DEBUG-1][TestThread.java:31 TestThread.run] [Thread - \"thread_2\"] end\n[thread_1] 4\n[thread_1] 5\n[thread_1] 6\n[thread_1] 7\n[thread_1] 8\n[DEBUG-1][TestThread.java:31 TestThread.run] [Thread - \"thread_1\"] end\n```\n\n\nif the arguments `--debug 5` is added, its standard output will be:\n```\n[DEBUG-1][Main.java:62 Main.testDebugHelper] ksdhjf\n[DEBUG-2][TestClassA.java:12 TestInnerClassA.\u003cinit\u003e] TestInnerClassA initialize, x: 0, y: 0\n[DEBUG-2][TestClassA.java:20 TestClassA.\u003cinit\u003e] TestClassA initialize, x: 0, y: 0\n[DEBUG-2][TestClassA.java:31 TestClassA.toString] TestClassA getString, x: 1, y: -1\nx: 1, y: -1\n[DEBUG-2][TestClassA.java:12 TestInnerClassA.\u003cinit\u003e] TestInnerClassA initialize, x: 2, y: 7\n[DEBUG-2][TestClassA.java:20 TestClassA.\u003cinit\u003e] TestClassA initialize, x: 2, y: 7\n[DEBUG-2][TestClassA.java:31 TestClassA.toString] TestClassA getString, x: 3, y: 6\nx: 3, y: 6\n[DEBUG-1][TestThread.java:18 TestThread.run] [Thread - \"thread_1\"] start\n[DEBUG-1][TestThread.java:18 TestThread.run] [Thread - \"thread_2\"] start\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 0 and wait for 503 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 0 and wait for 367 ms\n[thread_2] 0\n[thread_1] 0\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 367 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 1 and wait for 367 ms\n[thread_2] 1\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 1 and wait for 503 ms\n[thread_1] 1\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 368 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 2 and wait for 367 ms\n[thread_2] 2\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 2 and wait for 503 ms\n[thread_1] 2\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 368 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 3 and wait for 367 ms\n[thread_2] 3\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 368 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 4 and wait for 367 ms\n[thread_2] 4\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 3 and wait for 503 ms\n[thread_1] 3\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 368 ms\n[DEBUG-1][TestThread.java:31 TestThread.run] [Thread - \"thread_2\"] end\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 4 and wait for 503 ms\n[thread_1] 4\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 5 and wait for 503 ms\n[thread_1] 5\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 6 and wait for 503 ms\n[thread_1] 6\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 7 and wait for 503 ms\n[thread_1] 7\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 8 and wait for 503 ms\n[thread_1] 8\n[DEBUG-3][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-1][TestThread.java:31 TestThread.run] [Thread - \"thread_1\"] end\n```\n\nif the arguments `--debug 5 --debug_package_name \"test_package_A\"` is added, it will be:\n```\n[DEBUG-2][TestClassA.java:12 TestInnerClassA.\u003cinit\u003e] TestInnerClassA initialize, x: 0, y: 0\n[DEBUG-2][TestClassA.java:20 TestClassA.\u003cinit\u003e] TestClassA initialize, x: 0, y: 0\n[DEBUG-2][TestClassA.java:31 TestClassA.toString] TestClassA getString, x: 1, y: -1\nx: 1, y: -1\n[DEBUG-2][TestClassA.java:12 TestInnerClassA.\u003cinit\u003e] TestInnerClassA initialize, x: 2, y: 7\n[DEBUG-2][TestClassA.java:20 TestClassA.\u003cinit\u003e] TestClassA initialize, x: 2, y: 7\n[DEBUG-2][TestClassA.java:31 TestClassA.toString] TestClassA getString, x: 3, y: 6\nx: 3, y: 6\n[thread_2] 0\n[thread_1] 0\n[thread_2] 1\n[thread_1] 1\n[thread_2] 2\n[thread_1] 2\n[thread_2] 3\n[thread_2] 4\n[thread_1] 3\n[thread_1] 4\n[thread_1] 5\n[thread_1] 6\n[thread_1] 7\n[thread_1] 8\n```\n\nif the arguments `--debug 5 --debug_package_name \"test_package_B\" --debug_show_thread` is added, it will be:\n```\nx: 1, y: -1\nx: 3, y: 6\n[DEBUG-1][Thread-1][TestThread.java:18 TestThread.run] [Thread - \"thread_2\"] start\n[DEBUG-1][Thread-0][TestThread.java:18 TestThread.run] [Thread - \"thread_1\"] start\n[DEBUG-2][Thread-1][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 0 and wait for 367 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 0 and wait for 503 ms\n[thread_2] 0\n[thread_1] 0\n[DEBUG-3][Thread-1][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 368 ms\n[DEBUG-2][Thread-1][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 1 and wait for 367 ms\n[thread_2] 1\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 1 and wait for 503 ms\n[thread_1] 1\n[DEBUG-3][Thread-1][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 368 ms\n[DEBUG-2][Thread-1][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 2 and wait for 367 ms\n[thread_2] 2\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 2 and wait for 503 ms\n[thread_1] 2\n[DEBUG-3][Thread-1][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 367 ms\n[DEBUG-2][Thread-1][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 3 and wait for 367 ms\n[thread_2] 3\n[DEBUG-3][Thread-1][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 367 ms\n[DEBUG-2][Thread-1][TestThread.java:21 TestThread.run] [Thread - \"thread_2\"] execute - 4 and wait for 367 ms\n[thread_2] 4\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 3 and wait for 503 ms\n[thread_1] 3\n[DEBUG-3][Thread-1][TestThread.java:26 TestThread.run] [Thread - \"thread_2\"] came back after 368 ms\n[DEBUG-1][Thread-1][TestThread.java:31 TestThread.run] [Thread - \"thread_2\"] end\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 4 and wait for 503 ms\n[thread_1] 4\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 5 and wait for 503 ms\n[thread_1] 5\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 504 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 6 and wait for 503 ms\n[thread_1] 6\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 7 and wait for 503 ms\n[thread_1] 7\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 503 ms\n[DEBUG-2][Thread-0][TestThread.java:21 TestThread.run] [Thread - \"thread_1\"] execute - 8 and wait for 503 ms\n[thread_1] 8\n[DEBUG-3][Thread-0][TestThread.java:26 TestThread.run] [Thread - \"thread_1\"] came back after 505 ms\n[DEBUG-1][Thread-0][TestThread.java:31 TestThread.run] [Thread - \"thread_1\"] end\n```\n\n## Javadoc \n(not yet created :-( )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansbug%2Fdebug_logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansbug%2Fdebug_logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansbug%2Fdebug_logger/lists"}