{"id":18409293,"url":"https://github.com/sdtelectronics/lite-logger","last_synced_at":"2026-07-18T05:35:45.073Z","repository":{"id":105561323,"uuid":"317144290","full_name":"SdtElectronics/lite-logger","owner":"SdtElectronics","description":"Simple logging library for C++","archived":false,"fork":false,"pushed_at":"2022-01-20T10:26:24.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T17:44:34.594Z","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/SdtElectronics.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-30T07:31:35.000Z","updated_at":"2022-01-02T12:38:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"cba9bcac-6e23-4688-ab4d-a0bc671e2ab4","html_url":"https://github.com/SdtElectronics/lite-logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SdtElectronics/lite-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Flite-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Flite-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Flite-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Flite-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SdtElectronics","download_url":"https://codeload.github.com/SdtElectronics/lite-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Flite-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35606857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-18T02:00:07.223Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2024-11-06T03:24:29.938Z","updated_at":"2026-07-18T05:35:45.055Z","avatar_url":"https://github.com/SdtElectronics.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lite Logger\nHeader-only, lightweight, fully-customizable log library for modern C++.\n\n## Highlights\n* Standard streams style operations\n* Fully customizable message format with simple interface\n* Level and predicate based conditional logging\n\n## Quick Start\n``` c++\n#include \"llogger.h\"\nllogger ll(std::cout, llogger::info);\nll(llogger::warning) \u003c\u003c \"Weather control device detected.\";\n// [ 2021-10-04 22:40:47 ] WARNING: Weather control device detected.\n```\n\n## Conditional Logging\nValues in the log are costly to be evaluated sometimes, or the log at low severity level is too lengthy. In these cases it would be nice to disable specific log accordingly. Lite logger supports two categories of conditions: severity levels and bool expressions. \n\nLite logger has 5 predefined severity levels:\n* `fatal`\n* `error`\n* `warning`\n* `notice`, and\n* `info`\n\nYou can augment or modify them easily with slight changes in source code.\n\nThe severity level of the message is designated by the first parameter passed to the instance of `llogger`, and messages with level lower than the enabled level are not logged. The enabled severity level is initialized with the second parameter in the `llogger` constructor:\n``` c++\nllogger logger(std::cout, ll::error);\nlogger(ll::warning) \u003c\u003c \"Weather control device detected.\";\n// Nothing is printed\n```\nIf the severity level of the message is not provided, the severity level of the previous message is used.\n\nA bool expression can also be passed to the instance of `llogger`. If it is evaluated to `false`, the following message is not logged:\n\n``` c++\nllogger logger(std::cout, ll::error);\nlogger(1 \u003c 0) \u003c\u003c \"Weather control device detected.\";\n// Nothing is printed\n```\n\nThe bool expression can be used together with the severity level, and the later is always passed first:\n\n``` c++\nllogger logger(std::cout, ll::warning);\nlogger(ll::warning, true) \u003c\u003c \"Weather control device detected.\";\n// [ 2021-10-30 22:34:04 ] WARNING: Weather control device detected.\n```\n\nExpressions in the message body are always evaluated before the body is passed to the logger. This is enforced by the semantic of C++ language. To defer the evaluation of expressions, they have to be wrapped inside a lambda (or any callable). They will not be evaluated unless the logging conditions are met:\n\n``` c++\nllogger logger(std::cout, ll::warning);\nlogger(1 \u003c 0) \u003c\u003c []{return \"This is not going to be evaluated!\";};\n// Nothing is printed\n```\n\n## Message Format Customization\nLite logger provides extreme flexibility in customization of message format via the `llfmt` class, which has the same stream operation style as `llogger`. `llfmt` supports 5 types of message segments:\n* `llfmt::level` represents the severity level of this message\n* `llfmt::time` represents the time this message is logged\n* `llfmt::logStr` represents the message text\n* `std::function\u003cstd::string ()\u003e` allows functions returning a `string` to be evaluated during logging, and the returned value is inserted\n* `std::string` is the static text in the message format\n\nThe default format is initialized as a static member of `llogger`. The explicit process of creation and using it to initialize a `llogger` is:\n``` c++\nll::llfmt lfmt;\nlfmt \u003c\u003c \"[\" \u003c\u003c ll::llfmt::time  \u003c\u003c \"] \"\n            \u003c\u003c ll::llfmt::level \u003c\u003c \": \"\n            \u003c\u003c ll::llfmt::logStr;\nllogger ll(std::cout, ll::info, lfmt);\n// The format is\n// [ yyyy-mm-dd hh:mm:ss ] LEVEL: Message.\n```\n`llfmt::logStr` and  `llogger::fmtStr` allows interleaving the format text with the message:\n``` c++\nll::llfmt lfmt;\nlfmt \u003c\u003c \"format text0 \" \n    \u003c\u003c ll::llfmt::logStr \n    \u003c\u003c \"format text1 \" \n    \u003c\u003c ll::llfmt::logStr;\nllogger logger(std::cout, ll::info, lfmt);\nlogger(ll::warning) \u003c\u003c \"Message 0 \" \u003c\u003c ll::fmtStr \u003c\u003c \"Message 1\";\n// format text0 Message 0 format text1 Message 1\n```\nFunctionalities like a counter are easy to be implemented with a function in the format:\n``` c++\nll::llfmt lfmt;\nint cnt = 0;\nlfmt \u003c\u003c \"[\" \u003c\u003c []{std::to_string(++cnt);} \u003c\u003c \"] \"\n            \u003c\u003c ll::llfmt::level \u003c\u003c \": \"\n            \u003c\u003c ll::llfmt::logStr;\nllogger logger(std::cout, llogger::info, lfmt);\nlogger(ll::warning) \u003c\u003c \"Message 1 \"\n// [1] WARNING: Message 1\nlogger(ll::warning) \u003c\u003c \"Message 2 \"\n// [2] WARNING: Message 2\n```\n## Integration\nllogger is a single-header library. To use it, simply include `llogger.h`:\n```C++\n#include \"llogger.h\"\n```\nllogger requires a compiler supporting C++11 or above.\n\n## Thread Safety\nllogger guarantees segments in a line will not interleave with segments printed in other thread. The thread safety of writing to a stream should be granted by the stream passed to llogger.\n\n## License\nNo license.\n\nRather than a mature logging library, this project is more of a demonstration of the ideal interface of a logging library for C++ in my conception. It is heavily inspired by [glog](https://github.com/google/glog) but incorporates no macro to implement fancy features like conditional logging. Huge feature gap is yet to be filled to make it a complete library, but if you want to embedd it to your project, please feel free to do it :)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdtelectronics%2Flite-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdtelectronics%2Flite-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdtelectronics%2Flite-logger/lists"}