various fixes for Windows

JSON-105
Claudio Luck 5 years ago
parent 65f1bcbd37
commit aef8508347

@ -10,7 +10,7 @@
#include <thread>
#include <sstream>
#include <vector>
#include <sys/time.h>
#include <alloca>
#ifdef LOGGER_ENABLE_SYSLOG
extern "C" {
@ -216,7 +216,7 @@ std::string Logger::gmtime(time_t t)
// Win32 does not have gmtime_r(), but its gmtime() returns ptr to thread-local struct tm. :-)
#ifdef _WIN32
std::tm* T = gmtime(&t);
std::tm* T = ::gmtime(&t);
#else
std::tm myT;
gmtime_r(&t, &myT); // TODO: GNU extension, conform to POSIX.1; works on Linux and MacOS.
@ -316,7 +316,7 @@ void Logger::log(Severity s, const char* format, ...)
{
va_list va;
va_start(va, format);
char buf[ LoggerS::max_line_length + 1];
char *buf = (char*) alloca (sizeof(char) * ( LoggerS::max_line_length + 1 ));
std::vsnprintf(buf, LoggerS::max_line_length, format, va);
va_end(va);
@ -329,7 +329,7 @@ void LogP(Logger::Severity s, Logger::Severity my_loglevel, const std::string& p
{
if(s<=my_loglevel && s<=LoggerS::loglevel)
{
char buf[ LoggerS::max_line_length + 1];
char *buf = (char*) alloca (sizeof(char) * ( LoggerS::max_line_length + 1 ));
std::vsnprintf(buf, LoggerS::max_line_length, format, va);
LoggerS::log(s, prefix + buf );
}

@ -8,7 +8,9 @@
#define LOGGER_MAX_LINE_LENGTH (1000)
// enable logging to syslog
#ifndef _WIN32
#define LOGGER_ENABLE_SYSLOG (1)
#endif
// use ASCII-only characters to tag log lines
// #define LOGGER_USE_ASCII_TAGS (1)

@ -1,5 +1,6 @@
#include "pep-types.hh"
#include "pep-utils.hh"
#include "pep-adapter.hh"
#include "json_spirit/json_spirit_utils.h"
#include <pEp/pEp_string.h>
@ -827,3 +828,6 @@ js::Value Type2String<PEP_STATUS>::get() { return "PEP_STATUS"; }
template<>
js::Value Type2String<Language>::get() { return "Language"; }
template<>
js::Value Type2String<JsonAdapter *>::get() { return "JsonAdapter"; }

Loading…
Cancel
Save