{"id":20263139,"url":"https://github.com/briandowns/liblogger","last_synced_at":"2025-06-16T10:33:42.763Z","repository":{"id":54856384,"uuid":"213234966","full_name":"briandowns/liblogger","owner":"briandowns","description":"A simple and performant, single-header JSON structured logger for C applications.","archived":false,"fork":false,"pushed_at":"2025-03-05T17:33:16.000Z","size":74,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T02:08:09.112Z","etag":null,"topics":["c","json","json-logger","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":"bsd-2-clause","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":"2019-10-06T20:00:10.000Z","updated_at":"2025-03-12T01:30:24.000Z","dependencies_parsed_at":"2024-04-12T23:44:13.589Z","dependency_job_id":"5b805ac7-e89b-4e91-bd61-371c4a248fa5","html_url":"https://github.com/briandowns/liblogger","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2Fliblogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2Fliblogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2Fliblogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandowns%2Fliblogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briandowns","download_url":"https://codeload.github.com/briandowns/liblogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248328163,"owners_count":21085261,"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","json","json-logger","logger","logging","structured-logging"],"created_at":"2024-11-14T11:33:40.072Z","updated_at":"2025-04-11T02:08:20.249Z","avatar_url":"https://github.com/briandowns.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# liblogger\n\nliblogger is a structured logger for C/C++. The output format is JSON. liblogger supports writing to stdout, stderr, and to a file.\n\n## Usage\n\nTo use this library, initialize the logger with `s_log_init()` and call the `s_log` macro. The latter macro takes a log level, any number of `s_log_field_t` pointers containing a string key and a log value. \n\nThe supported int values are:  `int`, `int8`, `int16`, `int32`, `int64`\nThe supported uint values are: `uint`, `uint8`, `uint16`, `uint32`, `uint64`\nAnd `float`, `double`, and `string`.\n\nThe supported log levels are: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, \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. Memory is freed after the log entry is written.\n\n## Example \n\nBuild the example:\n\n```\nmake example\n```\n\n```c\n#include \u003cstdio.h\u003e\n\n#include \"logger.h\"\n\nint\nmain(int argc, char **argv)\n{\n    s_log_init(stdout); \n    s_log(S_LOG_INFO, \n        s_log_string(\"msg\", \"records added successfully\"),\n        s_log_uint(\"count\", 2));\n    s_log(S_LOG_INFO, \n        s_log_string(\"msg\", \"records added successfully\"),\n        s_log_int64(\"count\", 9223372036854775807));\n    s_log(S_LOG_INFO, \n        s_log_string(\"msg\", \"record added successfully\"),\n        s_log_string(\"name\", \"Brian\"),\n        s_log_double(\"elapsed\", 5.76));\n    s_log(S_LOG_FATAL, s_log_string(\"msg\", \"dead :(\"));  \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.75 }\n```\n\nWrite to a log file:\n\n```c\nFILE *f = fopen(\"file.log\", \"w\");\ns_log_init(f);\ns_log(S_LOG_INFO,\n    s_log_string(\"msg\", \"records added successfully\"),\n    s_log_uint8(\"count\", 2));\nfclose(f);\n```\n\n## Requirements / Dependencies\n\n* [jansson](https://github.com/akheron/jansson)\n\nA lot 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\nBSD 2 Clause [License](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriandowns%2Fliblogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriandowns%2Fliblogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriandowns%2Fliblogger/lists"}