diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index 8257dd5b..d2123ab7 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -35,7 +35,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C m_HasGetStringFunction(false), m_ValueType(LUA_TNIL) { - LuaManager::Init(); + LuaManager::Initialize(); } /* @@ -45,7 +45,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C CMeasureScript::~CMeasureScript() { DeleteLuaScript(); - LuaManager::CleanUp(); + LuaManager::Finalize(); } void CMeasureScript::DeleteLuaScript() diff --git a/Library/lua/LuaManager.cpp b/Library/lua/LuaManager.cpp index 2b9adecb..de774718 100644 --- a/Library/lua/LuaManager.cpp +++ b/Library/lua/LuaManager.cpp @@ -23,7 +23,7 @@ int LuaManager::c_RefCount = 0; lua_State* LuaManager::c_State = 0; -void LuaManager::Init() +void LuaManager::Initialize() { if (c_State == NULL) { @@ -51,7 +51,7 @@ void LuaManager::Init() ++c_RefCount; } -void LuaManager::CleanUp() +void LuaManager::Finalize() { if (c_RefCount > 0) { @@ -84,31 +84,6 @@ void LuaManager::ReportErrors(lua_State* L) Log(LOG_ERROR, str.c_str()); } -void LuaManager::LuaLog(int nLevel, const char* format, ... ) -{ - char* buffer = new char[4096]; - va_list args; - va_start( args, format ); - - _invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler); - _CrtSetReportMode(_CRT_ASSERT, 0); - - errno = 0; - _vsnprintf_s( buffer, 4096, _TRUNCATE, format, args ); - if (errno != 0) - { - _snprintf_s(buffer, 4096, _TRUNCATE, "Script: LuaLog internal error: %s", format); - } - - _set_invalid_parameter_handler(oldHandler); - - std::wstring str = ConvertToWide(buffer); - Log(nLevel, str.c_str()); - va_end(args); - - delete [] buffer; -} - void LuaManager::PushWide(lua_State* L, const WCHAR* str) { lua_pushstring(L, ConvertToAscii(str).c_str()); diff --git a/Library/lua/LuaManager.h b/Library/lua/LuaManager.h index 6e1b8bae..50faf7a1 100644 --- a/Library/lua/LuaManager.h +++ b/Library/lua/LuaManager.h @@ -25,13 +25,12 @@ class LuaManager { public: - static void Init(); - static void CleanUp(); + static void Initialize(); + static void Finalize(); static lua_State* GetState() { return c_State; } static void ReportErrors(lua_State* L); - static void LuaLog(int nLevel, const char* format, ... ); static void PushWide(lua_State* L, const WCHAR* str); static std::wstring ToWide(lua_State* L, int narg); diff --git a/Library/lua/glue/LuaGlobal.cpp b/Library/lua/glue/LuaGlobal.cpp index e4ca1130..66e61507 100644 --- a/Library/lua/glue/LuaGlobal.cpp +++ b/Library/lua/glue/LuaGlobal.cpp @@ -53,7 +53,7 @@ static int Global_Log(lua_State* L) lua_pop(L, 1); } - LuaManager::LuaLog(LOG_DEBUG, message.c_str()); + Log(LOG_DEBUG, ConvertToWide(message.c_str()).c_str()); return 0; }