Changeset

2:fd77e75c4891

clix: Make more use of Verse's new logging controls
author Matthew Wild <mwild1@gmail.com>
date Wed, 06 Jan 2010 17:52:01 +0000
parents 1:58c694492459
children 3:614b5994a1ed
files clix.lua
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/clix.lua	Wed Jan 06 17:33:16 2010 +0000
+++ b/clix.lua	Wed Jan 06 17:52:01 2010 +0000
@@ -50,18 +50,19 @@
 		io.stderr:write("The specified account (", opts.account or "default", ") wasn't found in the config file\n");
 		return nil;
 	end
-	
-	local conn = verse.new();
+	verse.set_logger(function () end);
+	local conn = verse.new(verse.logger());
+	conn.log.debug = opts.verbose;
 	conn:hook("authentication-failure", function (err)
-		io.stderr:write("Authentication failure (",err.condition or "unknown error", ")", err.text and (": "..err.text) or "", "\n");
+		conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or ""));
 	end);
-	conn:hook("binding-success", function () io.stderr:write("Connected: ", tostring(conn), "\n"); return on_connect(conn); end);
+	conn:hook("binding-success", function () conn:debug("Connected: "..tostring(conn)); return on_connect(conn); end);
 	conn:hook("binding-failure", function (err)
-		io.stderr:write("Authentication failure (",err.condition or "unknown error", ")", err.text and (": "..err.text) or "", "\n");
+		conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or ""));
 	end);
 	conn:hook("disconnected", function (info)
 		if info.reason then
-			io.stderr:write("Disconnecting: ", tostring(info.reason), "\n");
+			conn:warn("Disconnecting: %s", tostring(info.reason));
 		end
 		verse.quit();
 	end);