{"id":20468998,"url":"https://github.com/neko-box-coder/sslogger","last_synced_at":"2025-03-05T13:20:13.635Z","repository":{"id":117867566,"uuid":"523498236","full_name":"Neko-Box-Coder/ssLogger","owner":"Neko-Box-Coder","description":"Super Simple Logger for call stack and quick debug logging","archived":false,"fork":false,"pushed_at":"2025-03-03T11:36:04.000Z","size":8059,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T12:33:48.121Z","etag":null,"topics":["c-plus-plus","cpp","cpp-macros","cpp11","cross-platform","header-only","logger","logging","logging-library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Neko-Box-Coder.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":"2022-08-10T21:12:34.000Z","updated_at":"2025-02-17T22:20:01.000Z","dependencies_parsed_at":"2024-07-08T00:25:36.465Z","dependency_job_id":"63db5d73-4705-4296-9ad0-6ff37640c73b","html_url":"https://github.com/Neko-Box-Coder/ssLogger","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/Neko-Box-Coder%2FssLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FssLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FssLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FssLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neko-Box-Coder","download_url":"https://codeload.github.com/Neko-Box-Coder/ssLogger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242031569,"owners_count":20060608,"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-plus-plus","cpp","cpp-macros","cpp11","cross-platform","header-only","logger","logging","logging-library"],"created_at":"2024-11-15T14:07:35.610Z","updated_at":"2025-03-05T13:20:13.628Z","avatar_url":"https://github.com/Neko-Box-Coder.png","language":"C++","readme":"# ssLogger 📔\nA lightweight, flexible C++11 logging library with call stack tracking and multi-threading support.\n\n![](./logo.png)\n\n## ✨ Key Features\n\n- 🗒️ **Call Stack Tracking**: Full function call stack visualization\n- 🎯 **Multiple Log Levels**: FATAL, ERROR, WARNING, INFO, DEBUG with runtime control\n- 🧵 **Thread Safety**: Built-in support for multi-threaded applications\n- 🚀 **Minimal Dependencies**: Header-only or CMake integration\n- ⚡ **High Performance**: Optional caching and configurable thread safety\n- 🛠️ **Highly Configurable**: Extensive compile-time and runtime options\n\n## 📸 Quick Look\n\n### Call Stack Visualization\n![demo](./Resources/demo.gif)\n\n### Simple Function Logging\n![demo2](./Resources/demo2.gif)\n\n### Thread-Safe Logging\n![demo3](./Resources/MultiThread.png)\n\n### Log Levels\n![logLevel](./Resources/logLevels.png)\n\n## 🚀 Getting Started\n\n### Installation\n\n1. Add ssLogger to your project:\n    ```shell\n    git submodule add https://github.com/Neko-Box-Coder/ssLogger.git\n    # OR\n    git clone https://github.com/Neko-Box-Coder/ssLogger.git\n    ```\n\n2. Choose your integration method:\n\n    #### CMake Integration\n    ```cmake\n    add_subdirectory(path/to/ssLogger)\n    target_link_libraries(YourTarget PUBLIC ssLogger)\n    ```\n\n    #### Header-Only Usage\n    1. Add `include/ssLogger` to your include paths\n    2. Include in your entry point (once):\n      ```cpp\n      #include \"ssLogger/ssLogInit.hpp\"\n      #include \"ssLogger/ssLog.hpp\"\n      ```\n    3. Define macro options you want before including `ssLog.hpp`. See [Configuration](#configuration) for all options.\n\n\u003e ⚠️ **Warning**: Do not use ssLogger before main() as it uses global static variables.\n\n## 💻 Basic Usage\n\n### Simple Line Logging\n```cpp\nssLOG_LINE(\"Hello, World!\");  //Basic logging\nssLOG_LINE(\"Value: \" \u003c\u003c 42);  //Stream-style logging\n\n//Different log levels\nssLOG_FATAL(\"Critical error!\");\nssLOG_ERROR(\"Error occurred\");\nssLOG_WARNING(\"Warning message\");\nssLOG_INFO(\"Information\");\nssLOG_DEBUG(\"Debug info\");\n\n//Set runtime log level for current thread\nssLOG_SET_CURRENT_THREAD_TARGET_LEVEL(ssLOG_LEVEL_ERROR);\n\n//Get current thread's target log level\nint level = ssLOG_GET_CURRENT_THREAD_TARGET_LEVEL();\n```\n\n### Function Call Tracking\n```cpp\nvoid ProcessData()\n{\n    ssLOG_FUNC();  //Automatically logs function entry/exit\n    ssLOG_LINE(\"Processing...\");\n}\n\n//Custom function name (great for lambdas)\nauto handler = []() \n{\n    ssLOG_FUNC(\"CustomHandler\");\n    //... code ...\n};\n\n//Function tracking with different log levels\nssLOG_FUNC_ERROR(\"Critical operation\");\nssLOG_FUNC_WARNING(\"Important operation\");\nssLOG_FUNC_INFO(\"Normal operation\");\n```\n\n### Log Caching And Thread Control\n```cpp\n//Cache in current scope\nssLOG_CACHE_OUTPUT_IN_SCOPE();\n\n//Global cache control\nssLOG_ENABLE_CACHE_OUTPUT();   //Enable for all threads\nssLOG_DISABLE_CACHE_OUTPUT();  //Disable for all threads\n\n//Thread-specific cache control\nssLOG_ENABLE_CACHE_OUTPUT_FOR_CURRENT_THREAD();   //Enable for current thread\nssLOG_DISABLE_CACHE_OUTPUT_FOR_CURRENT_THREAD();  //Disable for current thread\n\nbool isCaching = ssLOG_IS_CACHE_OUTPUT_FOR_CURRENT_THREAD();  //Check if current thread is caching\n\n//New thread cache control\nssLOG_ENABLE_CACHE_OUTPUT_FOR_NEW_THREADS();   //Enable for new threads\nssLOG_DISABLE_CACHE_OUTPUT_FOR_NEW_THREADS();  //Disable for new threads\n\n//Reset all thread information\nssLOG_RESET_ALL_THREAD_INFO();   //Clear all thread info and reset thread ID counter\n\n//Output cached logs\nssLOG_OUTPUT_ALL_CACHE();           //Output all cached logs\nssLOG_OUTPUT_ALL_CACHE_GROUPED();   //Output grouped by thread\n\n//Combine caching with log levels\nssLOG_CACHE_OUTPUT_IN_SCOPE();\nssLOG_ERROR(\"This error will be cached\");\nssLOG_WARNING(\"This warning will be cached\");\n```\n\n## ⚙️ Configuration\n\n### Key Configuration Options\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| ssLOG_CALL_STACK | 1 | Enable function call stack tracking |\n| ssLOG_THREAD_SAFE_OUTPUT | 1 | Enable thread-safe output |\n| ssLOG_LEVEL | 3 | Compile-time log level (0:NONE to 5:DEBUG) |\n| ssLOG_MODE | 0 | Log mode for ssLogger (0: CONSOLE, 1: FILE, 2: CONSOLE_AND_FILE) |\n| ssLOG_SHOW_DATE | 0 | Show date in logs |\n| ssLOG_SHOW_TIME | 1 | Show time in logs |\n\n\u003e 📝 For a complete list of options, see [Configuration Details](#configuration-details) below.\n\n## 🔍 Advanced Features\n\n\u003c!-- \n\n### Raw Output and Custom Implementation\n```cpp\n//Basic output without formatting and thread safe checks\n//Expects stream operations (\u003c\u003c)\nssLOG_BASE(\"Hello\" \u003c\u003c 42);  \n\n//Custom implementation example\nstatic std::mutex logMutex;\nstatic std::ofstream logFile(\"app.log\", std::ios::app);\n\nvoid my_custom_log(const std::string\u0026 message) \n{\n    std::lock_guard\u003cstd::mutex\u003e lock(logMutex);\n    std::cout \u003c\u003c \"[Custom] \" \u003c\u003c message \u003c\u003c std::endl;\n    logFile \u003c\u003c \"[Custom] \" \u003c\u003c message \u003c\u003c std::endl;\n}\n\nvoid my_custom_flush()\n{\n    std::lock_guard\u003cstd::mutex\u003e lock(logMutex);\n    logFile.flush();\n}\n\n#undef ssLOG_BASE\n#define ssLOG_BASE(message) \\\n    do { \\\n        std::stringstream ss; \\\n        ss \u003c\u003c message; \\\n        my_custom_log(ss.str()); \\\n    } while(0)\n\n#undef ssLOG_FLUSH\n#define ssLOG_FLUSH() my_custom_flush()\n```\n\n--\u003e\n\n### Benchmarking\n```cpp\nauto benchmark = ssLOG_BENCH_START(\"Operation\");\n//... code to benchmark ...\nssLOG_BENCH_END(benchmark);\n\n//Benchmarking with different log levels\nauto benchError = ssLOG_BENCH_ERROR(\"Critical Operation\");\n//... code ...\nssLOG_BENCH_END(benchError);\n```\n\n### Content Logging\n```cpp\nssLOG_CONTENT( ProcessData(userID, username, password) );\n\n//Content logging with different log levels\nssLOG_CONTENT_WARNING( RiskyOperation() );\n```\n\n### Log Flush\nFlushes the output buffer to the console or file.\n```cpp\nssLOG_FLUSH();\n```\n\n### Log Prepending\nPrepends additional message to the log\n```cpp\nssLOG_PREPEND(\"My prepend message\");\nssLOG_LINE(\"Test\"); //\"My prepend message\" will be prepended for current thread\n\nssLOG_PREPEND_RESET();\nssLOG_LINE(\"Test\"); //Normal log message\n```\n\n### Precise Function Exit Log\nUsing `ssLOG_FUNC_ENTRY` and `ssLOG_FUNC_EXIT` will give you the line number of the exit log.\n\n```cpp\nvoid ProcessTransaction(int amount) \n{\n    ssLOG_FUNC_ENTRY();\n    ssLOG_LINE(\"Processing amount: \" \u003c\u003c amount);\n    \n    if(amount \u003c= 0)\n    {\n        ssLOG_ERROR(\"Invalid amount\");\n        ssLOG_FUNC_EXIT();\n        return;\n    }\n    \n    //...processing...\n    ssLOG_FUNC_EXIT();\n}\n```\n\n## 📚 Configuration Details\n\n| Define Macro Name | Default | Description |\n|-------------------|---------|-------------|\n| ssLOG_CALL_STACK | 1 | Show call stack for logged functions |\n| ssLOG_LOG_WITH_ASCII | 0 | Use ASCII-only characters |\n| ssLOG_SHOW_FILE_NAME | 1 | Show file name (⚠️ contains full path) |\n| ssLOG_SHOW_LINE_NUM | 1 | Show line numbers |\n| ssLOG_SHOW_FUNC_NAME | 1 | Show function names |\n| ssLOG_SHOW_DATE | 0 | Show log date |\n| ssLOG_SHOW_TIME | 1 | Show log time |\n| ssLOG_THREAD_SAFE_OUTPUT | 1 | Enable thread-safe output |\n| ssLOG_SHOW_THREADS | 1 | Show thread IDs |\n| ssLOG_MODE | 0 | Log mode for ssLogger (0: CONSOLE, 1: FILE, 2: CONSOLE_AND_FILE) |\n| ssLOG_USE_ESCAPE_SEQUENCES | 0 | Force use of escape sequences |\n| ssLOG_PREPEND_LOC | 0 | Where to insert preprend (0: BEFORE_FUNC_NAME, 1: BEFORE_FILE_NAME, 2: BEFORE_MESSAGE) |\n| ssLOG_LEVEL | 3 | Compile-time log level (0:NONE, 1:FATAL, 2:ERROR, 3:WARNING, 4:INFO, 5:DEBUG) |\n| ssLOG_USE_WINDOWS_COLOR | 0 | Force use of Windows color codes |\n| ssLOG_THREAD_VSPACE | 4 | Vertical space between individual threads outputs |\n| ssLOG_IMMEDIATE_FLUSH | 0 | Flush the log output immediately for each log (⚠️ may affect performance) |\n| ssLOG_CALL_STACK_ONLY | 0 | Only show function call stack logs, other logs will be ignored |\n\n## 🤝 Credits\nPowered by [termcolor](https://github.com/ikalnytskyi/termcolor) ([license](./External/termcolor%20LICENSE))\n\n## 🔜 TODOs:\n- Add script for running tests in different configurations\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fsslogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneko-box-coder%2Fsslogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fsslogger/lists"}