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 2017/05/31 00:50:18 UTC

[trafficserver] branch master updated: fix ts.debug

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  96b3320   fix ts.debug
96b3320 is described below

commit 96b3320118c484ec661b11ec1d095e8f11646d4b
Author: scw00 <61...@qq.com>
AuthorDate: Mon Apr 10 14:56:56 2017 +0800

    fix ts.debug
---
 doc/admin-guide/plugins/ts_lua.en.rst     |  9 +++++----
 plugins/experimental/ts_lua/ts_lua_misc.c | 14 +++++++++++---
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/doc/admin-guide/plugins/ts_lua.en.rst b/doc/admin-guide/plugins/ts_lua.en.rst
index 363aa42..7575359 100644
--- a/doc/admin-guide/plugins/ts_lua.en.rst
+++ b/doc/admin-guide/plugins/ts_lua.en.rst
@@ -178,21 +178,22 @@ Here is an example:
 
 ts.debug
 --------
-**syntax:** *ts.debug(MESSAGE)*
+**syntax:** *ts.debug(TAG?, MESSAGE)*
 
 **context:** global
 
-**description**: Log the MESSAGE to traffic.out if debug is enabled.
+**description**: Log the MESSAGE to traffic.out if debug TAG is enabled(the default TAG is **ts_lua**).
 
 Here is an example:
 
 ::
 
        ts.debug('I am in do_remap now.')
+       ts.debug("scw", "hello world")
 
-The debug tag is **ts_lua** and we should write this in records.config:
+We should write this TAG in records.config(If TAG is missing, default TAG will be set):
 
-``CONFIG proxy.config.diags.debug.tags STRING ts_lua``
+``CONFIG proxy.config.diags.debug.tags STRING TAG``
 
 `TOP <#ts-lua-plugin>`_
 
diff --git a/plugins/experimental/ts_lua/ts_lua_misc.c b/plugins/experimental/ts_lua/ts_lua_misc.c
index 6a75239..e7260f4 100644
--- a/plugins/experimental/ts_lua/ts_lua_misc.c
+++ b/plugins/experimental/ts_lua/ts_lua_misc.c
@@ -103,10 +103,18 @@ static int
 ts_lua_debug(lua_State *L)
 {
   const char *msg;
-  size_t len = 0;
+  const char *flag;
+  size_t msg_len = 0, flag_len = 0;
+
+  if (lua_gettop(L) == 2) {
+    msg  = luaL_checklstring(L, 2, &msg_len);
+    flag = luaL_checklstring(L, 1, &flag_len);
+    TSDebug(flag, "%.*s", (int)msg_len, msg);
+  } else {
+    msg = luaL_checklstring(L, 1, &msg_len);
+    TSDebug(TS_LUA_DEBUG_TAG, "%.*s", (int)msg_len, msg);
+  }
 
-  msg = luaL_checklstring(L, 1, &len);
-  TSDebug(TS_LUA_DEBUG_TAG, "%.*s", (int)len, msg);
   return 0;
 }
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].