diff --git a/kraken/KRContext.cpp b/kraken/KRContext.cpp index 075da6a..6097be0 100755 --- a/kraken/KRContext.cpp +++ b/kraken/KRContext.cpp @@ -169,16 +169,32 @@ void KRContext::Log(log_level level, const std::string message_format, ...) va_list args; va_start(args, message_format); + const int LOG_BUFFER_SIZE = 32768; + char log_buffer[LOG_BUFFER_SIZE]; + vsnprintf(log_buffer, LOG_BUFFER_SIZE, message_format.c_str(), args); + if (s_log_callback) { - const int LOG_BUFFER_SIZE = 32768; - char log_buffer[LOG_BUFFER_SIZE]; - vsnprintf(log_buffer, LOG_BUFFER_SIZE, message_format.c_str(), args); + s_log_callback(s_log_callback_user_data, std::string(log_buffer), level); } else { +#if defined(_WIN32) || defined(_WIN64) + if (level == LOG_LEVEL_INFORMATION) { + OutputDebugStringA("Kraken - INFO: "); + } else { + OutputDebugStringA("Kraken - ERROR: "); + } + OutputDebugStringA(log_buffer); + OutputDebugStringA("\n"); +#else FILE* out_file = level == LOG_LEVEL_INFORMATION ? stdout : stderr; - fprintf(out_file, "Kraken - INFO: "); - vfprintf(out_file, message_format.c_str(), args); + if (level == LOG_LEVEL_INFORMATION) { + fprintf(out_file, "Kraken - INFO: "); + } else { + fprintf(out_file, "Kraken - ERROR: "); + } + fprintf(out_file, log_buffer); fprintf(out_file, "\n"); +#endif } va_end(args);