1
0
Fork 0
mirror of https://gitlab.com/niansa/SomeBot.git synced 2025-03-06 20:48:26 +01:00

Improved logging

This commit is contained in:
niansa 2022-11-02 15:42:55 +01:00
parent 1ee46da2b9
commit 7df9b738ff

View file

@ -28,7 +28,6 @@ std::vector<std::function<void (Bot*)>> Bot::on_init,
Bot::Bot(const std::string& token, const std::string& database) : cluster(token), db(database) {
// Set up bot
cluster.on_log(dpp::utility::cout_logger());
cluster.on_slashcommand([this](const dpp::slashcommand_t& event) {
try {
for (const auto& command : commands.chat_commands) {
@ -304,7 +303,7 @@ int main(int argc, char **argv) {
bot.config.modules_mode = Bot::Config::ModulesMode::whitelist;
}
if (config_entry.contains("modules_mode")) {
const std::string& mode = config_entry["modules_mode"];
const std::string& mode = config_entry;
if (mode == "blacklist") {
bot.config.modules_mode = Bot::Config::ModulesMode::blacklist;
} else if (mode == "whitelist") {
@ -332,6 +331,7 @@ int main(int argc, char **argv) {
bot.cluster.on_log([&](const dpp::log_t& event) {
auto t = std::time(nullptr);
logfile << "(" << std::put_time(std::localtime(&t), "%Y-%m-%d %H:%M:%S") << ") [" << dpp::utility::loglevel(event.severity) << "]: " << event.message << std::endl;
std::cout << "(" << std::put_time(std::localtime(&t), "%Y-%m-%d %H:%M:%S") << ") [" << dpp::utility::loglevel(event.severity) << "]: <" << bot.config.id << "> " << event.message << std::endl;
});
bot.config.reregister_commands = argc == 2;
bot.add_property("main_all_instances", &instances, instances_mutex);