From 86a0d68f9920cbcd382d8bb255639b022991def7 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Sun, 26 Aug 2007 22:07:38 -0500 Subject: add all of the current files --- src/irc/debug.lua | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/irc/debug.lua (limited to 'src/irc/debug.lua') 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 +-- }}} +-- }}} -- cgit v1.2.3