{"id":23094851,"url":"https://github.com/htfy96/logalign","last_synced_at":"2026-03-06T20:03:52.010Z","repository":{"id":268299295,"uuid":"903878568","full_name":"htfy96/logalign","owner":"htfy96","description":"Command-line tool to annotate log lines with links to their definitons and argument expression.","archived":false,"fork":false,"pushed_at":"2024-12-20T03:25:32.000Z","size":10874,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T19:25:46.881Z","etag":null,"topics":["command-line","golang","golang-application","log","tree-sitter"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htfy96.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":"2024-12-15T19:36:31.000Z","updated_at":"2025-01-14T18:05:00.000Z","dependencies_parsed_at":"2024-12-15T22:20:53.877Z","dependency_job_id":"35cf7191-bfd4-4a1d-b104-983c00860070","html_url":"https://github.com/htfy96/logalign","commit_stats":null,"previous_names":["htfy96/logalign"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/htfy96/logalign","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Flogalign","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Flogalign/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Flogalign/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Flogalign/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htfy96","download_url":"https://codeload.github.com/htfy96/logalign/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Flogalign/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30195571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["command-line","golang","golang-application","log","tree-sitter"],"created_at":"2024-12-16T22:18:22.506Z","updated_at":"2026-03-06T20:03:51.981Z","avatar_url":"https://github.com/htfy96.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# logalign\n\nLogAlign is a command-line tool to annotate log lines with links to their definitons and argument expression.\n\n![screenshot](https://github.com/htfy96/logalign/blob/master/docs/screenshot.png)\n\n## Usage\n\nDownload the latest linux-amd64 canary build from [Release](https://github.com/htfy96/logalign/releases/tag/canary).\n\n### Dependency\n\nThis tool depends on `libpcre2` and `libhyperscan5` to run. Install them from your system's package manager.\n\n### Command-line Usage\n\nFirst, users need to build a **corpus** from source files to extract all relevant log calls. This guide uses [openssh](https://github.com/openssh/openssh-portable) as an example.\n\nClone and download the source of openssh. run `logalign corpus new-config` to generate a sample configuration. Edit `.logalign.toml` to the follows:\n\n```toml\nproject = 'openssh'\n# source files to grep\nsource_regex = '.*\\.c'\nignore_source_regex = 'generated\\.c$'\n\n# Could define multiple [[definitions]] under different 'id'\n[[definitions]]\nid = 'openssh_logs'\n\n# This is a Treesitter query\n# See https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries for the full syntax\n# Use https://intmainreturn0.com/ts-visualizer/ to visualize the TreeSitter AST for a given code snippet\n#\n# It needs to capture three components:\n# - @method: the log function name\n# - @format_string: a printf-like format string. Should not include surrounding quotes\n# - @argument_expr. Each @argument_expr should match one argument passed to the log call. Must match the number of\n#   directives in format_string\nquery = \"\"\"\n\n(call_expression\n  function: (identifier) @method\n  (#match? @method \\\"(logit|error|debug|fatal|logdie|verbose|debug3|debug2)(_f|_r|_fr)?\\\")\n  arguments: (argument_list\n    \\\"(\\\"\n    [(concatenated_string\n      (string_literal\n        _*\n        [(string_content)\n          (escape_sequence)\n        ]+ @format_string\n        _*\n      )+\n    )\n      (string_literal\n        _*\n        [(string_content)\n          (escape_sequence)\n        ]+ @format_string\n        _*\n      )\n    ]\n\n    (\n      \\\",\\\"\n      (_) @argument_expr\n    )*\n    \\\")\\\"\n  )\n)\"\"\"\n# language to run this query. Currently supports c,cpp,java,golang,javascript,python,typescript\nlanguage = 'c'\nsyntax = 'printflike'\n# A template string to link to the source at {file} {line}\nlink_template = 'https://github.com/openssh/openssh-portable/blob/master/{file}#L{line}'\n# Remove redundant '\\n' at the end of @format_string\nstrip_tailing_newline = true\n```\n\nThen, run `logalign corpus build`. It should output `Corpus built successfully`.\n\nCheck the generated corpus via `logalign corpus ls` and `logalign corpus cat openssh`.\n\nTo annoate log files based on built corpus, run `logalign corpus view /var/log/auth.log`. If your terminal supports [OSC-8](https://github.com/Alhadis/OSC8-Adoption), you can control/meta/alt click the\nleft source panel to jump to the definitions.\n\n## LICENSE\n\nApache v2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtfy96%2Flogalign","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtfy96%2Flogalign","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtfy96%2Flogalign/lists"}