Skip to content

Commit

Permalink
confirm number of created commands, and name spdlog logger threads
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Dec 18, 2024
1 parent 6ddaade commit 699f69e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/listeners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ namespace listeners {
if (cc.is_error()) {
bot.log(dpp::ll_error, cc.http_info.body);
}
auto slashcommands = std::get<dpp::slashcommand_map>(cc.value);
bot.log(dpp::ll_info, "Registered " + std::to_string(slashcommands.size()) + " application commands");
}
);
bot.guild_bulk_command_create({
Expand Down
6 changes: 5 additions & 1 deletion src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <dpp/dpp.h>
#include <atomic>

namespace logger {

Expand All @@ -31,10 +32,13 @@ namespace logger {
constexpr int max_log_size = 1024 * 1024 * 5;

static std::shared_ptr<spdlog::logger> async_logger;
std::atomic_int thread_number = 0;

void init(const std::string& log_file) {
/* Set up spdlog logger */
spdlog::init_thread_pool(8192, 2);
spdlog::init_thread_pool(8192, 2, []{
dpp::utility::set_thread_name("spdlog/logger/" + std::to_string(thread_number++));
});
std::vector<spdlog::sink_ptr> sinks = {
std::make_shared<spdlog::sinks::stdout_color_sink_mt >(),
std::make_shared<spdlog::sinks::rotating_file_sink_mt>(log_file, max_log_size, 10)
Expand Down

0 comments on commit 699f69e

Please sign in to comment.