From a2f07f66a5a42553adf1021970bd5c20849df13e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 18 Apr 2020 18:13:14 +0200 Subject: Consistent Lua script error and print() output 1/2 --- libs/ardour/luaproc.cc | 14 ++++++++++---- libs/ardour/luascripting.cc | 12 ++++++++++-- libs/ardour/session.cc | 9 ++++----- libs/ardour/session_state.cc | 3 +++ 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc index 73208a1eb8..c5ead88834 100644 --- a/libs/ardour/luaproc.cc +++ b/libs/ardour/luaproc.cc @@ -192,8 +192,10 @@ LuaProc::route () const void LuaProc::lua_print (std::string s) { - std::cout <<"LuaProc: " << s << "\n"; - PBD::error << "LuaProc: " << s << "\n"; +#ifndef NDEBUG + std::cout << "LuaProc: " << s << "\n"; +#endif + PBD::info << "LuaProc: " << s << "\n"; } bool @@ -258,6 +260,10 @@ LuaProc::load_script () try { lua_dsp_init (_session.nominal_sample_rate ()); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG + std::cerr << "LuaException:" << e.what () << std::endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; return true; // error } catch (...) { return true; @@ -605,10 +611,10 @@ LuaProc::configure_io (ChanCount in, ChanCount out) } _configured = true; } catch (luabridge::LuaException const& e) { - PBD::error << "LuaException: " << e.what () << "\n"; #ifndef NDEBUG std::cerr << "LuaException: " << e.what () << "\n"; #endif + PBD::warning << "LuaException: " << e.what () << "\n"; return false; } catch (...) { return false; @@ -756,10 +762,10 @@ LuaProc::connect_and_run (BufferSet& bufs, } } catch (luabridge::LuaException const& e) { - PBD::error << "LuaException: " << e.what () << "\n"; #ifndef NDEBUG std::cerr << "LuaException: " << e.what () << "\n"; #endif + PBD::warning << "LuaException: " << e.what () << "\n"; return -1; } catch (...) { return -1; diff --git a/libs/ardour/luascripting.cc b/libs/ardour/luascripting.cc index 156c9bbe66..bf26074011 100644 --- a/libs/ardour/luascripting.cc +++ b/libs/ardour/luascripting.cc @@ -220,12 +220,20 @@ LuaScripting::scan_script (const std::string &fn, const std::string &sc) #endif return LuaScriptInfoPtr(); } - } catch (...) { // luabridge::LuaException + } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG + cerr << "Exception: Failed to parse lua script fn: '"<< fn << "' " << e.what () << "\n"; +#endif + PBD::warning << "Exception: Failed to parse lua script fn: '"<< fn << "' " << e.what () << "\n"; + return LuaScriptInfoPtr(); + } catch (...) { #ifndef NDEBUG - cerr << "failed to parse lua script\n"; + cerr << "Exception: Failed to parse lua script fn: '"<< fn << "'\n"; #endif + PBD::warning << "Exception: Failed to parse lua script fn: '"<< fn << "'\n"; return LuaScriptInfoPtr(); } + luabridge::LuaRef nfo = luabridge::getGlobal (L, "ardourluainfo"); if (nfo.type() != LUA_TTABLE) { #ifndef NDEBUG diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 900cd90372..0c73acdaa5 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -5103,11 +5103,12 @@ Session::registered_lua_functions () return rv; } -#ifndef NDEBUG static void _lua_print (std::string s) { - std::cout << "SessionLua: " << s << "\n"; -} +#ifndef NDEBUG + std::cout << "LuaSession: " << s << "\n"; #endif + PBD::info << "LuaSession: " << s << endmsg; +} void Session::try_run_lua (pframes_t nframes) @@ -5123,9 +5124,7 @@ Session::try_run_lua (pframes_t nframes) void Session::setup_lua () { -#ifndef NDEBUG lua.Print.connect (&_lua_print); -#endif lua.sandbox (true); lua.do_command ( "function ArdourSession ()" diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 9b3b67c285..8b32648123 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1782,7 +1782,10 @@ Session::set_state (const XMLNode& node, int version) Glib::Threads::Mutex::Lock lm (lua_lock); (*_lua_load)(std::string ((const char*)buf, size)); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + warning << "LuaException: " << e.what () << endmsg; } catch (...) { } g_free (buf); } -- cgit v1.2.3