Software / code / prosody
Comparison
plugins/mod_console.lua @ 3404:33c81ee280e3
mod_console: Added support for multiple arguments to print().
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 26 Jul 2010 00:59:26 +0500 |
| parent | 3044:a6f89c72d305 |
| child | 3407:15f633285755 |
comparison
equal
deleted
inserted
replaced
| 3403:b89680015b7b | 3404:33c81ee280e3 |
|---|---|
| 34 | 34 |
| 35 function console:new_session(conn) | 35 function console:new_session(conn) |
| 36 local w = function(s) conn:write(s:gsub("\n", "\r\n")); end; | 36 local w = function(s) conn:write(s:gsub("\n", "\r\n")); end; |
| 37 local session = { conn = conn; | 37 local session = { conn = conn; |
| 38 send = function (t) w(tostring(t)); end; | 38 send = function (t) w(tostring(t)); end; |
| 39 print = function (t) w("| "..tostring(t).."\n"); end; | 39 print = function (...) |
| 40 local t = {}; | |
| 41 for i=1,select("#", ...) do | |
| 42 t[i] = tostring(select(i, ...)); | |
| 43 end | |
| 44 w("| "..table.concat(t, "\t").."\n"); | |
| 45 end; | |
| 40 disconnect = function () conn:close(); end; | 46 disconnect = function () conn:close(); end; |
| 41 }; | 47 }; |
| 42 session.env = setmetatable({}, default_env_mt); | 48 session.env = setmetatable({}, default_env_mt); |
| 43 | 49 |
| 44 -- Load up environment with helper objects | 50 -- Load up environment with helper objects |