From f84128a1886b1154beff66cf13314bdfc412bed0 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 22 Jun 2015 14:50:15 +0000 Subject: MirLua: added logging to scripts loader git-svn-id: http://svn.miranda-ng.org/main/trunk@14329 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua.cpp | 7 ++++--- plugins/MirLua/src/mlua_script_loader.cpp | 5 +++++ plugins/MirLua/src/mlua_script_loader.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index c90d120006..c73d259cf9 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -2,12 +2,16 @@ CMLua::CMLua() : L(NULL) { + console = new CMLuaConsole(L); + Load(); } CMLua::~CMLua() { Unload(); + + delete console; } void CMLua::Load() @@ -25,15 +29,12 @@ void CMLua::Load() MUUID muidLast = MIID_LAST; hScriptsLangpack = GetPluginLangId(muidLast, 0); - console = new CMLuaConsole(L); - CLuaModuleLoader::Load(L); CLuaScriptLoader::Load(L); } void CMLua::Unload() { - delete console; if (L) lua_close(L); KillModuleMenus(hScriptsLangpack); diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index 4ea6c73f80..dc64e2215a 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -2,6 +2,7 @@ CLuaScriptLoader::CLuaScriptLoader(lua_State *L) : L(L) { + hLogger = mir_createLog(MODULE, _T("MirLua script loader log"), VARST(_T("%miranda_logpath%\\MirLua.txt")), 0); } void CLuaScriptLoader::RegisterScriptsFolder(const char *path) @@ -18,7 +19,11 @@ void CLuaScriptLoader::RegisterScriptsFolder(const char *path) void CLuaScriptLoader::LoadScript(const char *path) { if (luaL_dofile(L, path)) + { + const char *error = lua_tostring(L, -1); + mir_writeLogT(hLogger, _T("%s"), ptrT(mir_utf8decodeT(error))); printf("%s\n", lua_tostring(L, -1)); + } } void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir) diff --git a/plugins/MirLua/src/mlua_script_loader.h b/plugins/MirLua/src/mlua_script_loader.h index 0d62e86ffc..c2f64a36b8 100644 --- a/plugins/MirLua/src/mlua_script_loader.h +++ b/plugins/MirLua/src/mlua_script_loader.h @@ -5,6 +5,7 @@ class CLuaScriptLoader { private: lua_State *L; + HANDLE hLogger; CLuaScriptLoader(lua_State *L); -- cgit v1.2.3