diff mbox series

Lua: expose notification functions

Message ID 20200420084047.40228-1-christian.storm@siemens.com
State Accepted
Headers show
Series Lua: expose notification functions | expand

Commit Message

Storm, Christian April 20, 2020, 8:40 a.m. UTC
Expose the notification functions for TRACE, DEBUG, WARN,
INFO, and ERROR as public for other modules to use them.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 corelib/lua_interface.c | 20 ++++++++++----------
 include/lua_util.h      |  7 +++++++
 2 files changed, 17 insertions(+), 10 deletions(-)

Comments

Stefano Babic April 20, 2020, 9:27 a.m. UTC | #1
On 20.04.20 10:40, Christian Storm wrote:
> Expose the notification functions for TRACE, DEBUG, WARN,
> INFO, and ERROR as public for other modules to use them.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/lua_interface.c | 20 ++++++++++----------
>  include/lua_util.h      |  7 +++++++
>  2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
> index 394aef1..219ee41 100644
> --- a/corelib/lua_interface.c
> +++ b/corelib/lua_interface.c
> @@ -711,24 +711,24 @@ static int notify_helper(lua_State *L, LOGLEVEL level)
>  	return 0;
>  }
>  
> -static int l_trace(lua_State *L) {
> +int lua_notify_trace(lua_State *L) {
>  	return notify_helper(L, TRACELEVEL);
>  }
>  
> -static int l_error(lua_State *L) {
> +int lua_notify_error(lua_State *L) {
>  	return notify_helper(L, ERRORLEVEL);
>  }
>  
> -static int l_info(lua_State *L) {
> +int lua_notify_info(lua_State *L) {
>  	return notify_helper(L, INFOLEVEL);
>  }
>  
> -static int l_warn(lua_State *L)
> +int lua_notify_warn(lua_State *L)
>  {
>  	return notify_helper(L, WARNLEVEL);
>  }
>  
> -static int l_debug(lua_State *L)
> +int lua_notify_debug(lua_State *L)
>  {
>  	return notify_helper(L, DEBUGLEVEL);
>  }
> @@ -851,11 +851,11 @@ static int l_progress_update(lua_State *L)
>   */
>  static const luaL_Reg l_swupdate[] = {
>          { "notify", l_notify },
> -        { "error", l_error },
> -        { "trace", l_trace },
> -        { "info", l_info },
> -        { "warn", l_warn },
> -        { "debug", l_debug },
> +        { "error", lua_notify_error },
> +        { "trace", lua_notify_trace },
> +        { "info", lua_notify_info },
> +        { "warn", lua_notify_warn },
> +        { "debug", lua_notify_debug },
>          { "mount", l_mount },
>          { "umount", l_umount },
>          { NULL, NULL }
> diff --git a/include/lua_util.h b/include/lua_util.h
> index ee5e2cf..a38a735 100644
> --- a/include/lua_util.h
> +++ b/include/lua_util.h
> @@ -20,6 +20,13 @@ int run_lua_script(const char *script, const char *function, char *parms);
>  lua_State *lua_parser_init(const char *buf, struct dict *bootenv);
>  int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img);
>  int lua_handlers_init(void);
> +
> +int lua_notify_trace(lua_State *L);
> +int lua_notify_error(lua_State *L);
> +int lua_notify_info(lua_State *L);
> +int lua_notify_warn(lua_State *L);
> +int lua_notify_debug(lua_State *L);
> +
>  #define lua_parser_exit(L) lua_close((lua_State *)L)
>  
>  #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
> 

Acked-by : Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index 394aef1..219ee41 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -711,24 +711,24 @@  static int notify_helper(lua_State *L, LOGLEVEL level)
 	return 0;
 }
 
-static int l_trace(lua_State *L) {
+int lua_notify_trace(lua_State *L) {
 	return notify_helper(L, TRACELEVEL);
 }
 
-static int l_error(lua_State *L) {
+int lua_notify_error(lua_State *L) {
 	return notify_helper(L, ERRORLEVEL);
 }
 
-static int l_info(lua_State *L) {
+int lua_notify_info(lua_State *L) {
 	return notify_helper(L, INFOLEVEL);
 }
 
-static int l_warn(lua_State *L)
+int lua_notify_warn(lua_State *L)
 {
 	return notify_helper(L, WARNLEVEL);
 }
 
-static int l_debug(lua_State *L)
+int lua_notify_debug(lua_State *L)
 {
 	return notify_helper(L, DEBUGLEVEL);
 }
@@ -851,11 +851,11 @@  static int l_progress_update(lua_State *L)
  */
 static const luaL_Reg l_swupdate[] = {
         { "notify", l_notify },
-        { "error", l_error },
-        { "trace", l_trace },
-        { "info", l_info },
-        { "warn", l_warn },
-        { "debug", l_debug },
+        { "error", lua_notify_error },
+        { "trace", lua_notify_trace },
+        { "info", lua_notify_info },
+        { "warn", lua_notify_warn },
+        { "debug", lua_notify_debug },
         { "mount", l_mount },
         { "umount", l_umount },
         { NULL, NULL }
diff --git a/include/lua_util.h b/include/lua_util.h
index ee5e2cf..a38a735 100644
--- a/include/lua_util.h
+++ b/include/lua_util.h
@@ -20,6 +20,13 @@  int run_lua_script(const char *script, const char *function, char *parms);
 lua_State *lua_parser_init(const char *buf, struct dict *bootenv);
 int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img);
 int lua_handlers_init(void);
+
+int lua_notify_trace(lua_State *L);
+int lua_notify_error(lua_State *L);
+int lua_notify_info(lua_State *L);
+int lua_notify_warn(lua_State *L);
+int lua_notify_debug(lua_State *L);
+
 #define lua_parser_exit(L) lua_close((lua_State *)L)
 
 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501