Skip to content

Commit

Permalink
Mege OEM
Browse files Browse the repository at this point in the history
  • Loading branch information
n506 committed Nov 30, 2015
2 parents 2c4f85c + 490add3 commit 381e4f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
17 changes: 13 additions & 4 deletions log4z.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <shlwapi.h>
#include <process.h>
#pragma comment(lib, "shlwapi")
#pragma comment(lib, "User32.lib")
#pragma warning(disable:4996)

#else
Expand Down Expand Up @@ -1161,15 +1162,24 @@ LogerManager::~LogerManager()

void LogerManager::showColorText(const char *text, int level)
{

#ifdef WIN32
char oem[LOG4Z_LOG_BUF_SIZE] = { 0 };
CharToOemBuffA(text, oem, LOG4Z_LOG_BUF_SIZE);
#endif

if (level <= LOG_LEVEL_DEBUG || level > LOG_LEVEL_FATAL)
{
#ifdef WIN32
printf("%s", oem);
#else
printf("%s", text);
#endif
return;
}
#ifndef WIN32
printf("%s%s\e[0m", LOG_COLOR[level], text);
#else

AutoLock l(_scLock);
HANDLE hStd = ::GetStdHandle(STD_OUTPUT_HANDLE);
if (hStd == INVALID_HANDLE_VALUE) return;
Expand All @@ -1178,10 +1188,10 @@ void LogerManager::showColorText(const char *text, int level)
{
return;
}
else
else
{
SetConsoleTextAttribute(hStd, LOG_COLOR[level]);
printf("%s", text);
printf("%s", oem);
SetConsoleTextAttribute(hStd, oldInfo.wAttributes);
}
#endif
Expand Down Expand Up @@ -1876,4 +1886,3 @@ ILog4zManager * ILog4zManager::getInstance()

_ZSUMMER_LOG4Z_END
_ZSUMMER_END

13 changes: 0 additions & 13 deletions log4z.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,10 @@ const bool LOG4Z_DEFAULT_MONTHDIR = false;
const int LOG4Z_DEFAULT_LIMITSIZE = 100;
//! default logger show suffix (file name and line number)
const bool LOG4Z_DEFAULT_SHOWSUFFIX = true;

///////////////////////////////////////////////////////////////////////////
//! -----------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////





#ifndef _ZSUMMER_BEGIN
#define _ZSUMMER_BEGIN namespace zsummer {
#endif
Expand All @@ -262,9 +257,6 @@ const bool LOG4Z_DEFAULT_SHOWSUFFIX = true;
_ZSUMMER_BEGIN
_ZSUMMER_LOG4Z_BEGIN




//! log4z class
class ILog4zManager
{
Expand Down Expand Up @@ -641,8 +633,3 @@ _ZSUMMER_LOG4Z_END
_ZSUMMER_END

#endif





1 change: 1 addition & 0 deletions test/fast_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ int main(int argc, char *argv[])
// sorry guys, this test is in russian
LOGI("const char[]: ANSI->OEM test, Ýòà ñòðîêà äîëæíà áûòü ÷èòàåìà â ëîãôàéëå (1251) è â êîíñîëè (866)");
LOGI("Stream: " << "ANSI->OEM test, Ýòà ñòðîêà äîëæíà áûòü ÷èòàåìà â ëîãôàéëå (1251) è â êîíñîëè (866)");
LOGT("Stream: " << "ANSI->OEM test, Ýòà ñòðîêà äîëæíà áûòü ÷èòàåìà â ëîãôàéëå (1251) è â êîíñîëè (866)");

//begin test wstring(utf-16) log string input....
WCHAR checkWCHAR[100] = L"ANSI->OEM test, Ýòà ñòðîêà äîëæíà áûòü ÷èòàåìà â ëîãôàéëå (1251)";
Expand Down

0 comments on commit 381e4f1

Please sign in to comment.