<commit_before>
-- needed to track available connections
local clients = {};
local control_socket;

-- debug monitoring is loud and costly and requires multiple hooks
-- there's a number of subsystems we need to hook in order to get a
-- reasonable debug/monitor view:
--
-- NOTIFICATION: [notifications] -
-- DISPLAY: [displays] - added/removed/rediscovered/reset/...
-- WM: [tilers] - window state changes
-- CONNECTION: [external connections] - rate limiting etc.
-- IDEVICE: [iostatem] - device appearing, disappearing, entering idle, ..
-- DISPATCH: [dispatch] - menu paths getting activated
-- WAYLAND: [special] - wayland clients
-- IPC: [ipc] - clients connecting
-- TIMERS: [timers] - when fired
--
local debug_count = 0;
local all_categories = {
	"NOTIFICATION",
	"DISPLAY",
	"WM",
	"CONNECTION",
	"IDEVICE",
	"DISPATCH",
	"WAYLAND",
	"IPC",
	"TIMERS",
	"CLIPBOARD",
	"CLIENTS"
};

local monitor_state = false;
local function toggle_monitoring(on)
	if (on and monitor_state or off and not monitor_state) then
		return;
	end

	local domains = {
		display = "DISPLAY:",
		wayland = "WAYLAND:",
		dispatch = "DISPATCH:",
		wm = "WM:",
		idevice = "IDEVICE:",
		timers = "TIMERS:",
		notification = "NOTIFICATION:",
		extconn = "CLIENT:",
		clipboard = "CLIPBOARD:"
	};

-- see suppl_add_logfn for the function that constructs the logger,
-- each subsystem references that to get the message log function that
-- will queue or forward to a set listener (that we define here)
	for k,v in pairs(domains) do
		local regfn = _G[k .. "_debug_listener"];
		if (regfn) then
			regfn( on and
				function(msg)
					for _, cl in ipairs(clients) do
						if (cl.category_map and cl.category_map[string.upper(k)]) then
							table.insert(cl.buffer, v .. msg);
						end
					end
				end or nil
			);
		end
	end

	monitor_state = on;
end

local function update_control(key, val)
-- close automatically unlinks
	if (control_socket) then
		control_socket:close();
		control_socket = nil;
	end<commit_msg>add more logging categories<commit_after>
-- needed to track available connections
local clients = {};
local control_socket;

-- debug monitoring is loud and costly and requires multiple hooks
-- there's a number of subsystems we need to hook in order to get a
-- reasonable debug/monitor view:
--
-- NOTIFICATION: [notifications] -
-- DISPLAY: [displays] - added/removed/rediscovered/reset/...
-- WM: [tilers] - window state changes
-- CONNECTION: [external connections] - rate limiting etc.
-- IDEVICE: [iostatem] - device appearing, disappearing, entering idle, ..
-- DISPATCH: [dispatch] - menu paths getting activated
-- WAYLAND: [special] - wayland clients
-- IPC: [ipc] - other IPC user actions
-- TIMERS: [timers] - when fired
-- CLIENTS: [clients] - events related
-- TOOLS: [tools] - domain used for toolscripts, prefix with name=xxx:"
--
local debug_count = 0;
local all_categories = {
	"NOTIFICATION",
	"DISPLAY",
	"WM",
	"CONNECTION",
	"IDEVICE",
	"DISPATCH",
	"WAYLAND",
	"IPC",
	"TIMERS",
	"CLIPBOARD",
	"CLIENT",
	"TOOLS",
};

local monitor_state = false;
local function toggle_monitoring(on)
	if (on and monitor_state or off and not monitor_state) then
		return;
	end

	local domains = {
		display = "DISPLAY:",
		wayland = "WAYLAND:",
		dispatch = "DISPATCH:",
		wm = "WM:",
		idevice = "IDEVICE:",
		timers = "TIMERS:",
		notification = "NOTIFICATION:",
		client = "CLIENT:",
		clipboard = "CLIPBOARD:",
		tools = "TOOLS:"
	};

-- see suppl_add_logfn for the function that constructs the logger,
-- each subsystem references that to get the message log function that
-- will queue or forward to a set listener (that we define here)
	for k,v in pairs(domains) do
		local regfn = _G[k .. "_debug_listener"];
		if (regfn) then
			regfn( on and
				function(msg)
					for _, cl in ipairs(clients) do
						if (cl.category_map and cl.category_map[string.upper(k)]) then
							table.insert(cl.buffer, v .. msg);
						end
					end
				end or nil
			);
		end
	end

	monitor_state = on;
end

local function update_control(key, val)
-- close automatically unlinks
	if (control_socket) then
		control_socket:close();
		control_socket = nil;
	end
{'fraction_non_alphanumeric': 0.12403660886319846, 'fraction_numerical': 0.0004816955684007707, 'mean_word_length': 3.563736263736264, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '176192', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1344, 'n_words': 454}