{"id":15374872,"url":"https://github.com/babelouest/yder","last_synced_at":"2025-04-15T11:33:03.512Z","repository":{"id":54455689,"uuid":"47931151","full_name":"babelouest/yder","owner":"babelouest","description":"Logging library for C applications","archived":false,"fork":false,"pushed_at":"2024-03-04T22:52:23.000Z","size":606,"stargazers_count":21,"open_issues_count":0,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-05T06:53:00.962Z","etag":null,"topics":["c","journald","logging","syslog"],"latest_commit_sha":null,"homepage":"https://babelouest.github.io/yder/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babelouest.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2015-12-13T18:30:32.000Z","updated_at":"2024-07-15T19:34:37.000Z","dependencies_parsed_at":"2023-12-30T04:29:11.626Z","dependency_job_id":"8d79c780-4bc8-4151-a90f-c578bb2f5ff7","html_url":"https://github.com/babelouest/yder","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babelouest%2Fyder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babelouest%2Fyder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babelouest%2Fyder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babelouest%2Fyder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babelouest","download_url":"https://codeload.github.com/babelouest/yder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219843081,"owners_count":16556591,"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","journald","logging","syslog"],"created_at":"2024-10-01T13:59:56.132Z","updated_at":"2024-10-16T14:03:33.847Z","avatar_url":"https://github.com/babelouest.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yder\n\nLogging library written in C.\n\n![.github/workflows/main.yml](https://github.com/babelouest/yder/workflows/.github/workflows/main.yml/badge.svg)\n\nSimple and easy to use logging library. You can log messages to the console, a file, Syslog, journald or a callback function.\n\nYder is mono-thread, which mean that you can use only one instance of Yder log at the same time in your program.\n\nSee the [online documentation](https://babelouest.github.io/yder/) for a doxygen format of the API documentation.\n\n# Installation\n\n## Distribution packages\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/yder.svg)](https://repology.org/metapackage/yder)\n\nYder is available in multiple distributions as official package. Check out your distribution documentation to install the package automatically.\n\n```shell\n$ # Example for Debian testing\n$ sudo apt install libyder-dev # Or apt install libyder2.0 if you don't need the development files\n```\n\n## Pre-compiled packages\n\nYou can install Yder with a pre-compiled package available in the [release pages](https://github.com/babelouest/yder/releases/latest/). Note that you need to install [Orcania](https://github.com/babelouest/orcania/releases/latest/) first. `jansson` development files packages is required to install Yder.\n\n## Manual install\n\n### Prerequisites\n\nYou must install [Orcania](https://github.com/babelouest/orcania) first before building Yder. Orcania will be automatically installed if missing and you're using CMake.\n\n### CMake - Multi architecture\n\n[CMake](https://cmake.org/download/) minimum 3.5 is required.\n\nRun the CMake script in a sub-directory, example:\n\nLast Yder release: [https://github.com/babelouest/yder/releases/latest/](https://github.com/babelouest/yder/releases/latest/)\n\n```shell\n$ cd \u003cyder_source\u003e\n$ mkdir build\n$ cd build\n$ cmake ..\n$ make \u0026\u0026 sudo make install\n```\n\nThe available options for CMake are:\n- `-DWITH_JOURNALD=[on|off]` (default `on`): Build with journald (SystemD) support\n- `-DBUILD_STATIC=[on|off]` (default `off`): Build the static archive in addition to the shared library\n- `-DBUILD_YDER_TESTING=[on|off]` (default `off`): Build unit tests\n- `-DBUILD_YDER_DOCUMENTATION=[on|off]` (default `off`): Build the documentation, doxygen is required\n- `-DINSTALL_HEADER=[on|off]` (default `on`): Install header file `yder.h`\n- `-DBUILD_RPM=[on|off]` (default `off`): Build RPM package when running `make package`\n- `-DCMAKE_BUILD_TYPE=[Debug|Release]` (default `Release`): Compile with debugging symbols or not\n\n### Good ol' Makefile\n\nDownload Yder from GitHub repository, compile and install.\n\nLast Yder release: [https://github.com/babelouest/yder/releases/latest/](https://github.com/babelouest/yder/releases/latest/)\n\n```shell\n$ cd yder/src\n$ make\n$ sudo make install\n```\n\nTo build Yder without Journald (SystemD) support, add the option Y_DISABLE_JOURNALD=1 to the `make command`:\n\n```shell\n$ git clone https://github.com/babelouest/yder.git\n$ cd yder/src\n$ make Y_DISABLE_JOURNALD=1\n$ sudo make install\n```\n\nBy default, the shared library and the header file will be installed in the `/usr/local` location. To change this setting, you can modify the `DESTDIR` value in the `src/Makefile`.\n\nExample: install Yder in /tmp/lib directory\n\n```shell\n$ cd src\n$ make \u0026\u0026 make DESTDIR=/tmp install\n```\n\nYou can install Yder without root permission if your user has write access to `$(DESTDIR)`.\nA `ldconfig` command is executed at the end of the install, it will probably fail if you don't have root permission, but this is harmless.\nIf you choose to install Yder in another directory, you must set your environment variable `LD_LIBRARY_PATH` properly.\n\n### Install Yder as a static archive\n\nInstall Yder library as a static archive, `libyder.a`, use the make commands `make static*`:\n\n```shell\n$ cd src\n$ make static \u0026\u0026 sudo make static-install # or make DESTDIR=/tmp static-install if you want to install in `/tmp/lib`\n```\n\n# API Documentation\n\n## Header files and compilation\n\nTo use Yder in your code, you must include the file `yder.h`.\n\n```c\n#include \u003cyder.h\u003e\n```\n\n### Initialization\n\nUse the `y_init_logs` function to start logging. The prototype of this function is:\n\n```c\n/**\n * Initialize logging with mode and level parameters, specify a log file if needed\n * Return true on success, false on error\n */\nint y_init_logs(const char * app, const unsigned long init_mode, const unsigned long init_level, const char * init_log_file, const char * message);\n```\n\nThe parameter `init_mode` is the initial mode for logging. You can specify and combine the following modes available:\n\n```c\nY_LOG_MODE_CONSOLE\nY_LOG_MODE_SYSLOG\nY_LOG_MODE_JOURNALD\nY_LOG_MODE_FILE\nY_LOG_MODE_CALLBACK\n```\n\nIf you use Y_LOG_MODE_FILE in your initial mode, you must specify a valid path for the `init_log_file` parameter.\n\nThe parameter `init_level` is the bottom level of your log messages. The levels available are, by level order:\n\n```c\nY_LOG_LEVEL_NONE\nY_LOG_LEVEL_ERROR\nY_LOG_LEVEL_WARNING\nY_LOG_LEVEL_INFO\nY_LOG_LEVEL_DEBUG\n```\n\nFor example, if you specify `Y_LOG_LEVEL_WARNING` as init_level, you will see in your log output only `Y_LOG_LEVEL_WARNING` and `Y_LOG_LEVEL_ERROR`. If you specify `Y_LOG_LEVEL_DEBUG`, you will see in your log output all log messages.\n\n### Redirect log messages to a callback function\n\nIf you need to redirect log messages to a custom callback function, for example if you need to interact with other logging libraries, you must use the init_mode `Y_LOG_MODE_CALLBACK` in the `init_mode` parameter in the `y_init_logs` function, then use the function `y_set_logs_callback` with your callback function as parameter.\n\n```C\n/**\n * Specify a callback function that will catch all log messages\n * In addition to other logs output already defined in y_init_logs\n */\nint y_set_logs_callback(void (* y_callback_log_message) (void * cls, const char * app_name, const time_t date, const unsigned long level, const char * message),\n                        void * cls,\n                        const char * message);\n```\n\nThe callback log function must have the following signature:\n\n```C\nvoid y_callback_log_message(void * cls, const char * app_name, const time_t date, const unsigned long level, const char * message);\n```\n\nThe parameters in the callback function are:\n```C\n- void * cls // Your specified parameter\n- const char * app_name // The value app_name from y_init_logs\n- const time_t date // The datestamp when the log message was launched\n- const unsigned long level // The log level of the message, values can be: Y_LOG_LEVEL_ERROR, Y_LOG_LEVEL_WARNING, Y_LOG_LEVEL_INFO, Y_LOG_LEVEL_DEBUG\n```\n\n### Close Yder\n\nTo close Yder and free its allocated memory, use the function `y_close_logs`:\n\n```c\n/**\n * Close the logs\n */\nint y_close_logs();\n```\n\n### Log a message\n\nTo log a message, use the function `y_log_message`, defined by:\n\n```c\n/**\n * Log a message using current parameters\n */\nvoid y_log_message(const unsigned long type, const char * message, ...);\n```\n\nThis function uses `printf` prototype for the message and the log message type. For example:\n\n```c\ny_log_message(Y_LOG_LEVEL_INFO, \"Initializing application\");\ny_log_message(Y_LOG_LEVEL_ERROR, \"Error in application, you have %d over %d threads in error mode\", threads_error, threads_total);\n```\n\n### Example source code\n\nSee `examples` folder for detailed sample source codes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabelouest%2Fyder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabelouest%2Fyder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabelouest%2Fyder/lists"}