{"id":15049001,"url":"https://github.com/briandowns/structured-logger","last_synced_at":"2025-04-10T01:40:37.236Z","repository":{"id":81489637,"uuid":"155796835","full_name":"briandowns/struCtured-logger","owner":"briandowns","description":"A simple JSON structured logger for C applications.","archived":false,"fork":false,"pushed_at":"2019-06-17T16:36:26.000Z","size":46,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T03:22:20.497Z","etag":null,"topics":["c","c-language","json","logger","logging","structured-logging"],"latest_commit_sha":null,"homepage":"","language":"C++","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/briandowns.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":"2018-11-02T01:21:45.000Z","updated_at":"2023-12-24T19:00:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"4ba9fac3-12ed-4979-b7ba-d6b237bbd2bb","html_url":"https://github.com/briandowns/struCtured-logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2FstruCtured-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2FstruCtured-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2FstruCtured-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2FstruCtured-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briandowns","download_url":"https://codeload.github.com/briandowns/struCtured-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142001,"owners_count":21054574,"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":["c","c-language","json","logger","logging","structured-logging"],"created_at":"2024-09-24T21:17:34.153Z","updated_at":"2025-04-10T01:40:37.205Z","avatar_url":"https://github.com/briandowns.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# struCtured-logger\n\nstruCtured-logger is a simple JSON logger for C applications. This first version only supports strings for the key types but I'm working on another version to support numbers and boolean values.\n\n## Use\n\nTo use this library, call the `log` macro. This macro takes a log level, a string key, and a log value. The values supported are int, int64, double, and string. To use one of those as a value, the value needs to be passed as a parameter to one of the associated functions. Ie `log_int64(6789)`.\n\nFor a successful log entry to be made, a key and a value need to be provided. If no value is provided, that field will not be logged.\n\n## Example \n\nBuild the example:\n\n```\nmake example\n```\n\n```c\n#include \u003cstdio.h\u003e\n\n#include \"log.h\"\n\nint\nmain(int argc, char **argv)\n{\n    log_init(stdout);\n    log(LOG_INFO, \"msg\", log_string(\"records added successfully\"), \"count\", log_int(2));\n    log(LOG_INFO, \"msg\", log_string(\"records added successfully\"), \"count\", log_int64(9223372036854775807));\n    log(LOG_INFO, \"msg\", log_string(\"records added partially\"), \"count\", log_int64(3.14));\n    log(LOG_INFO, \"msg\", log_string(\"record added successfully\"), \"name\", log_string(\"Brian\"), \"elapsed\", log_double(5.76)); \n}\n```\n\nExpected output:\n\n```sh\n{ \"timestamp\": 1541620673, \"level\": \"info\", \"msg\": \"records added successfully\", \"count\": 2 }\n{ \"timestamp\": 1541620673, \"level\": \"info\", \"msg\": \"records added successfully\", \"count\": 9223372036854775807 }\n{ \"timestamp\": 1541620673, \"level\": \"info\", \"msg\": \"records added partially\", \"count\": 3 }\n{ \"timestamp\": 1541620673, \"level\": \"info\", \"msg\": \"record added successfully\", \"name\": \"Brian\", \"elapsed\": 5.7599999999999998 }\n```\n\nWrite to a log file\n\n```c\nFILE *f = fopen(\"file.log\", \"w\");\nif (f == NULL) {\n    perror(\"couldn't open file.log\");\n    return 1;\n}\nlog_init(f);\nlog(LOG_INFO, \"msg\", log_string(\"records added successfully\"), \"count\", log_int(2));\nfclose(f);\n```\n\n## Requirements\n\n* [json-c](https://github.com/json-c/json-c) \n\nLots of thanks to [Ayan George](https://github.com/ayang64) for the help with getting this where it is.\n\n## Contact\n\nBrian Downs [@bdowns328](http://twitter.com/bdowns328)\n\n## License\n\nApache [License](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriandowns%2Fstructured-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriandowns%2Fstructured-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriandowns%2Fstructured-logger/lists"}