{"id":30930331,"url":"https://github.com/percona-lab/logv2analyzer","last_synced_at":"2025-09-10T10:45:28.121Z","repository":{"id":284141661,"uuid":"953947537","full_name":"Percona-Lab/logv2analyzer","owner":"Percona-Lab","description":"Analyzer for LOGV2 logging subsystem in MongoDB codebase","archived":false,"fork":false,"pushed_at":"2025-03-24T10:57:42.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T11:41:06.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/Percona-Lab.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":"2025-03-24T10:31:24.000Z","updated_at":"2025-03-24T10:58:45.000Z","dependencies_parsed_at":"2025-03-24T11:41:10.431Z","dependency_job_id":"722c93c2-0722-4e00-9fde-d8035fc33db5","html_url":"https://github.com/Percona-Lab/logv2analyzer","commit_stats":null,"previous_names":["percona-lab/logv2analyzer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Percona-Lab/logv2analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percona-Lab%2Flogv2analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percona-Lab%2Flogv2analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percona-Lab%2Flogv2analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percona-Lab%2Flogv2analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Percona-Lab","download_url":"https://codeload.github.com/Percona-Lab/logv2analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percona-Lab%2Flogv2analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274448220,"owners_count":25287121,"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-09-10T02:00:12.551Z","response_time":83,"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":"2025-09-10T10:45:27.070Z","updated_at":"2025-09-10T10:45:28.101Z","avatar_url":"https://github.com/Percona-Lab.png","language":"Python","readme":"# logv2analyzer\n\nThe `logv2analyzer.py` is a utility for analyzing log IDs in a MongoDB codebase. It specifically scans for `LOGV2` family macros to identify their usage and checks for duplicates. The tool supports filtering by log ID ranges, ignoring specific files or directories and output results in both human-readable and JSON formats.\n\n## Usage\n\nBasic usage:\n\n```bash\npython logv2analyzer.py [options] [paths...]\n```\n\nPrint help for more options:\n\n```bash\npython logv2analyzer.py --help\n```\n\n### Examples\n\n1. Scan the current directory for log ID usages, use `logv2analyzer.yaml` configuration file if exists:\n\n   ```bash\n   python logv2analyzer.py\n   ```\n\n2. Scan specific directories/files with verbose output:\n\n   ```bash\n   python logv2analyzer.py -v src/module1 src/module2/file.cpp\n   ```\n\n3. Analyze log IDs only in a specific range:\n\n   ```bash\n   python logv2analyzer.py --range 29000 30000\n   ```\n\n4. Use `.gitignore` file if exists to ignore specified files, ignore files with additional patterns and output results to a file in JSON format.\n\n   ```bash\n   python logv2analyzer.py --use-gitignore --ignore 'src/third_party' 'src/**/*.h' --output results.json\n   ```\n\n5. Use a custom configuration file:\n\n   ```bash\n   python logv2analyzer.py -c custom_config.yaml\n   ```\n\n## Configuration\n\nThe script supports a YAML configuration file to specify default options. Example:\n\n```yaml\nuse_gitignore: true\nignore:\n  - src/module/**/*.h\n  - src/third_party\nrange:\n  - 29000\n  - 30000\nduplicates: true\nignore_duplicates:\n  - \"1234:src/module1/file.cpp\"\n  - \"5678:src/module2/*.cpp\"\n```\n\n## Output\n\nIf no `--output` option is provided the script outputs the results in a human readable format, with short summary.\n\nIf `--output \u003cpath\u003e` option is provided the script outputs the results in JSON format, including:\n\n- Configuration used for the scan.\n- Log ID usages with file paths and line numbers.\n- Duplicate log IDs (if enabled).\n\nExample output:\n\n```json\n{\n  \"config\": {\n    \"ignore\": [\n      \"src/module/**/*.h\",\n      \"src/third_party\"\n    ],\n    \"range\": [29000, 30000],\n    \"duplicates\": true,\n    \"ignore_duplicates\": [\n      \"1234:src/module1/file.cpp\"\n      \"5678:src/module2/*.cpp\"\n    ]\n  },\n  \"usages\": [\n    {\n      \"id\": 1234,\n      \"path\": \"src/file.cpp\",\n      \"line_number\": 42,\n      \"col_begin\": 20,\n      \"col_end\": 24\n    },\n    {\n      \"id\": 1234,\n      \"path\": \"src/other_file.cpp\",\n      \"line_number\": 10,\n      \"col_begin\": 22,\n      \"col_end\": 26\n    }\n  ],\n  \"duplicates\": {\n    \"1234\": [\n      {\n        \"path\": \"src/file.cpp\",\n        \"line_number\": 42,\n        \"col_begin\": 20,\n        \"col_end\": 24\n      },\n      {\n        \"path\": \"src/other_file.cpp\",\n        \"line_number\": 10,\n        \"col_begin\": 22,\n        \"col_end\": 26\n      }\n    ]\n  }\n}\n```\n\n## TODO\n\n- Scan for config file if not running from project's root dir\n- Scan for `.gitignore` file if not running from project's root dir\n- Add some additional filters for duplicates e.g. ignore if duplicates are in the same function\n- Improve logging duplicates with respect to the changed files for github annotations\n- Add option to just print usages\n- Add option to provide a hint for a new log id\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercona-lab%2Flogv2analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpercona-lab%2Flogv2analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercona-lab%2Flogv2analyzer/lists"}