diff mod_audit/mod_audit.lua @ 5325:11b37063d80a

mod_audit: Add some control over output columns via command-line flags
author Matthew Wild <mwild1@gmail.com>
date Fri, 07 Apr 2023 13:25:34 +0100
parents 400ffa842576
children dc058fcc3fe3
line wrap: on
line diff
--- a/mod_audit/mod_audit.lua	Fri Apr 07 13:10:43 2023 +0100
+++ b/mod_audit/mod_audit.lua	Fri Apr 07 13:25:34 2023 +0100
@@ -155,7 +155,7 @@
 		{ title = "Event", key = "event_type", width = "2p" };
 	};
 
-	if not arg.global then
+	if arg.show_user ~= false and (not arg.global or arg.show_user) then
 		table.insert(colspec, {
 			title = "User", key = "username", width = "2p",
 			mapper = function (user)
@@ -165,17 +165,16 @@
 				end
 			end;
 		});
-
-		if attach_ips then
-			table.insert(colspec, {
-				title = "IP", key = "ip", width = "2p";
-			});
-		end
-		if attach_location then
-			table.insert(colspec, {
-				title = "Location", key = "country", width = 2;
-			});
-		end
+	end
+	if arg.show_ip ~= false and (not arg.global and attach_ips or arg.show_ip) then
+		table.insert(colspec, {
+			title = "IP", key = "ip", width = "2p";
+		});
+	end
+	if arg.show_location ~= false and (not arg.global and attach_location or arg.show_location) then
+		table.insert(colspec, {
+			title = "Location", key = "country", width = 2;
+		});
 	end
 
 	local row, width = require "util.human.io".table(colspec);