You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ki...@apache.org on 2020/09/22 14:19:10 UTC

[trafficserver] branch master updated: Add support for TS API for Note, Status, Warning, Alert (#7208)

This is an automated email from the ASF dual-hosted git repository.

kichan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 3eefadb  Add support for TS API for Note, Status, Warning, Alert (#7208)
3eefadb is described below

commit 3eefadbcae320121abbed485d601d456422aef3c
Author: Kit Chan <ki...@apache.org>
AuthorDate: Tue Sep 22 07:18:54 2020 -0700

    Add support for TS API for Note, Status, Warning, Alert (#7208)
---
 doc/admin-guide/plugins/lua.en.rst | 40 ++++++++++++++++++++++++
 plugins/lua/ts_lua_misc.c          | 64 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)

diff --git a/doc/admin-guide/plugins/lua.en.rst b/doc/admin-guide/plugins/lua.en.rst
index c282da6..e876a73 100644
--- a/doc/admin-guide/plugins/lua.en.rst
+++ b/doc/admin-guide/plugins/lua.en.rst
@@ -299,6 +299,46 @@ Here is an example:
 
 :ref:`TOP <admin-plugins-ts-lua>`
 
+ts.status
+---------
+**syntax:** *ts.status(MESSAGE)*
+
+**context:** global
+
+**description**: Log the MESSAGE to error.log as status
+
+:ref:`TOP <admin-plugins-ts-lua>`
+
+ts.note
+-------
+**syntax:** *ts.note(MESSAGE)*
+
+**context:** global
+
+**description**: Log the MESSAGE to error.log as note
+
+:ref:`TOP <admin-plugins-ts-lua>`
+
+ts.warning
+----------
+**syntax:** *ts.warning(MESSAGE)*
+
+**context:** global
+
+**description**: Log the MESSAGE to error.log as warning
+
+:ref:`TOP <admin-plugins-ts-lua>`
+
+ts.alert
+--------
+**syntax:** *ts.alert(MESSAGE)*
+
+**context:** global
+
+**description**: Log the MESSAGE to error.log as alert
+
+:ref:`TOP <admin-plugins-ts-lua>`
+
 TS Basic Internal Information
 -----------------------------
 **syntax:** *ts.get_install_dir()*
diff --git a/plugins/lua/ts_lua_misc.c b/plugins/lua/ts_lua_misc.c
index 057ef07..d65ec5e 100644
--- a/plugins/lua/ts_lua_misc.c
+++ b/plugins/lua/ts_lua_misc.c
@@ -26,6 +26,10 @@ static int ts_lua_debug(lua_State *L);
 static int ts_lua_error(lua_State *L);
 static int ts_lua_emergency(lua_State *L);
 static int ts_lua_fatal(lua_State *L);
+static int ts_lua_status(lua_State *L);
+static int ts_lua_note(lua_State *L);
+static int ts_lua_warning(lua_State *L);
+static int ts_lua_alert(lua_State *L);
 static int ts_lua_sleep(lua_State *L);
 static int ts_lua_host_lookup(lua_State *L);
 static int ts_lua_schedule(lua_State *L);
@@ -74,6 +78,22 @@ ts_lua_inject_misc_api(lua_State *L)
   lua_pushcfunction(L, ts_lua_fatal);
   lua_setfield(L, -2, "fatal");
 
+  /* ts.status(...) */
+  lua_pushcfunction(L, ts_lua_status);
+  lua_setfield(L, -2, "status");
+
+  /* ts.note(...) */
+  lua_pushcfunction(L, ts_lua_note);
+  lua_setfield(L, -2, "note");
+
+  /* ts.warning(...) */
+  lua_pushcfunction(L, ts_lua_warning);
+  lua_setfield(L, -2, "warning");
+
+  /* ts.alert(...) */
+  lua_pushcfunction(L, ts_lua_alert);
+  lua_setfield(L, -2, "alert");
+
   /* ts.sleep(...) */
   lua_pushcfunction(L, ts_lua_sleep);
   lua_setfield(L, -2, "sleep");
@@ -196,6 +216,50 @@ ts_lua_fatal(lua_State *L)
 }
 
 static int
+ts_lua_status(lua_State *L)
+{
+  const char *msg;
+  size_t len = 0;
+
+  msg = luaL_checklstring(L, 1, &len);
+  TSStatus("%.*s", (int)len, msg);
+  return 0;
+}
+
+static int
+ts_lua_note(lua_State *L)
+{
+  const char *msg;
+  size_t len = 0;
+
+  msg = luaL_checklstring(L, 1, &len);
+  TSNote("%.*s", (int)len, msg);
+  return 0;
+}
+
+static int
+ts_lua_warning(lua_State *L)
+{
+  const char *msg;
+  size_t len = 0;
+
+  msg = luaL_checklstring(L, 1, &len);
+  TSWarning("%.*s", (int)len, msg);
+  return 0;
+}
+
+static int
+ts_lua_alert(lua_State *L)
+{
+  const char *msg;
+  size_t len = 0;
+
+  msg = luaL_checklstring(L, 1, &len);
+  TSAlert("%.*s", (int)len, msg);
+  return 0;
+}
+
+static int
 ts_lua_schedule(lua_State *L)
 {
   int sec;