spdlog

# Integrating with spdlog

If you want to make your bot use spdlog, like aegis does, you can attach it to the `on_log` event. You can do this as follows:

    #include<spdlog/spdlog.h>
    #include<spdlog/async.h>
    #include<spdlog/sinks/stdout_color_sinks.h>
    #include<spdlog/sinks/rotating_file_sink.h>
    #include<iomanip>
    #include<dpp/dpp.h>
    #include<fmt/format.h>

    intmain(intargc,charconst*argv[]){
    dpp::clusterbot("token");

    conststd::stringlog_name="mybot.log";

    /*Setupspdloglogger*/
    std::shared_ptr<spdlog::logger>log;
    spdlog::init_thread_pool(8192,2);
    std::vector<spdlog::sink_ptr>sinks;
    autostdout_sink=std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
    autorotating=std::make_shared<spdlog::sinks::rotating_file_sink_mt>(log_name,1024*1024*5,10);
    sinks.push_back(stdout_sink);
    sinks.push_back(rotating);
    log=std::make_shared<spdlog::async_logger>("logs",sinks.begin(),sinks.end(),spdlog::thread_pool(),spdlog::async_overflow_policy::block);
    spdlog::register_logger(log);
    log->set_pattern("%^%Y-%m-%d%H:%M:%S.%e[%L][th#%t]%$:%v");
    log->set_level(spdlog::level::level_enum::debug);

    /*IntegratespdlogloggertoD++logevents*/
    bot.on_log([&bot,&log](constdpp::log_t&event){
    switch(event.severity){
    casedpp::ll_trace:
    log->trace("{}",event.message);
    break;
    casedpp::ll_debug:
    log->debug("{}",event.message);
    break;
    casedpp::ll_info:
    log->info("{}",event.message);
    break;
    casedpp::ll_warning:
    log->warn("{}",event.message);
    break;
    casedpp::ll_error:
    log->error("{}",event.message);
    break;
    casedpp::ll_critical:
    default:
    log->critical("{}",event.message);
    break;
    }
    });

    /*Addtherestofyourevents*/

    bot.start(dpp::st_wait);
    return0;
    }