| 140 | |
| 141 | #include "spdlog/async.h" |
| 142 | void async_example() |
| 143 | { |
| 144 | // Default thread pool settings can be modified *before* creating the async logger: |
| 145 | // spdlog::init_thread_pool(32768, 1); // queue with max 32k items 1 backing thread. |
| 146 | auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt"); |
| 147 | // alternatively: |
| 148 | // auto async_file = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger", "logs/async_log.txt"); |
| 149 | |
| 150 | for (int i = 1; i < 101; ++i) |
| 151 | { |
| 152 | async_file->info("Async message #{}", i); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | // Log binary data as hex. |
| 157 | // Many types of std::container<char> types can be used. |