{"id":24737544,"url":"https://github.com/engineersbox/c-logger","last_synced_at":"2025-07-09T05:34:43.959Z","repository":{"id":44384243,"uuid":"511888461","full_name":"EngineersBox/C-Logger","owner":"EngineersBox","description":"Simple logging macro for C projects","archived":false,"fork":false,"pushed_at":"2022-10-12T09:02:35.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T17:45:03.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/EngineersBox.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}},"created_at":"2022-07-08T12:32:13.000Z","updated_at":"2022-07-09T22:52:28.000Z","dependencies_parsed_at":"2023-01-20T00:45:38.198Z","dependency_job_id":null,"html_url":"https://github.com/EngineersBox/C-Logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EngineersBox/C-Logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FC-Logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FC-Logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FC-Logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FC-Logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EngineersBox","download_url":"https://codeload.github.com/EngineersBox/C-Logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FC-Logger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264400046,"owners_count":23602200,"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":[],"created_at":"2025-01-27T22:08:38.441Z","updated_at":"2025-07-09T05:34:43.935Z","avatar_url":"https://github.com/EngineersBox.png","language":"C","readme":"# C-Logger\nSimple logging macro for C projects\n\n## Defines\n\n* `ENABLE_LOGGING`: Enables logging\n* `LOG_DATETIME_PREFIX`: Enables the datetime prefix in logs\n* `LOGS_DIR(char*)`: Tee logging output to a file within a specified directory (argument)\n* `MIN_LOG_LEVEL`: Set the minimum log level, defaults to `LL_TRACE`\n\n## Levels\n\n* `LL_FATAL` (Exits with code 1 after logging)\n* `LL_ERROR`\n* `LL_WARN`\n* `LL_INFO`\n* `LL_DEBUG`\n* `LL_TRACE`\n\n## Macros\n\n* `LOG(level, msg, ...)`\n* `FATAL(msg, ...)`\n* `ERROR(msg, ...)`\n* `WARN(msg, ...)`\n* `INFO(msg, ...)`\n* `DEBUG(msg, ...)`\n* `TRACE(msg, ...)`\n\n## Usage\n\nWith datetime prefix\n```c\n#define ENABLE_LOGGING\n#define LOG_DATETIME_PREFIX\n#include \"logger.h\"\n\nint main(int argc, char* argv[]) {\n    LOG(INFO, \"Test log with %d params: [%s: %d]\", 3, \"test\", 56135);\n    // Prints: [8/7/2022 22:31:32] main(example.c:7) [ERROR] :: Test log with 2 params: [test1: 56135]\n    \n    TRACE(\"Test %d for some %s\", 2, \"value\");\n    // Prints: [8/7/2022 22:31:32] main(example.c:10) [TRACE] :: Test 2 for some value\n    \n    INFO(\"No variadic example\");\n    // Prints: [8/7/2022 22:31:32] main(example.c:13) [INFO ] :: No variadic example\n}\n```\n\nWithout datetime prefix\n```c\n#define ENABLE_LOGGING\n//#define LOG_DATETIME_PREFIX\n#include \"logger.h\"\n\nint main(int argc, char* argv[]) {\n    LOG(INFO, \"Test log with %d params: [%s: %d]\", 3, \"test\", 56135);\n    // Prints: main(example.c:7) [ERROR] :: Test log with 2 params: [test1: 56135]\n    \n    TRACE(\"Test %d for some %s\", 2, \"value\");\n    // Prints: main(example.c:10) [TRACE] :: Test 2 for some value\n    \n    INFO(\"No variadic example\");\n    // Prints: main(example.c:13) [INFO ] :: No variadic example\n}\n```\n\nTee'd output to a file\n```c\n#define ENABLE_LOGGING\n#define LOG_DATETIME_PREFIX\n#include \"logger.h\"\nLOGS_DIR(\"/tmp/example/logs\");\n\nint main(int argc, char* argv[]) {\n    LOG(INFO, \"Test log with %d params: [%s: %d]\", 3, \"test\", 56135);\n    // Prints: [8/7/2022 22:31:32] main(example.c:7) [ERROR] :: Test log with 2 params: [test1: 56135]\n    \n    TRACE(\"Test %d for some %s\", 2, \"value\");\n    // Prints: [8/7/2022 22:31:32] main(example.c:10) [TRACE] :: Test 2 for some value\n    \n    INFO(\"No variadic example\");\n    // Prints: [8/7/2022 22:31:32] main(example.c:13) [INFO ] :: No variadic example\n}\n```\nLog output at `/tmp/example/logs/log_8-7-2022_22-31-32.log`\n```\n[8/7/2022 22:31:32] main(example.c:7) [ERROR] :: Test log with 2 params: [test1: 56135]\n[8/7/2022 22:31:32] main(example.c:10) [TRACE] :: Test 2 for some value\n[8/7/2022 22:31:32] main(example.c:13) [INFO ] :: No variadic example\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineersbox%2Fc-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fengineersbox%2Fc-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineersbox%2Fc-logger/lists"}