[Zrouter-src] ZRouter.org: push to ZRouter profiles/lua_web_ui/files/etc/www/l...
zrouter-src at zrouter.org
zrouter-src at zrouter.org
Mon Sep 24 11:23:51 UTC 2012
details: http://zrouter.org/hg/zrouter//rev/b61a12ee8443
changeset: 465:b61a12ee8443
user: Aleksandr Rybalko <ray at ddteam.net>
date: Mon Sep 24 14:15:36 2012 +0300
description:
Send debug to sys console.
Must die. Added just for history.
diffstat:
profiles/lua_web_ui/files/etc/www/lib/print_to_console.lua | 30 ++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diffs (34 lines):
diff -r d7b0ddec1929 -r b61a12ee8443 profiles/lua_web_ui/files/etc/www/lib/print_to_console.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/profiles/lua_web_ui/files/etc/www/lib/print_to_console.lua Mon Sep 24 14:15:36 2012 +0300
@@ -0,0 +1,30 @@
+print_native = print;
+cons = io.open("/dev/console", "w");
+
+-- XXX We need to find a way how to close it on signal
+-- cons:close();
+
+-- Write to stdout and console at the same time
+function console(...)
+ ret = 0;
+ out = string.gsub(string.format(...), "\n", "\r\n");
+ if cons then
+ ret = cons:write(out);
+ end
+ -- check if native print moved
+ if print_native then
+ print_native(out);
+ else
+ print(out);
+ end
+ return ret;
+end
+
+function progress(...)
+ console(...);
+end
+
+print = function (...)
+ -- "string.format" need raw string of "print" as a single string
+ console(table.concat(arg, "\t"):gsub("%%","%%%%") .. "\n");
+end
More information about the Zrouter-src
mailing list