mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweaks
This commit is contained in:
parent
902e734e62
commit
f20170406e
@ -277,19 +277,19 @@ void Log(int nLevel, const WCHAR* message)
|
||||
|
||||
void LogWithArgs(int nLevel, const WCHAR* format, ...)
|
||||
{
|
||||
WCHAR* buffer = new WCHAR[4096];
|
||||
WCHAR* buffer = new WCHAR[1024];
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
va_start(args, format);
|
||||
|
||||
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
|
||||
_CrtSetReportMode(_CRT_ASSERT, 0);
|
||||
|
||||
errno = 0;
|
||||
_vsnwprintf_s(buffer, 4096, _TRUNCATE, format, args);
|
||||
_vsnwprintf_s(buffer, 1024, _TRUNCATE, format, args);
|
||||
if (errno != 0)
|
||||
{
|
||||
nLevel = LOG_ERROR;
|
||||
_snwprintf_s(buffer, 4096, _TRUNCATE, L"LogWithArgs internal error: %s", format);
|
||||
_snwprintf_s(buffer, 1024, _TRUNCATE, L"Internal error: %s", format);
|
||||
}
|
||||
|
||||
_set_invalid_parameter_handler(oldHandler);
|
||||
|
@ -254,7 +254,7 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
|
||||
if (re == NULL)
|
||||
{
|
||||
MakePlainSubstitute(str, i);
|
||||
Log(LOG_NOTICE, ConvertToWide(error).c_str());
|
||||
LogWithArgs(LOG_NOTICE, L"%S", error);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -205,37 +205,34 @@ void CMeasureNet::UpdateIFTable()
|
||||
|
||||
for (size_t i = 0; i < c_NumOfTables; ++i)
|
||||
{
|
||||
std::string desc((char*)ifTable->table[i].bDescr, ifTable->table[i].dwDescrLen);
|
||||
|
||||
std::wstring type;
|
||||
const WCHAR* type = L"";
|
||||
switch (ifTable->table[i].dwType)
|
||||
{
|
||||
case IF_TYPE_ETHERNET_CSMACD:
|
||||
type += L"Ethernet";
|
||||
type = L"Ethernet";
|
||||
break;
|
||||
case IF_TYPE_PPP:
|
||||
type += L"PPP";
|
||||
type = L"PPP";
|
||||
break;
|
||||
case IF_TYPE_SOFTWARE_LOOPBACK:
|
||||
type += L"Loopback";
|
||||
type = L"Loopback";
|
||||
break;
|
||||
case IF_TYPE_IEEE80211:
|
||||
type += L"IEEE802.11";
|
||||
type = L"IEEE802.11";
|
||||
break;
|
||||
case IF_TYPE_TUNNEL:
|
||||
type += L"Tunnel";
|
||||
type = L"Tunnel";
|
||||
break;
|
||||
case IF_TYPE_IEEE1394:
|
||||
type += L"IEEE1394";
|
||||
type = L"IEEE1394";
|
||||
break;
|
||||
default:
|
||||
type += L"Other";
|
||||
type = L"Other";
|
||||
break;
|
||||
}
|
||||
|
||||
LogWithArgs(LOG_DEBUG, L"%i: %s", (int)i + 1, ConvertToWide(desc.c_str()).c_str());
|
||||
LogWithArgs(LOG_DEBUG, L" Type=%s(%i)",
|
||||
type.c_str(), ifTable->table[i].dwType);
|
||||
LogWithArgs(LOG_DEBUG, L"%i: %.*S", (int)i + 1, ifTable->table[i].dwDescrLen, (char*)ifTable->table[i].bDescr);
|
||||
LogWithArgs(LOG_DEBUG, L" Type=%s(%i)", type, ifTable->table[i].dwType);
|
||||
}
|
||||
Log(LOG_DEBUG, L"------------------------------");
|
||||
}
|
||||
|
@ -76,21 +76,22 @@ void LuaManager::Finalize()
|
||||
|
||||
void LuaManager::ReportErrors(lua_State* L)
|
||||
{
|
||||
std::string error = lua_tostring(L, -1);
|
||||
const char* error = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
const char* pos = error + 4; // Skip the drive
|
||||
|
||||
// Get rid of everything up to the filename
|
||||
std::string::size_type pos = 4; // Skip the drive
|
||||
pos = error.find_first_of(':', pos);
|
||||
pos = error.find_last_of('\\', pos);
|
||||
if (pos != std::string::npos)
|
||||
while (*pos != ':')
|
||||
{
|
||||
error.erase(0, ++pos);
|
||||
if (*pos == '\\')
|
||||
{
|
||||
error = pos + 1;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
|
||||
std::wstring str = L"Script: ";
|
||||
str += ConvertToWide(error.c_str());
|
||||
Log(LOG_ERROR, str.c_str());
|
||||
LogWithArgs(LOG_ERROR, L"Script: %S", error);
|
||||
}
|
||||
|
||||
void LuaManager::PushWide(lua_State* L, const WCHAR* str)
|
||||
|
Loading…
Reference in New Issue
Block a user