From 2481102c6541df37a773569dd4d67b579f04d819 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 2 Jul 2015 08:52:29 +0000 Subject: MirLua: - removed console - changed logging (via netlib) - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14467 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_script_loader.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'plugins/MirLua/src/mlua_script_loader.cpp') diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index 663ad4cd59..c54c489d8b 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -CLuaScriptLoader::CLuaScriptLoader(lua_State *L, HANDLE hLogger) : L(L), hLogger(hLogger) +CLuaScriptLoader::CLuaScriptLoader(lua_State *L) : L(L) { } @@ -18,20 +18,26 @@ void CLuaScriptLoader::RegisterScriptsFolder(const char *path) lua_pop(L, 1); } -void CLuaScriptLoader::LoadScript(const TCHAR *path, const TCHAR *name) +void CLuaScriptLoader::LoadScript(const TCHAR *path) { + if (luaL_dofile(L, T2Utf(path))) { - ptrT error(mir_utf8decodeT(lua_tostring(L, -1))); - mir_writeLogT(hLogger, _T(" %s:FAIL\n %s\n"), name, error); - printf("%s\n", lua_tostring(L, -1)); + CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1)); + return; } - else mir_writeLogT(hLogger, _T(" %s:OK\n"), name); + + TCHAR buf[4096]; + mir_sntprintf(buf, _T("%s:OK"), path); + CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf); } void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir) { - mir_writeLogT(hLogger, _T("Loading scripts from path %s\n"), scriptDir); + TCHAR buf[4096]; + mir_sntprintf(buf, _T("Loading scripts from %s"), scriptDir); + CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf); + RegisterScriptsFolder(ptrA(mir_utf8encodeT(scriptDir))); TCHAR searchMask[MAX_PATH]; @@ -50,24 +56,21 @@ void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir) mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, fd.cFileName); PathToRelativeT(fullPath, path); if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1)) - LoadScript(fullPath, fd.cFileName); + LoadScript(fullPath); } } while (FindNextFile(hFind, &fd)); FindClose(hFind); } - mir_writeLogT(hLogger, _T("\n"), scriptDir); } -void CLuaScriptLoader::Load(lua_State *L, HANDLE hLogger) +void CLuaScriptLoader::Load(lua_State *L) { TCHAR scriptDir[MAX_PATH]; - CLuaScriptLoader loader(L, hLogger); + CLuaScriptLoader loader(L); FoldersGetCustomPathT(g_hCommonFolderPath, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT)); loader.LoadScripts(scriptDir); FoldersGetCustomPathT(g_hCustomFolderPath, scriptDir, _countof(scriptDir), VARST(CUSTOM_SCRIPTS_PATHT)); loader.LoadScripts(scriptDir); - - mir_writeLogT(hLogger, _T("\n"), scriptDir); } \ No newline at end of file -- cgit v1.2.3