{"id":15718882,"url":"https://github.com/ayaankhan98/xlogger","last_synced_at":"2025-03-30T22:27:52.513Z","repository":{"id":45141812,"uuid":"442349807","full_name":"ayaankhan98/xlogger","owner":"ayaankhan98","description":"xlogger is a simple header only logging provider for C++ applications. Using xlogger no need to worry about anything just copy the header file in your project include directory and start using it. xlogger provides facility for logging variables as well as l-values.","archived":false,"fork":false,"pushed_at":"2022-01-05T18:24:57.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T03:40:00.051Z","etag":null,"topics":["console","cpp","file-logger","library","log","logger","logging","logging-library","makefile","open-source"],"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/ayaankhan98.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}},"created_at":"2021-12-28T04:37:40.000Z","updated_at":"2022-01-05T18:25:00.000Z","dependencies_parsed_at":"2022-09-24T20:22:35.704Z","dependency_job_id":null,"html_url":"https://github.com/ayaankhan98/xlogger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaankhan98%2Fxlogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaankhan98%2Fxlogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaankhan98%2Fxlogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaankhan98%2Fxlogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayaankhan98","download_url":"https://codeload.github.com/ayaankhan98/xlogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246388840,"owners_count":20769254,"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":["console","cpp","file-logger","library","log","logger","logging","logging-library","makefile","open-source"],"created_at":"2024-10-03T21:54:14.793Z","updated_at":"2025-03-30T22:27:52.487Z","avatar_url":"https://github.com/ayaankhan98.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xlogger\n\n\n![xlogger](assets/xlogger_1_.svg?raw=true \"xlogger\")\n\nxlogger is a simple header only logging provider for C++ applications. Using\nxlogger no need to worry about anything just copy the header file in your\nproject `include` directory and start using it. xlogger provides facility for\nlogging variables as well as l-values.\n\n### Requirement\n- C++17 or above\n\n### Features\n- [x] console based logging support with different log levels and colors\n- [x] single file based logging support\n- [x] thread safe logging\n- [ ] multi file based logging\n\n### Usage\n- copy `xlogger.hpp` file and paste it into your project `include` directory.\n\n- #### Available Logging Macros\n  - `INFO_X_LOG()`\n  - `DEBUG_X_LOG()`\n  - `WARN_X_LOG()`\n  - `CRITICAL_X_LOG()`\n  - `ERROR_X_LOG()`\n  - `FATAL_X_LOG()`\n\n\n- #### Logging in Console\n  Console logger is enabled by default. Need not to do anything just initiate\n  the xlogger context and start using it. And at the end don't forget to\n  destroy xlogger context.\n\n  Code example:\n  ```C++\n    #include \u003cstring\u003e\n    #include \u003cunordered_map\u003e\n    #include \u003cxlogger.hpp\u003e\n\n    std::unordered_map\u003cstd::string, std::string\u003e fetch_from_server() {\n      std::unordered_map\u003cstd::string, std::string\u003e response;\n      response[\"username\"] = \"foo bar\";\n      response[\"email\"] = \"foo@example.com\";\n      response[\"dob\"] = \"10-10-1999\";\n      return response;\n    }\n\n    int main() {\n      /// Initiate a xlogger context\n      xlogger::init_xlogger();\n\n      INFO_X_LOG(\"Welcome to xlogger\");\n\n      const double PI = 3.145;\n      INFO_X_LOG(\"Value of PI = \", PI);\n\n      auto response = fetch_from_server();\n      DEBUG_X_LOG(\"Response from server: \", response);\n\n      /// Destroy the xlogger context before you exit\n      xlogger::destroy_xlogger();\n      return 0;\n    }\n  ```\n\n- #### Using a File logger\n  File logger can be used to preserve the logs on local disk.\n\n  code example:\n\n  ```C++\n  #include \u003cxlogger.hpp\u003e\n\n  int main() {\n    /// pass the filepath of file in which you wish to preserve the logs.\n    xlogger::init_xlogger(\"log_0_file.xlog\");\n\n    /// Log some stuff as usuall\n    INFO_X_LOG(\"Loggin information\");\n\n    /// Destroy xlogger context\n    xlogger::destroy_xlogger();\n  }\n  ```\n\n  if you wish to just use xlogger as file logger, you can disable console based\n  logging\n\n  ```C++\n  xlogger::init_xlogger(\"log_0_file.xlog\")-\u003eset_type_console(false);\n  ```\n\n- #### Using `xlogger` in Multithreading environment\n  xlogger provide thread safe logging. File logs and console logs are in sync.\n\n  code example:\n\n  ```C++\n  #include \u003cxlogger.hpp\u003e\n  #include \u003cthread\u003e\n\n  void function1() {\n    for (int i = 0; i \u003c 50; i++) {\n      INFO_X_LOG(\"Thread 1: i = \", i);\n    }\n  }\n\n  void function2() {\n    for (int i = 50; i \u003c 100; i++) {\n      WARN_X_LOG(\"Thread 2: i = \", i);\n    }\n  }\n\n  int main() {\n    xlogger::init_xlogger(\"log_0_file.xlog\");\n\n    std::thread t1(function1);\n    std::thread t2(function2);\n\n    for(int i = 100; i \u003c 150; i++) {\n      ERROR_X_LOG(\"Thread Main: i = \", i);\n    }\n\n    t1.join();\n    t2.join();\n\n    xlogger::destroy_xlogger();\n    return 0;\n  }\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayaankhan98%2Fxlogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayaankhan98%2Fxlogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayaankhan98%2Fxlogger/lists"}