aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2007-09-02 17:41:49 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2007-09-02 17:41:49 -0500
commit1ca154c05eecba90968738b33e3c9c3df22c0972 (patch)
tree38b83af57e171d1be4560a80909b6e04238b181d
parentd21ec508c5870ff22da868f2361b7da1c1685313 (diff)
downloadluairc-1ca154c05eecba90968738b33e3c9c3df22c0972.tar.gz
luairc-1ca154c05eecba90968738b33e3c9c3df22c0972.zip
document debug module
-rw-r--r--src/irc/debug.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/irc/debug.lua b/src/irc/debug.lua
index 2e03d74..4380036 100644
--- a/src/irc/debug.lua
+++ b/src/irc/debug.lua
@@ -1,8 +1,13 @@
+---
+-- Basic debug output
-- initialization {{{
local base = _G
local io = require 'io'
-- }}}
+---
+-- This module implements a few useful debug functions for use throughout the
+-- rest of the code.
module 'irc.debug'
-- defaults {{{
@@ -16,24 +21,37 @@ local outfile = io.output()
-- public functions {{{
-- enable {{{
+---
+-- Turns on debug output.
function enable()
ON = true
end
-- }}}
-- disable {{{
+---
+-- Turns off debug output.
function disable()
ON = false
end
-- }}}
-- set_output {{{
+---
+-- Redirects output to a file rather than stdout.
+-- @param file File to write debug output to
function set_output(file)
outfile = base.assert(io.open(file))
end
-- }}}
-- message {{{
+--
+-- Output a debug message.
+-- @param msg_type Arbitrary string corresponding to the type of message
+-- @param msg Message text
+-- @param color Which terminal code to use for color output (defaults to
+-- dark gray)
function message(msg_type, msg, color)
if ON then
local endcolor = ""
@@ -50,6 +68,11 @@ end
-- }}}
-- err {{{
+--
+-- Signal an error. Writes the error message to the screen in red and calls
+-- error().
+-- @param msg Error message
+-- @see error
function err(msg)
message("ERR", msg, "\027[0;31m")
base.error(msg, 2)
@@ -57,6 +80,9 @@ end
-- }}}
-- warn {{{
+--
+-- Signal a warning. Writes the warning message to the screen in yellow.
+-- @param msg Warning message
function warn(msg)
message("WARN", msg, "\027[0;33m")
end