cleaned common.h and moved some code around

This commit is contained in:
gabime
2016-05-15 01:45:16 +03:00
parent 10d5292bbb
commit 80a432e646
5 changed files with 31 additions and 33 deletions

View File

@@ -112,7 +112,7 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
return !(tm1 == tm2);
}
// eol at end of each log line
// eol definition
#if !defined (SPDLOG_EOL)
#ifdef _WIN32
#define SPDLOG_EOL "\r\n"
@@ -125,6 +125,7 @@ SPDLOG_CONSTEXPR static const char* eol = SPDLOG_EOL;
SPDLOG_CONSTEXPR static int eol_size = sizeof(SPDLOG_EOL) - 1;
//fopen_s on non windows for writing
inline int fopen_s(FILE** fp, const filename_t& filename, const filename_t& mode)
{
@@ -228,6 +229,23 @@ inline size_t thread_id()
}
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
#define SPDLOG_FILENAME_T(s) L ## s
inline std::string filename_to_str(const filename_t& filename)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> c;
return c.to_bytes(filename);
}
#else
#define SPDLOG_FILENAME_T(s) s
inline std::string filename_to_str(const filename_t& filename)
{
return filename;
}
#endif
} //os
} //details
} //spdlog