spdlog is a fast C++ logging library designed for ease of use and high performance. It is a header-only library, which means you can easily include it in your projects without complicated setup. With support for various logging levels and formats, spdlog makes logging in C++ applications straightforward.
For the latest releases, visit Releases.
To use spdlog, you can download it directly from the Releases section. Look for the latest release and download the necessary files.
You can also clone the repository using Git:
git clone https://github.com/adityatelang74/spdlog.git
After cloning, navigate to the directory and include the header files in your project.
If you are using CMake, you can easily integrate spdlog into your project by adding the following lines to your CMakeLists.txt
:
add_subdirectory(spdlog)
target_link_libraries(your_target PRIVATE spdlog::spdlog)
To start using spdlog, include the header in your source files:
#include "spdlog/spdlog.h"
Here is a simple example of how to log messages:
#include "spdlog/spdlog.h"
int main() {
spdlog::info("Hello, {}!", "world");
return 0;
}
You can use different log levels to categorize your messages:
spdlog::debug("This is a debug message");
spdlog::info("This is an info message");
spdlog::warn("This is a warning message");
spdlog::error("This is an error message");
spdlog::critical("This is a critical message");
You can customize the format of your log messages:
spdlog::set_pattern("%Y-%m-%d %H:%M:%S [%l] %v");
spdlog::info("Custom formatted message");
To log messages to the console, you can use the default logger:
spdlog::info("Logging to console");
To log messages to a file, create a file logger:
auto file_logger = spdlog::basic_logger_mt("file_logger", "logs.txt");
file_logger->info("Logging to a file");
To enable asynchronous logging, you can set up a logger like this:
spdlog::set_async_mode(8192); // Set queue size
auto async_logger = spdlog::stdout_color_mt("async_logger");
async_logger->info("Asynchronous logging enabled");
We welcome contributions to spdlog! If you would like to contribute, please follow these steps:
Please ensure your code follows the existing style and includes tests where applicable.
spdlog is licensed under the MIT License. See the LICENSE file for more details.
For questions or support, feel free to reach out via the issues section on GitHub or contact me directly.
For the latest releases, visit Releases.