diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2007-08-26 22:07:38 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2007-08-26 22:07:38 -0500 |
commit | 86a0d68f9920cbcd382d8bb255639b022991def7 (patch) | |
tree | d9ecb2ec46ababa1654818d06d3015f5da746162 /src/irc/debug.lua | |
parent | 27ea3f3876546997cfc838f6d605b8f4ca5adcd7 (diff) | |
download | luairc-86a0d68f9920cbcd382d8bb255639b022991def7.tar.xz |
add all of the current files
Diffstat (limited to 'src/irc/debug.lua')
-rw-r--r-- | src/irc/debug.lua | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/irc/debug.lua b/src/irc/debug.lua new file mode 100644 index 0000000..2e03d74 --- /dev/null +++ b/src/irc/debug.lua @@ -0,0 +1,64 @@ +-- initialization {{{ +local base = _G +local io = require 'io' +-- }}} + +module 'irc.debug' + +-- defaults {{{ +COLOR = true +-- }}} + +-- local variables {{{ +local ON = false +local outfile = io.output() +-- }}} + +-- public functions {{{ +-- enable {{{ +function enable() + ON = true +end +-- }}} + +-- disable {{{ +function disable() + ON = false +end +-- }}} + +-- set_output {{{ +function set_output(file) + outfile = base.assert(io.open(file)) +end +-- }}} + +-- message {{{ +function message(msg_type, msg, color) + if ON then + local endcolor = "" + if COLOR then + color = color or "\027[1;30m" + endcolor = "\027[0m" + else + color = "" + endcolor = "" + end + outfile:write(color .. msg_type .. ": " .. msg .. endcolor .. "\n") + end +end +-- }}} + +-- err {{{ +function err(msg) + message("ERR", msg, "\027[0;31m") + base.error(msg, 2) +end +-- }}} + +-- warn {{{ +function warn(msg) + message("WARN", msg, "\027[0;33m") +end +-- }}} +-- }}} |