clix: Make more use of Verse's new logging controls

Wed, 06 Jan 2010 17:52:01 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 06 Jan 2010 17:52:01 +0000
changeset 2
fd77e75c4891
parent 1
58c694492459
child 3
614b5994a1ed

clix: Make more use of Verse's new logging controls

clix.lua file | annotate | diff | comparison | revisions
--- 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);

mercurial