{"id":51393091,"url":"https://github.com/sona-tau/clog","last_synced_at":"2026-07-04T01:12:06.252Z","repository":{"id":358743962,"uuid":"1242890874","full_name":"sona-tau/clog","owner":"sona-tau","description":"A C Logging library with support for monoid logging and JSONL","archived":false,"fork":false,"pushed_at":"2026-05-18T21:28:22.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-18T23:50:50.801Z","etag":null,"topics":["c","jsonl","logging","monoid"],"latest_commit_sha":null,"homepage":"","language":"C","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/sona-tau.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-18T21:18:53.000Z","updated_at":"2026-05-18T21:27:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sona-tau/clog","commit_stats":null,"previous_names":["sona-tau/clog"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sona-tau/clog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sona-tau%2Fclog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sona-tau%2Fclog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sona-tau%2Fclog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sona-tau%2Fclog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sona-tau","download_url":"https://codeload.github.com/sona-tau/clog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sona-tau%2Fclog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35106726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"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":["c","jsonl","logging","monoid"],"created_at":"2026-07-04T01:12:05.630Z","updated_at":"2026-07-04T01:12:06.247Z","avatar_url":"https://github.com/sona-tau.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clog\n\nA C logging library with monoid logging and three output formats.\n\n## Output formats\n\nSet globally before any logging calls. Defaults to JSONL.\n\n```c\nclog_set_fmt(CLOG_FMT_JSONL);      // default\nclog_set_fmt(CLOG_FMT_TEXT);\nclog_set_fmt(CLOG_FMT_TEXT_COLOR); // ANSI colors\n```\n\n- **JSONL**: one JSON object per line, suitable for log aggregators and `jq`:\n```\n{\"ts\":\"Mon May 18 14:23:01 2026\",\"level\":\"ERR\",\"file\":\"server.c\",\"line\":42,\"func\":\"handle\",\"msg\":\"connection refused\"}\n```\n\n- **TEXT**: human-readable, easy to `grep`:\n```\nserver.c:42:handle Mon May 18 14:23:01 2026 ERR connection refused\n```\n\n- **TEXT_COLOR**: same as TEXT with ANSI level colors (cyan/white/yellow/bold red for INF/DBG/WRN/ERR).\n\nLevels: `CLOG_INF`, `CLOG_DBG`, `CLOG_WRN`, `CLOG_ERR`.\n\n## Imperative mode\n\nEach call immediately prints to stdout. Source location is captured automatically.\n\n```c\n#include \"clog.h\"\n\nclog(CLOG_INF, \"server started\");\nclog(CLOG_ERR, \"connection refused\");\n```\n\n## Monoid mode\n\nLog entries accumulate in a `CLog` (a dynamic array of `ClogEntry`). Nothing is printed until the caller decides to flush. Safe to pass through a call chain; the caller that holds the `CLog` controls when output happens.\n\n```c\n#include \"clog.h\"\n\nvoid work(CLog *log) {\n    clogm(CLOG_INF, *log, \"doing work\");\n    clogm(CLOG_WRN, *log, \"something looks odd\");\n}\n\nint main(void) {\n    CLog log = clog_log_init();\n\n    work(\u0026log);\n\n    clog_log_print(log);   // flush everything at once\n    clog_log_free(log);\n    return 0;\n}\n```\n\n`CLog` is a typed dynamic array (`ClogEntry *`) backed by `dynarr`. Entries are value types stored contiguously — plain indexing (`log[i]`) works.\n\n## Building\n\n```sh\njust          # static (.build/libclog.a) + dynamic (.build/libclog.so)\njust test     # compile and run tests with ASan + UBSan\njust clean    # remove .build/\n```\n\n## Linking\n\nCopy `include/clog.h`, `include/dynarr.h`, `include/prelude.h`, and either `libclog.a` or `libclog.so` into your project, then compile with `-I\u003cinclude_dir\u003e -L\u003clib_dir\u003e -lclog`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsona-tau%2Fclog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsona-tau%2Fclog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsona-tau%2Fclog/lists"}