main.lua

changeset 107
65791ba388b9
parent 89
f353cd50c075
child 108
cd58c64c67c0
--- a/main.lua	Mon Sep 10 09:53:14 2018 +0100
+++ b/main.lua	Mon Sep 10 10:01:19 2018 +0100
@@ -10,6 +10,8 @@
 local server_log_wait_time = 0.2;
 local skip_server_startup_log = false;
 local action_timeout = 5;
+local verse_log_levels = { "warn", "error" };
+local quiet = false;
 
 local property_rules = {};
 
@@ -69,6 +71,12 @@
 			else
 				error("Unable to parse tag: "..tag);
 			end
+		elseif opt == "--verbose" or opt == "-v" then
+			verse_log_levels = { "debug", "info", "warn", "error" };
+			quiet = false;
+		elseif opt == "--quiet" or opt == "-q" then
+			verse_log_levels = { "error" };
+			quiet = true;
 		else
 			error("Unhandled command-line option: "..opt);
 		end
@@ -112,7 +120,7 @@
 function initialize_verse(errcb)
 	local verse = require "verse";
 	
-	verse.set_log_handler(verse._default_log_handler, { "debug", "info", "warn", "error" });
+	verse.set_log_handler(verse._default_log_handler, verse_log_levels);
 
 	local function error_handler(err)
 		verse.log("error", "Error: %s", err);
@@ -147,7 +155,9 @@
 			local object = script.objects[action.object_name];
 			local handler = object.handler;
 			assert(handler[action.action], "Objects of type '"..object.type.."' do not support action '"..action.action.."'");
-			print("");
+			if not quiet then
+				print("");
+			end
 			if server_log_reader then
 				log_data("server", { lines = server_log_reader() });
 			end
@@ -158,10 +168,12 @@
 				extra = action.extra;
 				annotation = action.annotation;
 			});
-			if action.annotation then
-				print(action.annotation);
+			if not quiet then
+				if action.annotation then
+					print(action.annotation);
+				end
+				print(object.name.." "..action.action);
 			end
-			print(object.name, action.action.."...");
 			if action_timeout and action_timeout > 0 then
 				local action_number = i;
 				verse.add_task(action_timeout, function ()

mercurial