data from linux kernel drivers.
--
-//=== Major API Changes
+=== Major API Changes
+* Lua: the various logging functions (debug, info, message, warn and critical)
+ have been removed. Use the print function instead for debugging purposes.
== Getting Wireshark
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()
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)
--
-- 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
#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;
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) {
["wrap"] = '<function 378>',
["yield"] = '<function 379>'
},
- ["critical"] = '<function 380>',
["datafile_path"] = '<function 33>',
- ["debug"] = '<function 381>',
["deregister_filehandler"] = '<function 382>',
["dofile"] = '<function 383>',
["enable_lua"] = true,
[2] = "H225_OTHERS",
[0] = "H225_RAS"
},
- ["info"] = '<function 392>',
["init_routines"] = {},
["io"] = {
["close"] = '<function 393>',
["tan"] = '<function 433>',
["tanh"] = '<function 434>'
},
- ["message"] = '<function 435>',
["module"] = '<function 436>',
["new_dialog"] = '<function 437>',
["next"] = '<function 438>',
["type"] = '<function 501>',
["typeof"] = '<function 502>',
["unpack"] = '<function 498>',
- ["warn"] = '<function 503>',
["wtap"] = {
["APPLE_IP_OVER_IEEE1394"] = 62,
["ARCNET"] = 8,