{"id":18167161,"url":"https://github.com/hyouteki/lodge","last_synced_at":"2025-08-22T20:32:00.854Z","repository":{"id":260680072,"uuid":"882043194","full_name":"hyouteki/lodge","owner":"hyouteki","description":"C Logging Library","archived":false,"fork":false,"pushed_at":"2024-11-02T08:30:23.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-09T13:41:14.267Z","etag":null,"topics":["c","library","logging"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyouteki.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-11-01T19:00:36.000Z","updated_at":"2024-11-02T08:29:11.000Z","dependencies_parsed_at":"2024-11-01T20:17:26.611Z","dependency_job_id":"8a71b12e-4a3b-4b82-bf8d-276ccb84aa05","html_url":"https://github.com/hyouteki/lodge","commit_stats":null,"previous_names":["hyouteki/lodge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyouteki%2Flodge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyouteki%2Flodge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyouteki%2Flodge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyouteki%2Flodge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyouteki","download_url":"https://codeload.github.com/hyouteki/lodge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230634233,"owners_count":18256834,"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","library","logging"],"created_at":"2024-11-02T13:06:45.285Z","updated_at":"2024-12-20T19:21:38.549Z","avatar_url":"https://github.com/hyouteki.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e **Lodge** is a simple yet powerful C logging library that provides configurable log levels, file support, timestamping, and thread safety. It is designed to be easy to integrate into your projects and offers a variety of options for controlling log output and verbosity.\n---\n\n## Features\n1. **Multiple Log Levels**: Supports `DEBUG`, `INFO`, `WARNING`, `ERROR`, and `FATAL` levels.\n2. **Log to File**: Option to output logs to a file in addition to standard output.\n3. **Timestamping**: Each log entry includes a timestamp to track when events occur.\n4. **Thread Safety**: Uses a mutex to ensure logs are safe to use in multi-threaded applications.\n5. **Dynamic Log Level Control**: Set the log level at runtime to control the verbosity.\n\n## Getting Started\n### Requirements\n1. A C compiler (`GCC`, `Clang`, etc.)\n2. POSIX-compliant environment (for `pthread` support)\n### Installation\n1. Include `lodge.h` into your project.\n2. Compile the project with `libpthread`.\n```bash\ngcc your_program.c -o your_program -lpthread\n```\n\n## Usage\n1. Include the library.\n```c\n#include \"lodge.h\"\n```\n\n2. Initialize the logging system with an optional file path. If a file path is provided, logs will be saved to the file.\n```c\nlodge_constructor(filepath); // Logs to a file\n// or\nlodge_constructor(NULL); // Logs to stdout\n```\n\n3. *(Optional)* Set desired log level to control verbosity.\n```c\nlodge_set_log_level(LOG_DEBUG); // Options: LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL\n```\n\n4. Use the provided macros to log messages at different levels:\n```c\nlodge_info(\"This is an informational message.\");\nlodge_debug(\"This is a debug message with value: %d\", 42);\nlodge_warning(\"This is a warning.\");\nlodge_error(\"An error occurred: %s\", strerror(errno));\nlodge_fatal(\"Fatal error, exiting...\");\n```\n\n\u003e [!IMPORTANT]\n\u003e `log_fatal` exits the program with `EXIT_FAILURE`, thus stopping the program execution.\n\n5. *(Important)* Before exiting your application, call `lodge_destructor()` to close any open file handles and free resources.\n\n## Example\n```c\n#include \"lodge.h\"\n\nint main() {\n    lodge_constructor(NULL);\n    lodge_set_log_level(LOG_DEBUG);\n\n    lodge_info(\"Application started\");\n    lodge_debug(\"Debugging value: %d\", 100);\n    lodge_warning(\"This is a warning message.\");\n    lodge_error(\"This is an error message.\");\n    lodge_fatal(\"This is a fatal error message.\");\n\n    lodge_destructor();\n    return 0;\n}\n```\n```console\n2024-11-02 13:55:34 [INFO]: Application started\n2024-11-02 13:55:34 [DEBUG]: Debugging value: 100\n2024-11-02 13:55:34 [WARNING]: This is a warning message.\n2024-11-02 13:55:34 [ERROR]: This is an error message.\n2024-11-02 13:55:34 [FATAL]: This is a fatal error message.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyouteki%2Flodge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyouteki%2Flodge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyouteki%2Flodge/lists"}