Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions doc/admin-guide/plugins/lua.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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()*
Expand Down
64 changes: 64 additions & 0 deletions plugins/lua/ts_lua_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -195,6 +215,50 @@ ts_lua_fatal(lua_State *L)
return 0;
}

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)
{
Expand Down