<commit_before>local DocSettings = require("docsettings") -- for dump method

local Dbg = {
	is_on = false,
	ev_log = nil,
}

local Dbg_mt = {}

local function LvDEBUG(lv, ...)
	local line = ""
	for i,v in ipairs({...}) do
		if type(v) == "table" then
			line = line .. " " .. DocSettings:dump(v, lv)
		else
			line = line .. " " .. tostring(v)
		end
	end
	print("#"..line)
end

local function DEBUGBT()
	DEBUG(debug.traceback())
end

function Dbg_mt.__call(dbg, ...)
	LvDEBUG(math.huge, ...)
end

function Dbg:turnOn()
	self.is_on = true

	-- create or clear ev log file
	os.execute("echo > ev.log")
	self.ev_log = io.open("ev.log", "w")
end

function Dbg:logEv(ev)
	local log = ev.type.."|"..ev.code.."|"
				..ev.value.."|"..ev.time.sec.."|"..ev.time.usec.."\n"
	self.ev_log:write(log)
	self.ev_log:flush()
end

setmetatable(Dbg, Dbg_mt)

return Dbg<commit_msg>fix debug on/off toggle<commit_after>local DocSettings = require("docsettings") -- for dump method

local Dbg = {
	is_on = false,
	ev_log = nil,
}

local Dbg_mt = {}

local function LvDEBUG(lv, ...)
	local line = ""
	for i,v in ipairs({...}) do
		if type(v) == "table" then
			line = line .. " " .. DocSettings:dump(v, lv)
		else
			line = line .. " " .. tostring(v)
		end
	end
	print("#"..line)
end

function Dbg_mt.__call(dbg, ...)
	if dbg.is_on then LvDEBUG(math.huge, ...) end
end

function Dbg:turnOn()
	self.is_on = true

	-- create or clear ev log file
	os.execute("echo > ev.log")
	self.ev_log = io.open("ev.log", "w")
end

function Dbg:logEv(ev)
	local log = ev.type.."|"..ev.code.."|"
				..ev.value.."|"..ev.time.sec.."|"..ev.time.usec.."\n"
	self.ev_log:write(log)
	self.ev_log:flush()
end

function Dbg:traceback()
	LvDEBUG(math.huge, debug.traceback())
end

setmetatable(Dbg, Dbg_mt)

return Dbg
{'fraction_non_alphanumeric': 0.19571347997743938, 'fraction_numerical': 0.0, 'mean_word_length': 3.096997690531178, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4845285', 'n_tokens_mistral': 770, 'n_tokens_neox': 734, 'n_words': 162}