{"action":"created","comment":{"url":"https://api.github.com/repos/OPM/opm-common/pulls/comments/83849498","pull_request_review_id":4662712,"id":83849498,"diff_hunk":"@@ -46,62 +54,108 @@ namespace Opm\n         /// Negative limits (including NoLimit) are interpreted as\n         /// NoLimit, but the default constructor is the preferred way\n         /// to obtain that behaviour.\n-        explicit MessageLimiter(const int message_limit)\n-            : message_limit_(message_limit < 0 ? NoLimit : message_limit)\n+        explicit MessageLimiter(const int tag_limit)\n+            : tag_limit_(tag_limit < 0 ? NoLimit : tag_limit),\n+              category_limits_({{Log::MessageType::Note, NoLimit},\n+                                {Log::MessageType::Info, NoLimit},\n+                                {Log::MessageType::Warning, NoLimit},\n+                                {Log::MessageType::Error, NoLimit},\n+                                {Log::MessageType::Problem, NoLimit},\n+                                {Log::MessageType::Bug, NoLimit}})\n+        {\n+        }\n+\n+        MessageLimiter(const int tag_limit, const std::map<int64_t, int> category_limits)\n+            : tag_limit_(tag_limit < 0 ? NoLimit : tag_limit),\n+              category_limits_(category_limits)\n         {\n         }\n \n         /// The message limit (same for all tags).\n         int messageLimit() const\n         {\n-            return message_limit_;\n+            return tag_limit_;\n         }\n \n-        /// Used for handleMessageTag() return type (see that\n+        /// Used for handleMessageLimits() return type (see that\n         /// function).\n         enum class Response\n         {\n-            PrintMessage, JustOverLimit, OverLimit\n+            PrintMessage, JustOverTagLimit, JustOverCategoryLimit, OverTagLimit, OverCategoryLimit\n         };\n \n         /// If a tag is empty, there is no message limit or for that\n-        /// tag (count <= limit), respond PrintMessage.\n+        /// (count <= limit), respond PrintMessage.\n         /// If (count == limit + 1), respond JustOverLimit.\n         /// If (count > limit + 1), respond OverLimit.\n-        Response handleMessageTag(const std::string& tag)\n+        Response handleMessageLimits(const std::string& tag, const int64_t messageMask)\n         {\n-            if (tag.empty() || message_limit_ == NoLimit) {\n-                return Response::PrintMessage;\n+            Response res = Response::PrintMessage;\n+            // Deal with tag limits.\n+            if (tag.empty() || tag_limit_ == NoLimit) {\n+                category_counts_[messageMask]++;\n+                res = Response::PrintMessage;\n             } else {\n                 // See if tag already encountered.\n                 auto it = tag_counts_.find(tag);\n                 if (it != tag_counts_.end()) {\n                     // Already encountered this tag. Increment its count.\n                     const int count = ++it->second;\n-                    return countBasedResponse(count);\n+                    res = countBasedResponse(count, messageMask);\n                 } else {\n                     // First encounter of this tag. Insert 1.\n                     tag_counts_.insert({tag, 1});\n-                    return countBasedResponse(1);\n+                    res = countBasedResponse(1, messageMask);\n                 }\n             }\n+            // If tag count reached the limit, ignore all the same tagged messages.\n+            if (res == Response::JustOverTagLimit || res == Response::OverTagLimit) {\n+                return res;\n+            } else {\n+                if (category_limits_[messageMask] == NoLimit) {\n+                    category_counts_[messageMask]++;\n+                    res = Response::PrintMessage;\n+                } else {\n+                    res = countBasedResponse(messageMask);\n+                }\n+            }\n+            return res;\n         }\n \n     private:\n-        Response countBasedResponse(const int count)\n+        Response countBasedResponse(const int count, const int64_t messageMask)\n         {\n-            if (count <= message_limit_) {\n+            if (count <= tag_limit_) {\n+                category_counts_[messageMask]++;\n                 return Response::PrintMessage;\n-            } else if (count == message_limit_ + 1) {\n-                return Response::JustOverLimit;\n+            } else if (count == tag_limit_ + 1) {\n+                category_counts_[messageMask]++;\n+                return Response::JustOverTagLimit;\n             } else {\n-                return Response::OverLimit;\n+                return Response::OverTagLimit;\n             }\n         }\n \n \n-        int message_limit_;\n+        Response countBasedResponse(const int64_t messageMask)\n+        {\n+            if (category_counts_[messageMask] < category_limits_[messageMask]) {\n+                category_counts_[messageMask]++;\n+                return Response::PrintMessage;\n+            } else if (category_counts_[messageMask] == category_limits_[messageMask] + 1) {\n+                category_counts_[messageMask]++;\n+                return Response::JustOverCategoryLimit;\n+            } else {\n+                return Response::OverCategoryLimit;\n+            }\n+        }\n+\n+        int tag_limit_;\n         std::unordered_map<std::string, int> tag_counts_;\n+        std::map<int64_t, int> category_counts_;\n+        // info, note, warning, problem, error, bug.\n+        std::map<int64_t, int> category_limits_;\n+        bool reachTagLimit_;","path":"opm/common/OpmLog/MessageLimiter.hpp","position":148,"original_position":148,"commit_id":"9020c7cb36828216431cc71ce96ae864d98b1c9b","original_commit_id":"9020c7cb36828216431cc71ce96ae864d98b1c9b","user":{"login":"atgeirr","id":1876621,"avatar_url":"https://avatars.githubusercontent.com/u/1876621?v=3","gravatar_id":"","url":"https://api.github.com/users/atgeirr","html_url":"https://github.com/atgeirr","followers_url":"https://api.github.com/users/atgeirr/followers","following_url":"https://api.github.com/users/atgeirr/following{/other_user}","gists_url":"https://api.github.com/users/atgeirr/gists{/gist_id}","starred_url":"https://api.github.com/users/atgeirr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atgeirr/subscriptions","organizations_url":"https://api.github.com/users/atgeirr/orgs","repos_url":"https://api.github.com/users/atgeirr/repos","events_url":"https://api.github.com/users/atgeirr/events{/privacy}","received_events_url":"https://api.github.com/users/atgeirr/received_events","type":"User","site_admin":false},"body":"Unused, can be removed.","created_at":"2016-10-18T13:10:31Z","updated_at":"2016-10-18T13:14:55Z","html_url":"https://github.com/OPM/opm-common/pull/186#discussion_r83849498","pull_request_url":"https://api.github.com/repos/OPM/opm-common/pulls/186","_links":{"self":{"href":"https://api.github.com/repos/OPM/opm-common/pulls/comments/83849498"},"html":{"href":"https://github.com/OPM/opm-common/pull/186#discussion_r83849498"},"pull_request":{"href":"https://api.github.com/repos/OPM/opm-common/pulls/186"}}},"pull_request":{"url":"https://api.github.com/repos/OPM/opm-common/pulls/186","id":89796117,"html_url":"https://github.com/OPM/opm-common/pull/186","diff_url":"https://github.com/OPM/opm-common/pull/186.diff","patch_url":"https://github.com/OPM/opm-common/pull/186.patch","issue_url":"https://api.github.com/repos/OPM/opm-common/issues/186","number":186,"state":"open","locked":false,"title":"Support category limits setting.","user":{"login":"qilicun","id":2907423,"avatar_url":"https://avatars.githubusercontent.com/u/2907423?v=3","gravatar_id":"","url":"https://api.github.com/users/qilicun","html_url":"https://github.com/qilicun","followers_url":"https://api.github.com/users/qilicun/followers","following_url":"https://api.github.com/users/qilicun/following{/other_user}","gists_url":"https://api.github.com/users/qilicun/gists{/gist_id}","starred_url":"https://api.github.com/users/qilicun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qilicun/subscriptions","organizations_url":"https://api.github.com/users/qilicun/orgs","repos_url":"https://api.github.com/users/qilicun/repos","events_url":"https://api.github.com/users/qilicun/events{/privacy}","received_events_url":"https://api.github.com/users/qilicun/received_events","type":"User","site_admin":false},"body":"Since https://github.com/OPM/opm-common/pull/173 request a major changes, so  I decided to open a new PR and close that one. This is ready for review, ","created_at":"2016-10-18T11:28:10Z","updated_at":"2016-10-18T13:14:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2974dd8599e5ede2059569b5ee3fe980681020ba","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OPM/opm-common/pulls/186/commits","review_comments_url":"https://api.github.com/repos/OPM/opm-common/pulls/186/comments","review_comment_url":"https://api.github.com/repos/OPM/opm-common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OPM/opm-common/issues/186/comments","statuses_url":"https://api.github.com/repos/OPM/opm-common/statuses/9020c7cb36828216431cc71ce96ae864d98b1c9b","head":{"label":"qilicun:messages-limits","ref":"messages-limits","sha":"9020c7cb36828216431cc71ce96ae864d98b1c9b","user":{"login":"qilicun","id":2907423,"avatar_url":"https://avatars.githubusercontent.com/u/2907423?v=3","gravatar_id":"","url":"https://api.github.com/users/qilicun","html_url":"https://github.com/qilicun","followers_url":"https://api.github.com/users/qilicun/followers","following_url":"https://api.github.com/users/qilicun/following{/other_user}","gists_url":"https://api.github.com/users/qilicun/gists{/gist_id}","starred_url":"https://api.github.com/users/qilicun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qilicun/subscriptions","organizations_url":"https://api.github.com/users/qilicun/orgs","repos_url":"https://api.github.com/users/qilicun/repos","events_url":"https://api.github.com/users/qilicun/events{/privacy}","received_events_url":"https://api.github.com/users/qilicun/received_events","type":"User","site_admin":false},"repo":{"id":58170869,"name":"opm-common","full_name":"qilicun/opm-common","owner":{"login":"qilicun","id":2907423,"avatar_url":"https://avatars.githubusercontent.com/u/2907423?v=3","gravatar_id":"","url":"https://api.github.com/users/qilicun","html_url":"https://github.com/qilicun","followers_url":"https://api.github.com/users/qilicun/followers","following_url":"https://api.github.com/users/qilicun/following{/other_user}","gists_url":"https://api.github.com/users/qilicun/gists{/gist_id}","starred_url":"https://api.github.com/users/qilicun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qilicun/subscriptions","organizations_url":"https://api.github.com/users/qilicun/orgs","repos_url":"https://api.github.com/users/qilicun/repos","events_url":"https://api.github.com/users/qilicun/events{/privacy}","received_events_url":"https://api.github.com/users/qilicun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/qilicun/opm-common","description":"Common components for OPM, in particular build system (cmake).","fork":true,"url":"https://api.github.com/repos/qilicun/opm-common","forks_url":"https://api.github.com/repos/qilicun/opm-common/forks","keys_url":"https://api.github.com/repos/qilicun/opm-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qilicun/opm-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qilicun/opm-common/teams","hooks_url":"https://api.github.com/repos/qilicun/opm-common/hooks","issue_events_url":"https://api.github.com/repos/qilicun/opm-common/issues/events{/number}","events_url":"https://api.github.com/repos/qilicun/opm-common/events","assignees_url":"https://api.github.com/repos/qilicun/opm-common/assignees{/user}","branches_url":"https://api.github.com/repos/qilicun/opm-common/branches{/branch}","tags_url":"https://api.github.com/repos/qilicun/opm-common/tags","blobs_url":"https://api.github.com/repos/qilicun/opm-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qilicun/opm-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qilicun/opm-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/qilicun/opm-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qilicun/opm-common/statuses/{sha}","languages_url":"https://api.github.com/repos/qilicun/opm-common/languages","stargazers_url":"https://api.github.com/repos/qilicun/opm-common/stargazers","contributors_url":"https://api.github.com/repos/qilicun/opm-common/contributors","subscribers_url":"https://api.github.com/repos/qilicun/opm-common/subscribers","subscription_url":"https://api.github.com/repos/qilicun/opm-common/subscription","commits_url":"https://api.github.com/repos/qilicun/opm-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/qilicun/opm-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/qilicun/opm-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/qilicun/opm-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/qilicun/opm-common/contents/{+path}","compare_url":"https://api.github.com/repos/qilicun/opm-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qilicun/opm-common/merges","archive_url":"https://api.github.com/repos/qilicun/opm-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qilicun/opm-common/downloads","issues_url":"https://api.github.com/repos/qilicun/opm-common/issues{/number}","pulls_url":"https://api.github.com/repos/qilicun/opm-common/pulls{/number}","milestones_url":"https://api.github.com/repos/qilicun/opm-common/milestones{/number}","notifications_url":"https://api.github.com/repos/qilicun/opm-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qilicun/opm-common/labels{/name}","releases_url":"https://api.github.com/repos/qilicun/opm-common/releases{/id}","deployments_url":"https://api.github.com/repos/qilicun/opm-common/deployments","created_at":"2016-05-06T01:14:52Z","updated_at":"2016-05-06T01:14:53Z","pushed_at":"2016-10-18T11:26:42Z","git_url":"git://github.com/qilicun/opm-common.git","ssh_url":"git@github.com:qilicun/opm-common.git","clone_url":"https://github.com/qilicun/opm-common.git","svn_url":"https://github.com/qilicun/opm-common","homepage":"http://www.opm-project.org","size":500,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OPM:master","ref":"master","sha":"c32693f44c402da6cfdc05ae3231807b0dfed301","user":{"login":"OPM","id":1827197,"avatar_url":"https://avatars.githubusercontent.com/u/1827197?v=3","gravatar_id":"","url":"https://api.github.com/users/OPM","html_url":"https://github.com/OPM","followers_url":"https://api.github.com/users/OPM/followers","following_url":"https://api.github.com/users/OPM/following{/other_user}","gists_url":"https://api.github.com/users/OPM/gists{/gist_id}","starred_url":"https://api.github.com/users/OPM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OPM/subscriptions","organizations_url":"https://api.github.com/users/OPM/orgs","repos_url":"https://api.github.com/users/OPM/repos","events_url":"https://api.github.com/users/OPM/events{/privacy}","received_events_url":"https://api.github.com/users/OPM/received_events","type":"Organization","site_admin":false},"repo":{"id":32443143,"name":"opm-common","full_name":"OPM/opm-common","owner":{"login":"OPM","id":1827197,"avatar_url":"https://avatars.githubusercontent.com/u/1827197?v=3","gravatar_id":"","url":"https://api.github.com/users/OPM","html_url":"https://github.com/OPM","followers_url":"https://api.github.com/users/OPM/followers","following_url":"https://api.github.com/users/OPM/following{/other_user}","gists_url":"https://api.github.com/users/OPM/gists{/gist_id}","starred_url":"https://api.github.com/users/OPM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OPM/subscriptions","organizations_url":"https://api.github.com/users/OPM/orgs","repos_url":"https://api.github.com/users/OPM/repos","events_url":"https://api.github.com/users/OPM/events{/privacy}","received_events_url":"https://api.github.com/users/OPM/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OPM/opm-common","description":"Common components for OPM, in particular build system (cmake).","fork":false,"url":"https://api.github.com/repos/OPM/opm-common","forks_url":"https://api.github.com/repos/OPM/opm-common/forks","keys_url":"https://api.github.com/repos/OPM/opm-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OPM/opm-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OPM/opm-common/teams","hooks_url":"https://api.github.com/repos/OPM/opm-common/hooks","issue_events_url":"https://api.github.com/repos/OPM/opm-common/issues/events{/number}","events_url":"https://api.github.com/repos/OPM/opm-common/events","assignees_url":"https://api.github.com/repos/OPM/opm-common/assignees{/user}","branches_url":"https://api.github.com/repos/OPM/opm-common/branches{/branch}","tags_url":"https://api.github.com/repos/OPM/opm-common/tags","blobs_url":"https://api.github.com/repos/OPM/opm-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OPM/opm-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OPM/opm-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/OPM/opm-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OPM/opm-common/statuses/{sha}","languages_url":"https://api.github.com/repos/OPM/opm-common/languages","stargazers_url":"https://api.github.com/repos/OPM/opm-common/stargazers","contributors_url":"https://api.github.com/repos/OPM/opm-common/contributors","subscribers_url":"https://api.github.com/repos/OPM/opm-common/subscribers","subscription_url":"https://api.github.com/repos/OPM/opm-common/subscription","commits_url":"https://api.github.com/repos/OPM/opm-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/OPM/opm-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/OPM/opm-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/OPM/opm-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/OPM/opm-common/contents/{+path}","compare_url":"https://api.github.com/repos/OPM/opm-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OPM/opm-common/merges","archive_url":"https://api.github.com/repos/OPM/opm-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OPM/opm-common/downloads","issues_url":"https://api.github.com/repos/OPM/opm-common/issues{/number}","pulls_url":"https://api.github.com/repos/OPM/opm-common/pulls{/number}","milestones_url":"https://api.github.com/repos/OPM/opm-common/milestones{/number}","notifications_url":"https://api.github.com/repos/OPM/opm-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OPM/opm-common/labels{/name}","releases_url":"https://api.github.com/repos/OPM/opm-common/releases{/id}","deployments_url":"https://api.github.com/repos/OPM/opm-common/deployments","created_at":"2015-03-18T06:59:50Z","updated_at":"2016-04-11T07:18:23Z","pushed_at":"2016-10-18T13:03:33Z","git_url":"git://github.com/OPM/opm-common.git","ssh_url":"git@github.com:OPM/opm-common.git","clone_url":"https://github.com/OPM/opm-common.git","svn_url":"https://github.com/OPM/opm-common","homepage":"http://www.opm-project.org","size":623,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":5,"forks":24,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OPM/opm-common/pulls/186"},"html":{"href":"https://github.com/OPM/opm-common/pull/186"},"issue":{"href":"https://api.github.com/repos/OPM/opm-common/issues/186"},"comments":{"href":"https://api.github.com/repos/OPM/opm-common/issues/186/comments"},"review_comments":{"href":"https://api.github.com/repos/OPM/opm-common/pulls/186/comments"},"review_comment":{"href":"https://api.github.com/repos/OPM/opm-common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OPM/opm-common/pulls/186/commits"},"statuses":{"href":"https://api.github.com/repos/OPM/opm-common/statuses/9020c7cb36828216431cc71ce96ae864d98b1c9b"}}}}
{"actor":{"display_login":"atgeirr"}}