From 8cae22be8ea7932580387e01137f5849ea216687 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 29 Oct 2013 16:52:05 +0100 Subject: [PATCH] Reduced log duplicity. --- src/controller/controller_storage.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/controller/controller_storage.cpp b/src/controller/controller_storage.cpp index ebad9da6..fab0d294 100644 --- a/src/controller/controller_storage.cpp +++ b/src/controller/controller_storage.cpp @@ -14,10 +14,16 @@ namespace Controller { void Log(std::string kind, std::string message){ //if last log message equals this one, do not log. if (Storage["log"].size() > 0){ - JSON::ArrIter it = Storage["log"].ArrEnd() - 1; - if (( *it)[2] == message && ( *it)[1] == kind){ - return; - } + JSON::ArrIter it = Storage["log"].ArrEnd(); + int repeats = Storage["log"].size(); + if (repeats > 10){repeats = 10;} + do{ + it--; + if (( *it)[2] == message && ( *it)[1] == kind){ + return; + } + repeats--; + }while (repeats > 0); } JSON::Value m; m.append(Util::epoch());