From fd6352ee98b9ecd6082da8f0efa9b94ce268bbd0 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Thu, 13 Jan 2011 17:27:56 +0000 Subject: [PATCH] Adjust buffer sizes and add an option --- CaptainsLog.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CaptainsLog.lua b/CaptainsLog.lua index 5cd4835..637f4e9 100644 --- a/CaptainsLog.lua +++ b/CaptainsLog.lua @@ -7,8 +7,6 @@ local L = addon.L addon.ldb = LibStub("LibDataBroker-1.1") -local BUFFER_SIZE = 10 - local C = { whisper = WHISPER, party = PARTY, @@ -27,6 +25,9 @@ function addon:Initialize() profile = { timestamp = true, timestamp_format = "%H:%M ", + buffersize = { + ["*"] = 10, + }, showinfeed = { whisper = true, party = true, @@ -78,10 +79,19 @@ function addon:Initialize() end end +function addon:PruneMessages() + for mtype, list in pairs(self.messages) do + while #list > addon.db.profile.buffersize[mtype] do + table.remove(list, 1) + end + end +end + function addon:Log(mtype, sender, msg) table.insert(self.messages[mtype], {time(), sender, msg}) - while #self.messages[mtype] > BUFFER_SIZE do + local bufsize = addon.db.profile.buffersize[mtype] + while #self.messages[mtype] > bufsize do table.remove(self.messages[mtype], 1) end -- 1.7.9.5