--- Logging utility. -- This prints things to the console for now, maybe it can automatically file bugs and save bug reports in the future? --@shared log.lua local log = {} local fn = nrequire("fn.lua") local col = nrequire("colortheme.lua") local domain if SERVER then domain = "[SERVER]" elseif CLIENT then domain = "[CLIENT]" end local log_levels = { debug = { color = col.console.gray,domain, prefix = "[DEBUG]" }, info = { color = col.console.cyan,domain, prefix = "[INFO]", }, warn = { color = col.console.yellow,domain, prefix = "[WARNING]", }, error = { color = col.console.red,domain, prefix = "[ERROR]", }, } local level = "debug" local rev_levels = {} local rev_level_counter = 1 for k,v in pairs(log_levels) do rev_levels[k] = rev_level_counter rev_level_counter = rev_level_counter + 1 end for mode,settings in pairs(log_levels) do log[mode] = function(...) if rev_levels[mode] >= rev_levels[level] then local args = {...} local toprint = {domain, settings.prefix} for _,part in pairs(args) do toprint[#toprint + 1] = tostring(part) end toprint[#toprint + 1] = "\n" MsgC(settings.color,table.concat(toprint," ")) end end log[mode .. "f"] = function(...) local args = {...} log[mode](string.format(unpack(args))) end end log.report = fn.curry( file.Append, "artery/report_log.txt" ) return log