Last active
July 8, 2017 02:29
-
-
Save MikeLing/d146ca104903d2257446a4ee236edd50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "spdlog/spdlog.h" | |
class SGIO | |
{ | |
public: | |
SGIO | |
{ | |
... | |
} | |
#ifdef HAVESPDLOG | |
void set_target_to_file(string filename) | |
{ | |
shogun_log = spdlog::rotating_logger_mt("shogunFileLog"); | |
} | |
void set_target_to_stdout() | |
{ | |
shogun_log = spdlog::stdout_color_mt("shogunlog"); | |
} | |
void set_target_to_stderr() | |
{ | |
shogun_log = spdlog::stderr_color_mt("shogunErrorLog"); | |
} | |
#endif | |
#ifdef HAVESPDLOG | |
public: | |
... | |
std::shared_ptr<spdlog::logger> shogun_log; | |
... | |
#endif | |
} | |
void SGIO::message(EMessageType prio, const char* function, const char* file, | |
int32_t line, const char *fmt, ... ) const | |
{ | |
... | |
switch (prio) | |
{ | |
case MSG_GCDEBUG: | |
case MSG_DEBUG: | |
shogun_log->debug(str); | |
break; | |
case MSG_INFO: | |
shogun_log->info(str); | |
break; | |
case MSG_NOTICE: | |
case MSG_MESSAGEONLY: | |
shogun_log->info(str); | |
break; | |
case MSG_WARN: | |
if (sg_print_warning) | |
shogun_log->warn(str); | |
break; | |
case MSG_ERROR: | |
shogun_log->error(str); | |
break; | |
case MSG_CRITICAL: | |
shogun_log->critical(str); | |
break; | |
case MSG_ALERT: | |
case MSG_EMERGENCY: | |
if (sg_print_error) | |
shogun_log->error(str); | |
throw ShogunException(str); | |
break; | |
default: | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment