{"id":24486155,"url":"https://github.com/oktal/logpp","last_synced_at":"2025-04-13T19:40:58.030Z","repository":{"id":38457762,"uuid":"327251229","full_name":"oktal/logpp","owner":"oktal","description":"A modern, fast, structured logging framework in C++","archived":false,"fork":false,"pushed_at":"2023-05-06T12:32:51.000Z","size":467,"stargazers_count":59,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T10:21:16.524Z","etag":null,"topics":["cpp17","logging","performance"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oktal.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}},"created_at":"2021-01-06T08:42:25.000Z","updated_at":"2025-03-07T16:16:04.000Z","dependencies_parsed_at":"2022-08-19T18:40:55.084Z","dependency_job_id":null,"html_url":"https://github.com/oktal/logpp","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktal%2Flogpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktal%2Flogpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktal%2Flogpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktal%2Flogpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oktal","download_url":"https://codeload.github.com/oktal/logpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248770253,"owners_count":21158941,"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":["cpp17","logging","performance"],"created_at":"2025-01-21T14:33:21.646Z","updated_at":"2025-04-13T19:40:58.007Z","avatar_url":"https://github.com/oktal.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI][ci-shield]][ci-url]\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\n\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003ch3 align=\"center\"\u003elogpp\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    A modern, fast, structured logging framework in C++\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/oktal/logpp\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/oktal/logpp/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/oktal/logpp/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\n\n\u003cdetails open=\"open\"\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#roadmap\"\u003eRoadmap\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgements\"\u003eAcknowledgements\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n## About The Project\n\nThe logging framework you've always dreamed of.\u003cbr /\u003e\u003cbr /\u003e\nLog events are first recorded from a `Logger`, formatted with a `Formatter` like [logfmt](https://github.com/oktal/logpp/blob/master/include/logpp/format/LogFmtFormatter.h) or [pattern](https://github.com/oktal/logpp/blob/master/include/logpp/format/PatternFormatter.h) and sent to a `Sink` for persistence or visualization like [console](https://github.com/oktal/logpp/blob/master/include/logpp/sinks/ColoredConsole.h), [file](https://github.com/oktal/logpp/blob/master/include/logpp/sinks/file/FileSink.h) and [others](https://github.com/oktal/logpp/tree/master/include/logpp/sinks)\n\nUnlike other well-known logging frameworks, `logpp` has been designed with the idea of enriching log events with information called *structured data*.\nThe act of adding data to log messages is called [structured logging](https://stackify.com/what-is-structured-logging-and-why-developers-need-it/).\n\nFor example, with logpp, a typical structured log event looks like this:\n\n```cpp\nlogpp::info(\"Handling http request\",\n    logpp::field(\"path\", path),\n    logpp::field(\"method\", method));\n ```\n \n and will yield the following string rendered into [logfmt format](https://www.brandur.org/logfmt):\n \n `lvl=Info msg=\"Handling http request\" path=/v1/ping method=GET`\n\nAt its core, logpp has been designed with a zero-allocation approach, meaning that it will avoid memory allocations for small log events.\nCombined with [asynchronocity](https://github.com/oktal/logpp/blob/master/include/logpp/sinks/AsyncSink.h), logpp is a perfect fit for logging in critical code paths.\n\n### Features\n\n* Level-based logging API with familiar levels like `debug`, `info`, `warn`, `error`\n* Hierarchical loggers. Loggers are organized in a tree-based hierarchy, e.g `Namespace`, `Namespace.Component`, `Namespace.Component.Class`\n* [TOML](http://toml.io) runtime configuration, see [logpp.toml](https://github.com/oktal/logpp/blob/master/examples/logpp.toml) example\n* Enrichment of log messages with contextual structured fields\n* Built-in support for a variety of [sinks](https://github.com/oktal/logpp/tree/master/include/logpp/sinks)\n    * Colored console\n    * File\n    * Rolling file\n    * Please [contribute](#contributing) yours !\n* Extandable and configurable log [formatters](https://github.com/oktal/logpp/tree/master/include/logpp/format)\n    * Pattern\n    * [logfmt](https://www.brandur.org/logfmt)\n* Asynchronous logging (optional)\n* Zero-allocation logging strategy for small log messages\n\n### Built With\n\n* [conan](https://conan.io/)\n* [CMake](https://cmake.org/)\n\n## Getting Started\n\n### Prerequisites\n\nTo retrieve logpp external dependencies, make sure to install and configure [conan](https://conan.io) on your local machine.\n\n### Installation\n\n1. Clone the repo\n   ```sh\n   git clone https://github.com/oktal/logpp.git\n   ```\n2. Create a build directory\n   ```sh\n        cd logpp\n        mkdir build\n    ```\n3. Install dependencies\n   ```sh\n       cd build\n       conan install ..\n   ```\n4. Build the library\n   ```sh\n       conan build ..\n   ```\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\n### Namespace\n\nThe logpp api is located in the `logpp` namespace\n\n### Basic\n\n```cpp\n#include \"logpp/logpp.h\"\n\nint main(int argc, char* argv[])\n{\n    logpp::info(\"This is a log message\",\n        logpp::field(\"exe_name\", argv[0]));\n}\n```\n\n```console\n2021-04-12 13:28:50 [info] (logpp) This is a log message - exe_name=./bin/sample_BasicLogger\n```\n\nlogpp provides a default logger that will log all messages into the standard output. logpp `trace`, `debug`, `info`, `warn` and `error` functions will all use\nthe default logger provided by logpp.\n\n### Manual setup\n\nThis example demonstrates how to setup a manual logger to log to a file.\n\n```cpp\n#include \"logpp/sinks/file/FileSink.h\"\n#include \"logpp/core/Logger.h\"\n\nusing namespace logpp;\n\nint main()\n{\n    auto sink = std::make_shared\u003csink::FileSink\u003e(\"main.log\");\n    auto logger = std::make_shared\u003cLogger\u003e(\"main\", LogLevel::Info, sink);\n\n    logger-\u003einfo(\"Hello from main\");\n}\n```\n\n```console\n\u003e cat main.log \n2021-04-12 13:34:35 [info] (main) Hello from main\n```\n\n### Configuration file\n\nLogpp registry can be configured from a [TOML](https://toml.io/en/) configuration file. The following example demonstrates how to do it:\n\n```cpp\n#include \"logpp/config/TomlConfigurator.h\"\n#include \"logpp/logpp.h\"\n\n#include \u003ciostream\u003e\n\nint main(int argc, const char* argv[])\n{\n    std::string file = \"logpp.toml\";\n    if (argc == 2)\n        file = argv[1];\n\n    std::cout \u003c\u003c \"Configuring logger with \" \u003c\u003c file \u003c\u003c std::endl;\n    auto err = logpp::TomlConfigurator::configureFile(file);\n\n    if (err)\n    {\n        std::cerr \u003c\u003c \"Error configuring logger: \" \u003c\u003c *err \u003c\u003c std::endl;\n        return 0;\n    }\n\n    auto logger = logpp::getLogger(\"main\");\n\n    logger-\u003einfo(\"This is an informational message\",\n                 logpp::field(\"exe_name\", argv[0]));\n}\n```\n\nFor a detailed description of logpp configuration format, please refer to [logpp.toml](https://github.com/oktal/logpp/blob/master/examples/logpp.toml)\n\n### Examples\n\n_For more examples, please refer to the [examples](https://github.com/oktal/logpp/examples) folder_\n\n\n## Roadmap\n\nSee the [open issues](https://github.com/othneildrew/Best-README-Template/issues) for a list of proposed features (and known issues).\n\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n[contributors-shield]: https://img.shields.io/github/contributors/oktal/logpp.svg?style=for-the-badge\n[contributors-url]: https://github.com/oktal/logpp/graphs/contributors\n[ci-shield]: https://img.shields.io/github/workflow/status/oktal/logpp/CI?style=for-the-badge\n[ci-url]: https://github.com/oktal/logpp/workflows/CI/badge.svg\n[forks-shield]: https://img.shields.io/github/forks/oktal/logpp.svg?style=for-the-badge\n[forks-url]: https://github.com/oktal/logpp/network/members\n[stars-shield]: https://img.shields.io/github/stars/oktal/logpp.svg?style=for-the-badge\n[stars-url]: https://github.com/oktal/logpp/stargazers\n[issues-shield]: https://img.shields.io/github/issues/oktal/logpp.svg?style=for-the-badge\n[issues-url]: https://github.com/oktal/logpp/issues\n[license-shield]: https://img.shields.io/github/license/oktal/logpp.svg?style=for-the-badge\n[license-url]: https://github.com/oktal/logpp/blob/master/LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktal%2Flogpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktal%2Flogpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktal%2Flogpp/lists"}