Added IgnoreIdentical param to LogDisplay for use in ignoring identical error messages.
This commit is contained in:
@@ -48,6 +48,7 @@ end
|
||||
local log_args= {
|
||||
Name= "ScriptError",
|
||||
ReplaceLinesWhenHidden= true,
|
||||
IgnoreIdentical= true,
|
||||
Times= message_time,
|
||||
Font= "Common Error",
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
-- If this is false, messages recieved while the LogDisplay is hidden
|
||||
-- will push other messages back. Messages pushed past MaxLines will be
|
||||
-- removed.
|
||||
-- IgnoreIdentical= bool
|
||||
-- If true, then a message that is identical to one already in the log
|
||||
-- will be ignored.
|
||||
-- Font= font name
|
||||
-- The name of the font to use. This will be passed to THEME:GetPathF,
|
||||
-- so it should not be a path.
|
||||
@@ -146,6 +149,19 @@ local log_display_mt= {
|
||||
-- Long ago, someone decided that "::" should be an alias for "\n"
|
||||
-- and hardcoded it into BitmapText.
|
||||
local message= tostring(mess.message):gsub("::", ":")
|
||||
if params.IgnoreIdentical then
|
||||
-- Use only the first line for comparison because the rest is
|
||||
-- probably stack trace, with args that might vary uselessly.
|
||||
self.width_tester:settext(message)
|
||||
local lines= convert_text_to_indented_lines(
|
||||
self.width_tester, self.indent, self.line_width, self.text_zoom)
|
||||
for i, prevmess in ipairs(self.message_log) do
|
||||
self.width_tester:settext(prevmess)
|
||||
local prevlines= convert_text_to_indented_lines(
|
||||
self.width_tester, self.indent, self.line_width, self.text_zoom)
|
||||
if lines[1][2] == prevmess[1][2] then return end
|
||||
end
|
||||
end
|
||||
if params.ReplaceLinesWhenHidden and self.hidden then
|
||||
self:clear()
|
||||
self.message_log[1]= message
|
||||
|
||||
Reference in New Issue
Block a user