changeset 465:b61a12ee8443

Send debug to sys console. Must die. Added just for history.
author Aleksandr Rybalko <ray@ddteam.net>
date Mon, 24 Sep 2012 14:15:36 +0300
parents d7b0ddec1929
children 40667c72ca98
files profiles/lua_web_ui/files/etc/www/lib/print_to_console.lua
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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