aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-09-06 16:24:24 +0200
committerAnders Broman <a.broman58@gmail.com>2018-09-07 04:02:45 +0000
commit6fa2ad4922ce296a26bdd9f54622a491209ec3cd (patch)
treeca68acf47a7656cd5735d724385863a0ad980440 /epan/wslua
parentd703310749312b0b822af0cb5ab3947dc5a53696 (diff)
Lua: remove various logging functions (debug, warn, etc.)
The "debug" logging function overwrites the "debug" package which breaks luacov: https://github.com/keplerproject/luacov/issues/55 Change-Id: I9b6025c060733198bfff8ea959444c09d6e08709 Reviewed-on: https://code.wireshark.org/review/29449 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/wslua')
-rw-r--r--epan/wslua/console.lua31
-rw-r--r--epan/wslua/template-init.lua8
-rw-r--r--epan/wslua/wslua.h1
-rw-r--r--epan/wslua/wslua_util.c54
4 files changed, 13 insertions, 81 deletions
diff --git a/epan/wslua/console.lua b/epan/wslua/console.lua
index 023016e51c..2af50d3587 100644
--- a/epan/wslua/console.lua
+++ b/epan/wslua/console.lua
@@ -57,34 +57,29 @@ if (gui_enabled()) then
local w = TextWindow.new("Console")
-- save original logger functions
- local orig = {
- critical = critical,
- warn = warn,
- message = message,
- info = info,
- debug = debug
- }
+ local orig_print = print
-- define new logger functions that append text to the window
- function critical(x) w:append( date() .. " CRITICAL: " .. tostring(x) .. "\n") end
- function warn(x) w:append( date() .. " WARN: " .. tostring(x) .. "\n") end
- function message(x) w:append( date() .. " MESSAGE: " .. tostring(x) .. "\n") end
- function info(x) w:append( date() .. " INFO: " .. tostring(x) .. "\n") end
- function debug(x) w:append( date() .. " DEBUG: " .. tostring(x) .. "\n") end
+ function print(...)
+ local arg = {...}
+ local n = #arg
+ w:append(date() .. " ")
+ for i=1, n do
+ if i > 1 then w:append("\t") end
+ w:append(tostring(arg[i]))
+ end
+ w:append("\n")
+ end
-- when the window gets closed restore the original logger functions
local function at_close()
- critical = orig.critical
- warn = orig.warn
- message = orig.message
- info = orig.info
- debug = orig.debug
+ print = old_print
console_open = false
end
w:set_atclose(at_close)
- info("Console opened")
+ print("Console opened")
end
function ref_manual()
diff --git a/epan/wslua/template-init.lua b/epan/wslua/template-init.lua
index 9be7050fed..a06f62265e 100644
--- a/epan/wslua/template-init.lua
+++ b/epan/wslua/template-init.lua
@@ -38,13 +38,6 @@ if running_superuser then
file = disabled_lib
end
--- to avoid output to stdout which can cause problems lua's print ()
--- has been suppresed so that it yields an error.
--- have print() call info() instead.
-if gui_enabled() then
- print = info
-end
-
function typeof(obj)
local mt = getmetatable(obj)
return mt and mt.__typeof or obj.__typeof or type(obj)
@@ -74,7 +67,6 @@ end
--
-- since 1.11.3
function package.prepend_path(name)
- local debug = require "debug"
-- get the function calling this package.prepend_path function
local dt = debug.getinfo(2, "f")
if not dt then
diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h
index 3c12ce283c..b0373f2497 100644
--- a/epan/wslua/wslua.h
+++ b/epan/wslua/wslua.h
@@ -53,7 +53,6 @@
#define WSLUA_INIT_ROUTINES "init_routines"
#define WSLUA_PREFS_CHANGED "prefs_changed"
-#define LOG_DOMAIN_LUA "wslua"
typedef void (*wslua_logger_t)(const gchar *, GLogLevelFlags, const gchar *, gpointer);
extern wslua_logger_t wslua_logger;
diff --git a/epan/wslua/wslua_util.c b/epan/wslua/wslua_util.c
index bd706071d7..9d37efd949 100644
--- a/epan/wslua/wslua_util.c
+++ b/epan/wslua/wslua_util.c
@@ -129,60 +129,6 @@ WSLUA_FUNCTION wslua_report_failure(lua_State* LS) { /* Reports a failure to the
return 0;
}
-static int wslua_log(lua_State* L, GLogLevelFlags log_level) {
- GString* str = g_string_new("");
- int n = lua_gettop(L); /* Number of arguments */
- int i;
-
- lua_getglobal(L, "tostring");
- for (i=1; i<=n; i++) {
- const char *s;
- lua_pushvalue(L, -1); /* function to be called */
- lua_pushvalue(L, i); /* value to print */
- lua_call(L, 1, 1);
- s = lua_tostring(L, -1); /* get result */
- if (s == NULL)
- return luaL_error(L, "`tostring' must return a string");
-
- if (i>1) g_string_append(str,"\t");
- g_string_append(str,s);
-
- lua_pop(L, 1); /* pop result */
- }
- g_string_append_c(str, '\n');
-
- wslua_logger(LOG_DOMAIN_LUA, log_level, str->str, NULL);
- g_string_free(str,TRUE);
-
- return 0;
-}
-
-WSLUA_FUNCTION wslua_critical( lua_State* L ) { /* Will add a log entry with critical severity. */
-/* WSLUA_MOREARGS critical objects to be printed */
- wslua_log(L,G_LOG_LEVEL_CRITICAL);
- return 0;
-}
-WSLUA_FUNCTION wslua_warn( lua_State* L ) { /* Will add a log entry with warn severity. */
-/* WSLUA_MOREARGS warn objects to be printed */
- wslua_log(L,G_LOG_LEVEL_WARNING);
- return 0;
-}
-WSLUA_FUNCTION wslua_message( lua_State* L ) { /* Will add a log entry with message severity. */
-/* WSLUA_MOREARGS message objects to be printed */
- wslua_log(L,G_LOG_LEVEL_MESSAGE);
- return 0;
-}
-WSLUA_FUNCTION wslua_info( lua_State* L ) { /* Will add a log entry with info severity. */
-/* WSLUA_MOREARGS info objects to be printed */
- wslua_log(L,G_LOG_LEVEL_INFO);
- return 0;
-}
-WSLUA_FUNCTION wslua_debug( lua_State* L ) { /* Will add a log entry with debug severity. */
-/* WSLUA_MOREARGS debug objects to be printed */
- wslua_log(L,G_LOG_LEVEL_DEBUG);
- return 0;
-}
-
/* The returned filename is g_malloc()'d so the caller must free it */
/* except when NULL is returned if file doesn't exist */
char* wslua_get_actual_filename(const char* fname) {