{"action":"created","comment":{"url":"https://api.github.com/repos/ravendb/ravendb/pulls/comments/91596934","pull_request_review_id":12106553,"id":91596934,"diff_hunk":"@@ -0,0 +1,145 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Reflection;\n+using System.Text;\n+using System.Threading.Tasks;\n+using Raven.Abstractions.Extensions;\n+\n+namespace Sparrow.Logging\n+{\n+    public class LogginFilter\n+    {\n+\n+            private readonly Dictionary<string, List<string>> _rules = new Dictionary<string, List<string>>();\n+            private readonly string[] _entryFields;\n+\n+            public LogginFilter()\n+            {\n+                _entryFields = typeof(LogEntry).GetFields().Select(p => p.Name.ToLower()).ToArray();\n+                foreach (var entry in _entryFields)\n+                {\n+                    _rules.Add(entry, new List<string>());\n+                }\n+            }\n+\n+            public void Add(string rule)\n+            {\n+                string[] parts = rule.Split(':');\n+                string key = parts[0];\n+                string value = parts[1];\n+\n+                if (_entryFields.Contains(key) && value.Length > 0)\n+                {\n+                    _rules[key].Add(value.ToLower());\n+                }\n+            }\n+            public void Del(string rule)\n+            {\n+                string[] parts = rule.Split(':');\n+                string key = parts[0];\n+                int index = int.Parse(parts[1]) - 1;\n+\n+                if (_entryFields.Contains(key) && index < _rules[key].Count)\n+                {\n+                    _rules[key].RemoveAt(index);\n+                }\n+            }\n+            public string List()\n+            {\n+                StringBuilder sb = new StringBuilder();\n+                foreach (var rule in _rules)\n+                {\n+                    sb.AppendLine(\"-\" + rule.Key);\n+                    for (int index = 0; index < rule.Value.Count; index++)\n+                    {\n+                        var r = rule.Value[index];\n+                        sb.AppendLine(\"\\t \" + (index + 1) + \". \" + r);\n+                    }\n+                }\n+                return sb.ToString();\n+            }\n+\n+            public string GetHelp()\n+            {\n+                StringBuilder sb = new StringBuilder();\n+                sb.AppendLine(\"usage: filter [-add] [-del] [-list]\\n\");\n+                sb.AppendLine(\"The available headers are:\");\n+                // Array.ForEach(entries, (entry) => sb.Append(entry));\n+                foreach (var entry in _entryFields)\n+                {\n+                    sb.Append(entry + \"  \");\n+                }\n+                \n+                sb.AppendLine(\"\\n-add <header>:somestring\");\n+                sb.AppendLine(\"-del <header>:rule number\");\n+            return sb.ToString();\n+            }\n+            public bool Forward(LogEntry entry)\n+            {\n+                bool valid = true;\n+              \n+                foreach (var e in _entryFields)\n+                {\n+                    var listOfRules = _rules[e];\n+                    if (listOfRules.Count != 0)\n+                    {\n+                    valid = false;\n+                    switch (e)\n+                        {\n+                        // Don't know how to do it more generic (and prettier) without the use of reflection\n+                        case \"at\":","path":"src/Sparrow/Logging/LogginFilter.cs","position":91,"original_position":91,"commit_id":"706a0b05478d69053d91e15c2d91210630315edc","original_commit_id":"d8d39f9fe1e5b3379f0f297b8f12984232c518f3","user":{"login":"ayende","id":116915,"avatar_url":"https://avatars.githubusercontent.com/u/116915?v=3","gravatar_id":"","url":"https://api.github.com/users/ayende","html_url":"https://github.com/ayende","followers_url":"https://api.github.com/users/ayende/followers","following_url":"https://api.github.com/users/ayende/following{/other_user}","gists_url":"https://api.github.com/users/ayende/gists{/gist_id}","starred_url":"https://api.github.com/users/ayende/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayende/subscriptions","organizations_url":"https://api.github.com/users/ayende/orgs","repos_url":"https://api.github.com/users/ayende/repos","events_url":"https://api.github.com/users/ayende/events{/privacy}","received_events_url":"https://api.github.com/users/ayende/received_events","type":"User","site_admin":false},"body":"This is bad. You are doing multiple allocations here, for the `Any` call, for the `ToLower`, etc.\r\nThis is also done elsewhere, but those happen much more rarely. Here this is called every single log entry, which means that you need to consider performance.","created_at":"2016-12-08T20:10:39Z","updated_at":"2016-12-08T20:13:31Z","html_url":"https://github.com/ravendb/ravendb/pull/1074#discussion_r91596934","pull_request_url":"https://api.github.com/repos/ravendb/ravendb/pulls/1074","_links":{"self":{"href":"https://api.github.com/repos/ravendb/ravendb/pulls/comments/91596934"},"html":{"href":"https://github.com/ravendb/ravendb/pull/1074#discussion_r91596934"},"pull_request":{"href":"https://api.github.com/repos/ravendb/ravendb/pulls/1074"}}},"pull_request":{"url":"https://api.github.com/repos/ravendb/ravendb/pulls/1074","id":97144536,"html_url":"https://github.com/ravendb/ravendb/pull/1074","diff_url":"https://github.com/ravendb/ravendb/pull/1074.diff","patch_url":"https://github.com/ravendb/ravendb/pull/1074.patch","issue_url":"https://api.github.com/repos/ravendb/ravendb/issues/1074","number":1074,"state":"open","locked":false,"title":"Raven db 5656","user":{"login":"karmeli87","id":6377808,"avatar_url":"https://avatars.githubusercontent.com/u/6377808?v=3","gravatar_id":"","url":"https://api.github.com/users/karmeli87","html_url":"https://github.com/karmeli87","followers_url":"https://api.github.com/users/karmeli87/followers","following_url":"https://api.github.com/users/karmeli87/following{/other_user}","gists_url":"https://api.github.com/users/karmeli87/gists{/gist_id}","starred_url":"https://api.github.com/users/karmeli87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karmeli87/subscriptions","organizations_url":"https://api.github.com/users/karmeli87/orgs","repos_url":"https://api.github.com/users/karmeli87/repos","events_url":"https://api.github.com/users/karmeli87/events{/privacy}","received_events_url":"https://api.github.com/users/karmeli87/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-08T15:38:14Z","updated_at":"2016-12-08T20:13:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"198ca1c50cd185a9742cdf0a35110145486578df","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ravendb/ravendb/pulls/1074/commits","review_comments_url":"https://api.github.com/repos/ravendb/ravendb/pulls/1074/comments","review_comment_url":"https://api.github.com/repos/ravendb/ravendb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ravendb/ravendb/issues/1074/comments","statuses_url":"https://api.github.com/repos/ravendb/ravendb/statuses/706a0b05478d69053d91e15c2d91210630315edc","head":{"label":"karmeli87:RavenDB-5656","ref":"RavenDB-5656","sha":"706a0b05478d69053d91e15c2d91210630315edc","user":{"login":"karmeli87","id":6377808,"avatar_url":"https://avatars.githubusercontent.com/u/6377808?v=3","gravatar_id":"","url":"https://api.github.com/users/karmeli87","html_url":"https://github.com/karmeli87","followers_url":"https://api.github.com/users/karmeli87/followers","following_url":"https://api.github.com/users/karmeli87/following{/other_user}","gists_url":"https://api.github.com/users/karmeli87/gists{/gist_id}","starred_url":"https://api.github.com/users/karmeli87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karmeli87/subscriptions","organizations_url":"https://api.github.com/users/karmeli87/orgs","repos_url":"https://api.github.com/users/karmeli87/repos","events_url":"https://api.github.com/users/karmeli87/events{/privacy}","received_events_url":"https://api.github.com/users/karmeli87/received_events","type":"User","site_admin":false},"repo":{"id":75198542,"name":"ravendb","full_name":"karmeli87/ravendb","owner":{"login":"karmeli87","id":6377808,"avatar_url":"https://avatars.githubusercontent.com/u/6377808?v=3","gravatar_id":"","url":"https://api.github.com/users/karmeli87","html_url":"https://github.com/karmeli87","followers_url":"https://api.github.com/users/karmeli87/followers","following_url":"https://api.github.com/users/karmeli87/following{/other_user}","gists_url":"https://api.github.com/users/karmeli87/gists{/gist_id}","starred_url":"https://api.github.com/users/karmeli87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karmeli87/subscriptions","organizations_url":"https://api.github.com/users/karmeli87/orgs","repos_url":"https://api.github.com/users/karmeli87/repos","events_url":"https://api.github.com/users/karmeli87/events{/privacy}","received_events_url":"https://api.github.com/users/karmeli87/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/karmeli87/ravendb","description":"A linq enabled document database for .NET","fork":true,"url":"https://api.github.com/repos/karmeli87/ravendb","forks_url":"https://api.github.com/repos/karmeli87/ravendb/forks","keys_url":"https://api.github.com/repos/karmeli87/ravendb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/karmeli87/ravendb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/karmeli87/ravendb/teams","hooks_url":"https://api.github.com/repos/karmeli87/ravendb/hooks","issue_events_url":"https://api.github.com/repos/karmeli87/ravendb/issues/events{/number}","events_url":"https://api.github.com/repos/karmeli87/ravendb/events","assignees_url":"https://api.github.com/repos/karmeli87/ravendb/assignees{/user}","branches_url":"https://api.github.com/repos/karmeli87/ravendb/branches{/branch}","tags_url":"https://api.github.com/repos/karmeli87/ravendb/tags","blobs_url":"https://api.github.com/repos/karmeli87/ravendb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/karmeli87/ravendb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/karmeli87/ravendb/git/refs{/sha}","trees_url":"https://api.github.com/repos/karmeli87/ravendb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/karmeli87/ravendb/statuses/{sha}","languages_url":"https://api.github.com/repos/karmeli87/ravendb/languages","stargazers_url":"https://api.github.com/repos/karmeli87/ravendb/stargazers","contributors_url":"https://api.github.com/repos/karmeli87/ravendb/contributors","subscribers_url":"https://api.github.com/repos/karmeli87/ravendb/subscribers","subscription_url":"https://api.github.com/repos/karmeli87/ravendb/subscription","commits_url":"https://api.github.com/repos/karmeli87/ravendb/commits{/sha}","git_commits_url":"https://api.github.com/repos/karmeli87/ravendb/git/commits{/sha}","comments_url":"https://api.github.com/repos/karmeli87/ravendb/comments{/number}","issue_comment_url":"https://api.github.com/repos/karmeli87/ravendb/issues/comments{/number}","contents_url":"https://api.github.com/repos/karmeli87/ravendb/contents/{+path}","compare_url":"https://api.github.com/repos/karmeli87/ravendb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/karmeli87/ravendb/merges","archive_url":"https://api.github.com/repos/karmeli87/ravendb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/karmeli87/ravendb/downloads","issues_url":"https://api.github.com/repos/karmeli87/ravendb/issues{/number}","pulls_url":"https://api.github.com/repos/karmeli87/ravendb/pulls{/number}","milestones_url":"https://api.github.com/repos/karmeli87/ravendb/milestones{/number}","notifications_url":"https://api.github.com/repos/karmeli87/ravendb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/karmeli87/ravendb/labels{/name}","releases_url":"https://api.github.com/repos/karmeli87/ravendb/releases{/id}","deployments_url":"https://api.github.com/repos/karmeli87/ravendb/deployments","created_at":"2016-11-30T15:10:57Z","updated_at":"2016-11-30T15:11:16Z","pushed_at":"2016-12-08T15:37:17Z","git_url":"git://github.com/karmeli87/ravendb.git","ssh_url":"git@github.com:karmeli87/ravendb.git","clone_url":"https://github.com/karmeli87/ravendb.git","svn_url":"https://github.com/karmeli87/ravendb","homepage":"http://ravendb.net","size":377788,"stargazers_count":0,"watchers_count":0,"language":"C#","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":"v3.5"}},"base":{"label":"ravendb:v4.0","ref":"v4.0","sha":"aa7357793db33eb6bd6996c36ef621f3b62faa62","user":{"login":"ravendb","id":213792,"avatar_url":"https://avatars.githubusercontent.com/u/213792?v=3","gravatar_id":"","url":"https://api.github.com/users/ravendb","html_url":"https://github.com/ravendb","followers_url":"https://api.github.com/users/ravendb/followers","following_url":"https://api.github.com/users/ravendb/following{/other_user}","gists_url":"https://api.github.com/users/ravendb/gists{/gist_id}","starred_url":"https://api.github.com/users/ravendb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ravendb/subscriptions","organizations_url":"https://api.github.com/users/ravendb/orgs","repos_url":"https://api.github.com/users/ravendb/repos","events_url":"https://api.github.com/users/ravendb/events{/privacy}","received_events_url":"https://api.github.com/users/ravendb/received_events","type":"Organization","site_admin":false},"repo":{"id":542714,"name":"ravendb","full_name":"ravendb/ravendb","owner":{"login":"ravendb","id":213792,"avatar_url":"https://avatars.githubusercontent.com/u/213792?v=3","gravatar_id":"","url":"https://api.github.com/users/ravendb","html_url":"https://github.com/ravendb","followers_url":"https://api.github.com/users/ravendb/followers","following_url":"https://api.github.com/users/ravendb/following{/other_user}","gists_url":"https://api.github.com/users/ravendb/gists{/gist_id}","starred_url":"https://api.github.com/users/ravendb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ravendb/subscriptions","organizations_url":"https://api.github.com/users/ravendb/orgs","repos_url":"https://api.github.com/users/ravendb/repos","events_url":"https://api.github.com/users/ravendb/events{/privacy}","received_events_url":"https://api.github.com/users/ravendb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ravendb/ravendb","description":"A linq enabled document database for .NET","fork":false,"url":"https://api.github.com/repos/ravendb/ravendb","forks_url":"https://api.github.com/repos/ravendb/ravendb/forks","keys_url":"https://api.github.com/repos/ravendb/ravendb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ravendb/ravendb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ravendb/ravendb/teams","hooks_url":"https://api.github.com/repos/ravendb/ravendb/hooks","issue_events_url":"https://api.github.com/repos/ravendb/ravendb/issues/events{/number}","events_url":"https://api.github.com/repos/ravendb/ravendb/events","assignees_url":"https://api.github.com/repos/ravendb/ravendb/assignees{/user}","branches_url":"https://api.github.com/repos/ravendb/ravendb/branches{/branch}","tags_url":"https://api.github.com/repos/ravendb/ravendb/tags","blobs_url":"https://api.github.com/repos/ravendb/ravendb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ravendb/ravendb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ravendb/ravendb/git/refs{/sha}","trees_url":"https://api.github.com/repos/ravendb/ravendb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ravendb/ravendb/statuses/{sha}","languages_url":"https://api.github.com/repos/ravendb/ravendb/languages","stargazers_url":"https://api.github.com/repos/ravendb/ravendb/stargazers","contributors_url":"https://api.github.com/repos/ravendb/ravendb/contributors","subscribers_url":"https://api.github.com/repos/ravendb/ravendb/subscribers","subscription_url":"https://api.github.com/repos/ravendb/ravendb/subscription","commits_url":"https://api.github.com/repos/ravendb/ravendb/commits{/sha}","git_commits_url":"https://api.github.com/repos/ravendb/ravendb/git/commits{/sha}","comments_url":"https://api.github.com/repos/ravendb/ravendb/comments{/number}","issue_comment_url":"https://api.github.com/repos/ravendb/ravendb/issues/comments{/number}","contents_url":"https://api.github.com/repos/ravendb/ravendb/contents/{+path}","compare_url":"https://api.github.com/repos/ravendb/ravendb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ravendb/ravendb/merges","archive_url":"https://api.github.com/repos/ravendb/ravendb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ravendb/ravendb/downloads","issues_url":"https://api.github.com/repos/ravendb/ravendb/issues{/number}","pulls_url":"https://api.github.com/repos/ravendb/ravendb/pulls{/number}","milestones_url":"https://api.github.com/repos/ravendb/ravendb/milestones{/number}","notifications_url":"https://api.github.com/repos/ravendb/ravendb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ravendb/ravendb/labels{/name}","releases_url":"https://api.github.com/repos/ravendb/ravendb/releases{/id}","deployments_url":"https://api.github.com/repos/ravendb/ravendb/deployments","created_at":"2010-03-02T11:05:30Z","updated_at":"2016-12-07T19:09:46Z","pushed_at":"2016-12-08T15:38:14Z","git_url":"git://github.com/ravendb/ravendb.git","ssh_url":"git@github.com:ravendb/ravendb.git","clone_url":"https://github.com/ravendb/ravendb.git","svn_url":"https://github.com/ravendb/ravendb","homepage":"http://ravendb.net","size":437334,"stargazers_count":1597,"watchers_count":1597,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":640,"mirror_url":null,"open_issues_count":9,"forks":640,"open_issues":9,"watchers":1597,"default_branch":"v3.5"}},"_links":{"self":{"href":"https://api.github.com/repos/ravendb/ravendb/pulls/1074"},"html":{"href":"https://github.com/ravendb/ravendb/pull/1074"},"issue":{"href":"https://api.github.com/repos/ravendb/ravendb/issues/1074"},"comments":{"href":"https://api.github.com/repos/ravendb/ravendb/issues/1074/comments"},"review_comments":{"href":"https://api.github.com/repos/ravendb/ravendb/pulls/1074/comments"},"review_comment":{"href":"https://api.github.com/repos/ravendb/ravendb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ravendb/ravendb/pulls/1074/commits"},"statuses":{"href":"https://api.github.com/repos/ravendb/ravendb/statuses/706a0b05478d69053d91e15c2d91210630315edc"}}}}
{"actor":{"display_login":"ayende"}}