{"action":"created","comment":{"url":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/comments/27777405","id":27777405,"diff_hunk":"@@ -0,0 +1,182 @@\n+#ifndef __Maszyna_Diagnostics_Trace_hxx__\n+#define __Maszyna_Diagnostics_Trace_hxx__\n+\n+#include <cstdint>\n+\n+namespace Maszyna\n+{\n+namespace Diagnostics\n+{\n+    namespace TraceLevel\n+    {\n+        enum Enum\n+        {\n+            Disabled,\n+            Debug,\n+            Normal,\n+            Warning,\n+            Error,\n+            Critical\n+        };\n+\n+        //\n+        // Converts trace-level to string.\n+        //\n+        inline const char* ToString(TraceLevel::Enum value)\n+        {\n+            switch (value)\n+            {\n+            case TraceLevel::Disabled:\n+                return \"Disabled\";\n+            case TraceLevel::Debug:\n+                return \"Debug\";\n+            case TraceLevel::Normal:\n+                return \"Normal\";\n+            case TraceLevel::Warning:\n+                return \"Warning\";\n+            case TraceLevel::Error:\n+                return \"Error\";\n+            case TraceLevel::Critical:\n+                return \"Critical\";\n+            default:\n+                return \"Unknown\";\n+            }\n+        }\n+    }\n+\n+    class Trace final\n+    {\n+    public:\n+        static bool Initialize(const char* filename);\n+        static bool Shutdown();\n+\n+    public:\n+        static void Fail();\n+        static void Fail(const char* message);\n+        static void Fail(const char* message, const char* details);\n+        // Unconditionally dispatches message.\n+        static bool Dispatch(TraceLevel::Enum level, const char* category, const char* format, ...);\n+        // Called by macros, to check whether need to emit Dispatch call (along with built call frame).\n+        static bool CanDispatch(TraceLevel::Enum level);\n+        static void SetLevel(TraceLevel::Enum level);\n+\n+    private:\n+        static TraceLevel::Enum _trace_level;\n+    };\n+\n+    inline bool Trace::CanDispatch(TraceLevel::Enum level)\n+    {\n+        return static_cast<uintptr_t>(level) < static_cast<uintptr_t>(_trace_level);\n+    }\n+\n+    inline void Trace::SetLevel(TraceLevel::Enum level)\n+    {\n+        _trace_level = level;\n+    }\n+\n+    // Base for trace switches.\n+    struct TraceSwitchBase\n+    {\n+    private:\n+        const char* _name;\n+        TraceLevel::Enum _level;\n+        TraceLevel::Enum _compileTimeLevel;\n+\n+    public:\n+        TraceSwitchBase(const char* name, TraceLevel::Enum defaultLevel, TraceLevel::Enum compileTimeLevel)\n+            : _name(name)\n+            , _level(defaultLevel)\n+            , _compileTimeLevel(compileTimeLevel)\n+        {\n+        }\n+\n+    public:\n+        inline const char* GetName() const\n+        {\n+            return _name;\n+        }\n+\n+        inline bool CanDispatch(TraceLevel::Enum level) const\n+        {\n+            return level <= _level;","path":"client/include/Maszyna.Diagnostics/Trace.hxx","position":101,"original_position":101,"commit_id":"dcdd0c7a5d32d059a5c7b8ed5e7eeb5c78c41ab7","original_commit_id":"dcdd0c7a5d32d059a5c7b8ed5e7eeb5c78c41ab7","user":{"login":"shaxbee","id":5236349,"avatar_url":"https://avatars.githubusercontent.com/u/5236349?v=3","gravatar_id":"","url":"https://api.github.com/users/shaxbee","html_url":"https://github.com/shaxbee","followers_url":"https://api.github.com/users/shaxbee/followers","following_url":"https://api.github.com/users/shaxbee/following{/other_user}","gists_url":"https://api.github.com/users/shaxbee/gists{/gist_id}","starred_url":"https://api.github.com/users/shaxbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaxbee/subscriptions","organizations_url":"https://api.github.com/users/shaxbee/orgs","repos_url":"https://api.github.com/users/shaxbee/repos","events_url":"https://api.github.com/users/shaxbee/events{/privacy}","received_events_url":"https://api.github.com/users/shaxbee/received_events","type":"User","site_admin":false},"body":"static_cast ?","created_at":"2015-04-05T13:46:35Z","updated_at":"2015-04-05T13:46:35Z","html_url":"https://github.com/shaxbee/maszyna-client/pull/2#discussion_r27777405","pull_request_url":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/comments/27777405"},"html":{"href":"https://github.com/shaxbee/maszyna-client/pull/2#discussion_r27777405"},"pull_request":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2","id":32647924,"html_url":"https://github.com/shaxbee/maszyna-client/pull/2","diff_url":"https://github.com/shaxbee/maszyna-client/pull/2.diff","patch_url":"https://github.com/shaxbee/maszyna-client/pull/2.patch","issue_url":"https://api.github.com/repos/shaxbee/maszyna-client/issues/2","number":2,"state":"open","locked":false,"title":"Trace and TraceSwitch functionality proposal","user":{"login":"KarolGrzybowski89","id":1857146,"avatar_url":"https://avatars.githubusercontent.com/u/1857146?v=3","gravatar_id":"","url":"https://api.github.com/users/KarolGrzybowski89","html_url":"https://github.com/KarolGrzybowski89","followers_url":"https://api.github.com/users/KarolGrzybowski89/followers","following_url":"https://api.github.com/users/KarolGrzybowski89/following{/other_user}","gists_url":"https://api.github.com/users/KarolGrzybowski89/gists{/gist_id}","starred_url":"https://api.github.com/users/KarolGrzybowski89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KarolGrzybowski89/subscriptions","organizations_url":"https://api.github.com/users/KarolGrzybowski89/orgs","repos_url":"https://api.github.com/users/KarolGrzybowski89/repos","events_url":"https://api.github.com/users/KarolGrzybowski89/events{/privacy}","received_events_url":"https://api.github.com/users/KarolGrzybowski89/received_events","type":"User","site_admin":false},"body":"I've added Trace and TraceSwitch proposal. It allows to declare many\r\ntrace switches, which allows to filter-out trace messages by type. Also,\r\nI've slightly updated CMakeLists.txt to group files. Folder structure is\r\nbased on Graphyte Engine and resembles .NET framework. Also, physical\r\nfiles structure matches at C++ namespaces.","created_at":"2015-04-05T12:16:30Z","updated_at":"2015-04-05T13:46:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b24c8f2cbd56cbf61167a2abbdf8016ee8dfd216","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2/commits","review_comments_url":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2/comments","review_comment_url":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shaxbee/maszyna-client/issues/2/comments","statuses_url":"https://api.github.com/repos/shaxbee/maszyna-client/statuses/dcdd0c7a5d32d059a5c7b8ed5e7eeb5c78c41ab7","head":{"label":"KarolGrzybowski89:master","ref":"master","sha":"dcdd0c7a5d32d059a5c7b8ed5e7eeb5c78c41ab7","user":{"login":"KarolGrzybowski89","id":1857146,"avatar_url":"https://avatars.githubusercontent.com/u/1857146?v=3","gravatar_id":"","url":"https://api.github.com/users/KarolGrzybowski89","html_url":"https://github.com/KarolGrzybowski89","followers_url":"https://api.github.com/users/KarolGrzybowski89/followers","following_url":"https://api.github.com/users/KarolGrzybowski89/following{/other_user}","gists_url":"https://api.github.com/users/KarolGrzybowski89/gists{/gist_id}","starred_url":"https://api.github.com/users/KarolGrzybowski89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KarolGrzybowski89/subscriptions","organizations_url":"https://api.github.com/users/KarolGrzybowski89/orgs","repos_url":"https://api.github.com/users/KarolGrzybowski89/repos","events_url":"https://api.github.com/users/KarolGrzybowski89/events{/privacy}","received_events_url":"https://api.github.com/users/KarolGrzybowski89/received_events","type":"User","site_admin":false},"repo":{"id":33437858,"name":"maszyna-client","full_name":"KarolGrzybowski89/maszyna-client","owner":{"login":"KarolGrzybowski89","id":1857146,"avatar_url":"https://avatars.githubusercontent.com/u/1857146?v=3","gravatar_id":"","url":"https://api.github.com/users/KarolGrzybowski89","html_url":"https://github.com/KarolGrzybowski89","followers_url":"https://api.github.com/users/KarolGrzybowski89/followers","following_url":"https://api.github.com/users/KarolGrzybowski89/following{/other_user}","gists_url":"https://api.github.com/users/KarolGrzybowski89/gists{/gist_id}","starred_url":"https://api.github.com/users/KarolGrzybowski89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KarolGrzybowski89/subscriptions","organizations_url":"https://api.github.com/users/KarolGrzybowski89/orgs","repos_url":"https://api.github.com/users/KarolGrzybowski89/repos","events_url":"https://api.github.com/users/KarolGrzybowski89/events{/privacy}","received_events_url":"https://api.github.com/users/KarolGrzybowski89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KarolGrzybowski89/maszyna-client","description":"","fork":true,"url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client","forks_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/forks","keys_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/teams","hooks_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/hooks","issue_events_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/issues/events{/number}","events_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/events","assignees_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/assignees{/user}","branches_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/branches{/branch}","tags_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/tags","blobs_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/statuses/{sha}","languages_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/languages","stargazers_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/stargazers","contributors_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/contributors","subscribers_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/subscribers","subscription_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/subscription","commits_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/contents/{+path}","compare_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/merges","archive_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/downloads","issues_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/issues{/number}","pulls_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/pulls{/number}","milestones_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/milestones{/number}","notifications_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/labels{/name}","releases_url":"https://api.github.com/repos/KarolGrzybowski89/maszyna-client/releases{/id}","created_at":"2015-04-05T10:40:35Z","updated_at":"2015-04-05T12:19:10Z","pushed_at":"2015-04-05T12:19:09Z","git_url":"git://github.com/KarolGrzybowski89/maszyna-client.git","ssh_url":"git@github.com:KarolGrzybowski89/maszyna-client.git","clone_url":"https://github.com/KarolGrzybowski89/maszyna-client.git","svn_url":"https://github.com/KarolGrzybowski89/maszyna-client","homepage":null,"size":2964,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"shaxbee:master","ref":"master","sha":"4dc2335ea3e4ec7cf9a6ad9b3ea1a7f3237f2eb3","user":{"login":"shaxbee","id":5236349,"avatar_url":"https://avatars.githubusercontent.com/u/5236349?v=3","gravatar_id":"","url":"https://api.github.com/users/shaxbee","html_url":"https://github.com/shaxbee","followers_url":"https://api.github.com/users/shaxbee/followers","following_url":"https://api.github.com/users/shaxbee/following{/other_user}","gists_url":"https://api.github.com/users/shaxbee/gists{/gist_id}","starred_url":"https://api.github.com/users/shaxbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaxbee/subscriptions","organizations_url":"https://api.github.com/users/shaxbee/orgs","repos_url":"https://api.github.com/users/shaxbee/repos","events_url":"https://api.github.com/users/shaxbee/events{/privacy}","received_events_url":"https://api.github.com/users/shaxbee/received_events","type":"User","site_admin":false},"repo":{"id":24023296,"name":"maszyna-client","full_name":"shaxbee/maszyna-client","owner":{"login":"shaxbee","id":5236349,"avatar_url":"https://avatars.githubusercontent.com/u/5236349?v=3","gravatar_id":"","url":"https://api.github.com/users/shaxbee","html_url":"https://github.com/shaxbee","followers_url":"https://api.github.com/users/shaxbee/followers","following_url":"https://api.github.com/users/shaxbee/following{/other_user}","gists_url":"https://api.github.com/users/shaxbee/gists{/gist_id}","starred_url":"https://api.github.com/users/shaxbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaxbee/subscriptions","organizations_url":"https://api.github.com/users/shaxbee/orgs","repos_url":"https://api.github.com/users/shaxbee/repos","events_url":"https://api.github.com/users/shaxbee/events{/privacy}","received_events_url":"https://api.github.com/users/shaxbee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shaxbee/maszyna-client","description":"","fork":false,"url":"https://api.github.com/repos/shaxbee/maszyna-client","forks_url":"https://api.github.com/repos/shaxbee/maszyna-client/forks","keys_url":"https://api.github.com/repos/shaxbee/maszyna-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shaxbee/maszyna-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shaxbee/maszyna-client/teams","hooks_url":"https://api.github.com/repos/shaxbee/maszyna-client/hooks","issue_events_url":"https://api.github.com/repos/shaxbee/maszyna-client/issues/events{/number}","events_url":"https://api.github.com/repos/shaxbee/maszyna-client/events","assignees_url":"https://api.github.com/repos/shaxbee/maszyna-client/assignees{/user}","branches_url":"https://api.github.com/repos/shaxbee/maszyna-client/branches{/branch}","tags_url":"https://api.github.com/repos/shaxbee/maszyna-client/tags","blobs_url":"https://api.github.com/repos/shaxbee/maszyna-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shaxbee/maszyna-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shaxbee/maszyna-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/shaxbee/maszyna-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shaxbee/maszyna-client/statuses/{sha}","languages_url":"https://api.github.com/repos/shaxbee/maszyna-client/languages","stargazers_url":"https://api.github.com/repos/shaxbee/maszyna-client/stargazers","contributors_url":"https://api.github.com/repos/shaxbee/maszyna-client/contributors","subscribers_url":"https://api.github.com/repos/shaxbee/maszyna-client/subscribers","subscription_url":"https://api.github.com/repos/shaxbee/maszyna-client/subscription","commits_url":"https://api.github.com/repos/shaxbee/maszyna-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/shaxbee/maszyna-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/shaxbee/maszyna-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/shaxbee/maszyna-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/shaxbee/maszyna-client/contents/{+path}","compare_url":"https://api.github.com/repos/shaxbee/maszyna-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shaxbee/maszyna-client/merges","archive_url":"https://api.github.com/repos/shaxbee/maszyna-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shaxbee/maszyna-client/downloads","issues_url":"https://api.github.com/repos/shaxbee/maszyna-client/issues{/number}","pulls_url":"https://api.github.com/repos/shaxbee/maszyna-client/pulls{/number}","milestones_url":"https://api.github.com/repos/shaxbee/maszyna-client/milestones{/number}","notifications_url":"https://api.github.com/repos/shaxbee/maszyna-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shaxbee/maszyna-client/labels{/name}","releases_url":"https://api.github.com/repos/shaxbee/maszyna-client/releases{/id}","created_at":"2014-09-14T14:04:12Z","updated_at":"2015-03-30T07:42:15Z","pushed_at":"2015-04-05T12:19:10Z","git_url":"git://github.com/shaxbee/maszyna-client.git","ssh_url":"git@github.com:shaxbee/maszyna-client.git","clone_url":"https://github.com/shaxbee/maszyna-client.git","svn_url":"https://github.com/shaxbee/maszyna-client","homepage":null,"size":2964,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2"},"html":{"href":"https://github.com/shaxbee/maszyna-client/pull/2"},"issue":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/issues/2"},"comments":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/shaxbee/maszyna-client/statuses/dcdd0c7a5d32d059a5c7b8ed5e7eeb5c78c41ab7"}}}}