mirror of
https://gitlab.com/niansa/SomeBot.git
synced 2025-03-06 20:48:26 +01:00
Improved logging
This commit is contained in:
parent
1ee46da2b9
commit
7df9b738ff
1 changed files with 2 additions and 2 deletions
4
main.cpp
4
main.cpp
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue