From 18e95de8f1fb5f5d756d3bf4db168ad96cd5f954 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 29 Apr 2019 14:52:25 +0100 Subject: [Minor] Improve lua logging escaping --- src/lua/lua_common.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/lua/lua_common.h') diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index d9bbff585..5ff5cc8bf 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -365,6 +365,16 @@ struct lua_logger_trace { gconstpointer traces[TRACE_POINTS]; }; +enum lua_logger_escape_type { + LUA_ESCAPE_NONE = (0u), + LUA_ESCAPE_UNPRINTABLE = (1u << 0u), + LUA_ESCAPE_NEWLINES = (1u << 1u), + LUA_ESCAPE_8BIT = (1u << 2u), +}; + +#define LUA_ESCAPE_LOG (LUA_ESCAPE_UNPRINTABLE|LUA_ESCAPE_NEWLINES) +#define LUA_ESCAPE_ALL (LUA_ESCAPE_UNPRINTABLE|LUA_ESCAPE_NEWLINES|LUA_ESCAPE_8BIT) + /** * Log lua object to string * @param L @@ -374,7 +384,8 @@ struct lua_logger_trace { * @return */ gsize lua_logger_out_type (lua_State *L, gint pos, gchar *outbuf, - gsize len, struct lua_logger_trace *trace); + gsize len, struct lua_logger_trace *trace, + enum lua_logger_escape_type esc_type); /** * Safely checks userdata to match specified class -- cgit v1.2.3