Make log function easier to be called

This commit is contained in:
Don Ho 2024-10-05 21:47:20 +02:00
parent a3535f385f
commit d2fb03e41c
2 changed files with 11 additions and 5 deletions

View File

@ -143,8 +143,8 @@ void writeLog(const wchar_t *logFileName, const char *log2write)
SYSTEMTIME currentTime = {}; SYSTEMTIME currentTime = {};
::GetLocalTime(&currentTime); ::GetLocalTime(&currentTime);
wstring dateTimeStrW = getDateTimeStrFrom(L"yyyy-MM-dd HH:mm:ss", currentTime); wstring dateTimeStrW = getDateTimeStrFrom(L"yyyy-MM-dd HH:mm:ss", currentTime);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string log2writeStr = converter.to_bytes(dateTimeStrW); string log2writeStr = converter.to_bytes(dateTimeStrW);
log2writeStr += " "; log2writeStr += " ";
log2writeStr += log2write; log2writeStr += log2write;
log2writeStr += "\n"; log2writeStr += "\n";
@ -157,6 +157,11 @@ void writeLog(const wchar_t *logFileName, const char *log2write)
} }
} }
void writeLog(const wchar_t* logFileName, const wchar_t* log2write)
{
string log2WriteA = wstring2string(log2write, CP_ACP);
return writeLog(logFileName, log2WriteA.c_str());
}
wstring folderBrowser(HWND parent, const wstring & title, int outputCtrlID, const wchar_t *defaultStr) wstring folderBrowser(HWND parent, const wstring & title, int outputCtrlID, const wchar_t *defaultStr)
{ {

View File

@ -59,6 +59,7 @@ void printStr(const wchar_t *str2print);
std::wstring commafyInt(size_t n); std::wstring commafyInt(size_t n);
void writeLog(const wchar_t* logFileName, const char* log2write); void writeLog(const wchar_t* logFileName, const char* log2write);
void writeLog(const wchar_t* logFileName, const wchar_t* log2write);
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep); int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep);
std::wstring purgeMenuItemString(const wchar_t* menuItemStr, bool keepAmpersand = false); std::wstring purgeMenuItemString(const wchar_t* menuItemStr, bool keepAmpersand = false);
std::vector<std::wstring> tokenizeString(const std::wstring & tokenString, const char delim); std::vector<std::wstring> tokenizeString(const std::wstring & tokenString, const char delim);