Reduce output logging unless /aidebug is enabled

Sasky [06-13-14 - 23:19]
Reduce output logging unless /aidebug is enabled
Filename
AutoInvite.lua
AutoInvite.txt
diff --git a/AutoInvite.lua b/AutoInvite.lua
index e791252..5a733e0 100644
--- a/AutoInvite.lua
+++ b/AutoInvite.lua
@@ -13,10 +13,11 @@ AutoInvite.AddonId = "AutoInvite"
 ------------------------------------------------
 local function b(v) if v then return "T" else return "F" end end
 local function nn(val) if val == nil then return "NIL" else return val end end
+local function dbg(msg) if AutoInvite.debug then d("|c999999" .. msg) end end

 AutoInvite.isCyrodiil = function(unit)
     if unit == nil then unit = "player" end
-    d("Current zone: '" .. GetUnitZone(unit) .. "'")
+    dbg("Current zone: '" .. GetUnitZone(unit) .. "'")
     return GetUnitZone(unit) == "Cyrodiil"
 end

@@ -45,7 +46,7 @@ AutoInvite.guildLookup = function(channel, acctName)
             charName = charName:gsub("%^.+", "")

             if AutoInvite.cfg.cyrCheck then
-                d("In Cyrodiil? " .. b(AutoInvite.isCyrodiil()) .. " / Zone: " .. zone)
+                dbg("In Cyrodiil? " .. b(AutoInvite.isCyrodiil()) .. " / Zone: " .. zone)

                 if AutoInvite.isCyrodiil() and zone ~= "Cyrodiil" then
                     d("Player " .. charName .. " is not in Cyrodiil but in " .. zone)
@@ -126,10 +127,10 @@ end
 AutoInvite.offlineEvent = function(_, unitTag, connectStatus)
     local unitName = GetUnitName(unitTag):gsub("%^.+", "")
     if connectStatus then
-        d(unitTag .. "/" .. unitName .. " has reconnected")
+        dbg(unitTag .. "/" .. unitName .. " has reconnected")
         AutoInvite.kickTable[unitName] = nil
     else
-        d(unitTag .. "/" .. unitName .. " has disconnected")
+        dbg(unitTag .. "/" .. unitName .. " has disconnected")
         AutoInvite.kickTable[unitName] = GetTimeStamp()
     end
 end
@@ -142,10 +143,10 @@ function AutoInvite.kickCheck()
     for p,t in pairs(AutoInvite.kickTable) do
         local offTime = GetDiffBetweenTimeStamps(now, t)
         if offTime > AutoInvite.cfg.kickDelay then
-            d("  KICK: " .. p .. " offline for " .. offTime)
+            dbg("  KICK: " .. p .. " offline for " .. offTime)
             AutoInvite.kickByName(p)
         else
-            d(p .. " offline for " .. offTime .. " / " .. AutoInvite.cfg.kickDelay)
+            dbg(p .. " offline for " .. offTime .. " / " .. AutoInvite.cfg.kickDelay)
         end
     end
 end
@@ -249,13 +250,18 @@ SLASH_COMMANDS["/aik"] = function()
     for p,t in pairs(AutoInvite.kickTable) do
         local offTime = now - t
         if offTime > 300 then
-            d("  KICK: " .. p .. " offline for " .. now - t)
+            dbg("  KICK: " .. p .. " offline for " .. now - t)
         else
-            --d("  " .. p .. " offline for " .. now - t)
+            dbg("  " .. p .. " offline for " .. now - t)
         end
     end
 end

+SLASH_COMMANDS["/aidebug"] = function()
+    d("|cFF0000Beginning debug mode for AutoInvite.")
+    AutoInvite.debug = true
+end
+
 SLASH_COMMANDS["/aikick"] = function()
     local now = GetTimeStamp()
     d("Offline players:")
diff --git a/AutoInvite.txt b/AutoInvite.txt
index 1d70d90..c552cbf 100644
--- a/AutoInvite.txt
+++ b/AutoInvite.txt
@@ -1,6 +1,6 @@
 ## APIVersion: 100004
 ## Title: AutoInvite
-## Version: 1.3.0
+## Version: 1.3.1
 ## Author: Sasky
 ## SavedVariables: AutoInviteSettings
 ## OptionalDependsOn: LibAddonMenu-2.0