aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/log.lua
blob: 8005000d0d34b5940ea67ec70b85c3b089bc06d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- 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

--- Print a debug message.
-- This can be suppressed in release versions
function log.debug(...)
    MsgC(col.console.gray,domain,"[DEBUG]",table.concat({...}," "),"\n")
end

--- Print an information message.
-- Things server owners might want to see
function log.info(...)
    MsgC(col.console.cyan,domain,"[INFO]",table.concat({...}," "),"\n")
end

--- Prints a warning.
-- Things developers need to look at
-- Maybe print this to a file in the future?
function log.warn(...)
    MsgC(col.console.yellow,domain,"[WARNING]",table.concat({...}," "),"\n")
end

--- Prints an error.
-- Things that should never happen
-- Maybe have this automatically make bugs on the bug tracker with the above log files?
function log.error(...)
    MsgC(col.console.red,domain,"[ERROR]",table.concat({...}," "),"\n")
end

log.report = fn.curry(
    file.Append,
    "artery/report_log.txt"
)

return log