{"action":"created","comment":{"url":"https://api.github.com/repos/gabime/spdlog/pulls/comments/39384412","id":39384412,"diff_hunk":"@@ -0,0 +1,101 @@\n+/*************************************************************************/\n+/* spdlog - an extremely fast and easy to use c++11 logging library.     */\n+/* Copyright (c) 2014 Gabi Melman.                                       */\n+/* Copyright (c) 2015 Ruslan Baratov.                                    */\n+/*                                                                       */\n+/* Permission is hereby granted, free of charge, to any person obtaining */\n+/* a copy of this software and associated documentation files (the       */\n+/* \"Software\"), to deal in the Software without restriction, including   */\n+/* without limitation the rights to use, copy, modify, merge, publish,   */\n+/* distribute, sublicense, and/or sell copies of the Software, and to    */\n+/* permit persons to whom the Software is furnished to do so, subject to */\n+/* the following conditions:                                             */\n+/*                                                                       */\n+/* The above copyright notice and this permission notice shall be        */\n+/* included in all copies or substantial portions of the Software.       */\n+/*                                                                       */\n+/* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,       */\n+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */\n+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/\n+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */\n+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */\n+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */\n+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */\n+/*************************************************************************/\n+\n+#pragma once\n+\n+#if defined(__ANDROID__)\n+\n+#include <mutex>\n+#include \"base_sink.h\"\n+#include \"../details/null_mutex.h\"\n+\n+#include <android/log.h>\n+\n+namespace spdlog\n+{\n+namespace sinks\n+{\n+/*\n+* Android sink (logging using __android_log_write)\n+*/\n+template<class Mutex>\n+class base_android_sink : public base_sink < Mutex >\n+{\n+public:\n+    explicit base_android_sink(std::string tag=\"spdlog\"): _tag(tag)\n+    {\n+    }\n+\n+    void flush() override\n+    {\n+    }\n+\n+protected:\n+    void _sink_it(const details::log_msg& msg) override\n+    {\n+        const android_LogPriority priority = convert_to_android(msg.level);\n+        const int expected_size = msg.formatted.size();\n+        const int size = __android_log_write(\n+            priority, _tag.c_str(), msg.formatted.c_str()\n+        );\n+        if (size > expected_size)\n+        {\n+            // Will write a little bit more than original message\n+        }\n+        else\n+        {\n+            throw spdlog_ex(\"Send to Android logcat failed\");\n+        }\n+    }\n+\n+private:\n+    static android_LogPriority convert_to_android(spdlog::level::level_enum level)\n+    {\n+        switch(level)\n+        {\n+            case spdlog::level::trace: return ANDROID_LOG_VERBOSE;\n+            case spdlog::level::debug: return ANDROID_LOG_DEBUG;\n+            case spdlog::level::info: return ANDROID_LOG_INFO;\n+            case spdlog::level::notice: return ANDROID_LOG_INFO;\n+            case spdlog::level::warn: return ANDROID_LOG_WARN;\n+            case spdlog::level::err: return ANDROID_LOG_ERROR;\n+            case spdlog::level::critical: return ANDROID_LOG_FATAL;\n+            case spdlog::level::alert: return ANDROID_LOG_FATAL;\n+            case spdlog::level::emerg: return ANDROID_LOG_FATAL;\n+            case spdlog::level::off: throw spdlog_ex(\"Unexpected off\");","path":"include/spdlog/sinks/android_sink.h","position":87,"original_position":87,"commit_id":"24a8cb07487b15b5f3da4cee03df9c119fd00f61","original_commit_id":"24a8cb07487b15b5f3da4cee03df9c119fd00f61","user":{"login":"ruslo","id":4346993,"avatar_url":"https://avatars.githubusercontent.com/u/4346993?v=3","gravatar_id":"","url":"https://api.github.com/users/ruslo","html_url":"https://github.com/ruslo","followers_url":"https://api.github.com/users/ruslo/followers","following_url":"https://api.github.com/users/ruslo/following{/other_user}","gists_url":"https://api.github.com/users/ruslo/gists{/gist_id}","starred_url":"https://api.github.com/users/ruslo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruslo/subscriptions","organizations_url":"https://api.github.com/users/ruslo/orgs","repos_url":"https://api.github.com/users/ruslo/repos","events_url":"https://api.github.com/users/ruslo/events{/privacy}","received_events_url":"https://api.github.com/users/ruslo/received_events","type":"User","site_admin":false},"body":"> Off means no logging. It should not throw, just ignore the log\r\n\r\nShould we return from `_sink_it` (i.e. `if (level == off) return`) or check `assert(level != off)`?","created_at":"2015-09-14T11:42:01Z","updated_at":"2015-09-14T11:42:01Z","html_url":"https://github.com/gabime/spdlog/pull/130#discussion_r39384412","pull_request_url":"https://api.github.com/repos/gabime/spdlog/pulls/130","_links":{"self":{"href":"https://api.github.com/repos/gabime/spdlog/pulls/comments/39384412"},"html":{"href":"https://github.com/gabime/spdlog/pull/130#discussion_r39384412"},"pull_request":{"href":"https://api.github.com/repos/gabime/spdlog/pulls/130"}}},"pull_request":{"url":"https://api.github.com/repos/gabime/spdlog/pulls/130","id":44724944,"html_url":"https://github.com/gabime/spdlog/pull/130","diff_url":"https://github.com/gabime/spdlog/pull/130.diff","patch_url":"https://github.com/gabime/spdlog/pull/130.patch","issue_url":"https://api.github.com/repos/gabime/spdlog/issues/130","number":130,"state":"open","locked":false,"title":"Add Android sink","user":{"login":"ruslo","id":4346993,"avatar_url":"https://avatars.githubusercontent.com/u/4346993?v=3","gravatar_id":"","url":"https://api.github.com/users/ruslo","html_url":"https://github.com/ruslo","followers_url":"https://api.github.com/users/ruslo/followers","following_url":"https://api.github.com/users/ruslo/following{/other_user}","gists_url":"https://api.github.com/users/ruslo/gists{/gist_id}","starred_url":"https://api.github.com/users/ruslo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruslo/subscriptions","organizations_url":"https://api.github.com/users/ruslo/orgs","repos_url":"https://api.github.com/users/ruslo/repos","events_url":"https://api.github.com/users/ruslo/events{/privacy}","received_events_url":"https://api.github.com/users/ruslo/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-10T22:01:21Z","updated_at":"2015-09-14T11:42:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a110d9fc6d85b18403626ba3ad4d8396f2fecd6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gabime/spdlog/pulls/130/commits","review_comments_url":"https://api.github.com/repos/gabime/spdlog/pulls/130/comments","review_comment_url":"https://api.github.com/repos/gabime/spdlog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gabime/spdlog/issues/130/comments","statuses_url":"https://api.github.com/repos/gabime/spdlog/statuses/24a8cb07487b15b5f3da4cee03df9c119fd00f61","head":{"label":"ruslo:android.sink","ref":"android.sink","sha":"24a8cb07487b15b5f3da4cee03df9c119fd00f61","user":{"login":"ruslo","id":4346993,"avatar_url":"https://avatars.githubusercontent.com/u/4346993?v=3","gravatar_id":"","url":"https://api.github.com/users/ruslo","html_url":"https://github.com/ruslo","followers_url":"https://api.github.com/users/ruslo/followers","following_url":"https://api.github.com/users/ruslo/following{/other_user}","gists_url":"https://api.github.com/users/ruslo/gists{/gist_id}","starred_url":"https://api.github.com/users/ruslo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruslo/subscriptions","organizations_url":"https://api.github.com/users/ruslo/orgs","repos_url":"https://api.github.com/users/ruslo/repos","events_url":"https://api.github.com/users/ruslo/events{/privacy}","received_events_url":"https://api.github.com/users/ruslo/received_events","type":"User","site_admin":false},"repo":{"id":42258241,"name":"spdlog","full_name":"ruslo/spdlog","owner":{"login":"ruslo","id":4346993,"avatar_url":"https://avatars.githubusercontent.com/u/4346993?v=3","gravatar_id":"","url":"https://api.github.com/users/ruslo","html_url":"https://github.com/ruslo","followers_url":"https://api.github.com/users/ruslo/followers","following_url":"https://api.github.com/users/ruslo/following{/other_user}","gists_url":"https://api.github.com/users/ruslo/gists{/gist_id}","starred_url":"https://api.github.com/users/ruslo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruslo/subscriptions","organizations_url":"https://api.github.com/users/ruslo/orgs","repos_url":"https://api.github.com/users/ruslo/repos","events_url":"https://api.github.com/users/ruslo/events{/privacy}","received_events_url":"https://api.github.com/users/ruslo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ruslo/spdlog","description":"Super fast C++ logging library.","fork":true,"url":"https://api.github.com/repos/ruslo/spdlog","forks_url":"https://api.github.com/repos/ruslo/spdlog/forks","keys_url":"https://api.github.com/repos/ruslo/spdlog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ruslo/spdlog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ruslo/spdlog/teams","hooks_url":"https://api.github.com/repos/ruslo/spdlog/hooks","issue_events_url":"https://api.github.com/repos/ruslo/spdlog/issues/events{/number}","events_url":"https://api.github.com/repos/ruslo/spdlog/events","assignees_url":"https://api.github.com/repos/ruslo/spdlog/assignees{/user}","branches_url":"https://api.github.com/repos/ruslo/spdlog/branches{/branch}","tags_url":"https://api.github.com/repos/ruslo/spdlog/tags","blobs_url":"https://api.github.com/repos/ruslo/spdlog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ruslo/spdlog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ruslo/spdlog/git/refs{/sha}","trees_url":"https://api.github.com/repos/ruslo/spdlog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ruslo/spdlog/statuses/{sha}","languages_url":"https://api.github.com/repos/ruslo/spdlog/languages","stargazers_url":"https://api.github.com/repos/ruslo/spdlog/stargazers","contributors_url":"https://api.github.com/repos/ruslo/spdlog/contributors","subscribers_url":"https://api.github.com/repos/ruslo/spdlog/subscribers","subscription_url":"https://api.github.com/repos/ruslo/spdlog/subscription","commits_url":"https://api.github.com/repos/ruslo/spdlog/commits{/sha}","git_commits_url":"https://api.github.com/repos/ruslo/spdlog/git/commits{/sha}","comments_url":"https://api.github.com/repos/ruslo/spdlog/comments{/number}","issue_comment_url":"https://api.github.com/repos/ruslo/spdlog/issues/comments{/number}","contents_url":"https://api.github.com/repos/ruslo/spdlog/contents/{+path}","compare_url":"https://api.github.com/repos/ruslo/spdlog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ruslo/spdlog/merges","archive_url":"https://api.github.com/repos/ruslo/spdlog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ruslo/spdlog/downloads","issues_url":"https://api.github.com/repos/ruslo/spdlog/issues{/number}","pulls_url":"https://api.github.com/repos/ruslo/spdlog/pulls{/number}","milestones_url":"https://api.github.com/repos/ruslo/spdlog/milestones{/number}","notifications_url":"https://api.github.com/repos/ruslo/spdlog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ruslo/spdlog/labels{/name}","releases_url":"https://api.github.com/repos/ruslo/spdlog/releases{/id}","created_at":"2015-09-10T17:00:24Z","updated_at":"2015-09-10T17:00:24Z","pushed_at":"2015-09-14T11:16:24Z","git_url":"git://github.com/ruslo/spdlog.git","ssh_url":"git@github.com:ruslo/spdlog.git","clone_url":"https://github.com/ruslo/spdlog.git","svn_url":"https://github.com/ruslo/spdlog","homepage":"","size":3710,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gabime:master","ref":"master","sha":"d28662db60d1a8977075025594f6e223b9524c29","user":{"login":"gabime","id":6052198,"avatar_url":"https://avatars.githubusercontent.com/u/6052198?v=3","gravatar_id":"","url":"https://api.github.com/users/gabime","html_url":"https://github.com/gabime","followers_url":"https://api.github.com/users/gabime/followers","following_url":"https://api.github.com/users/gabime/following{/other_user}","gists_url":"https://api.github.com/users/gabime/gists{/gist_id}","starred_url":"https://api.github.com/users/gabime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabime/subscriptions","organizations_url":"https://api.github.com/users/gabime/orgs","repos_url":"https://api.github.com/users/gabime/repos","events_url":"https://api.github.com/users/gabime/events{/privacy}","received_events_url":"https://api.github.com/users/gabime/received_events","type":"User","site_admin":false},"repo":{"id":26038648,"name":"spdlog","full_name":"gabime/spdlog","owner":{"login":"gabime","id":6052198,"avatar_url":"https://avatars.githubusercontent.com/u/6052198?v=3","gravatar_id":"","url":"https://api.github.com/users/gabime","html_url":"https://github.com/gabime","followers_url":"https://api.github.com/users/gabime/followers","following_url":"https://api.github.com/users/gabime/following{/other_user}","gists_url":"https://api.github.com/users/gabime/gists{/gist_id}","starred_url":"https://api.github.com/users/gabime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabime/subscriptions","organizations_url":"https://api.github.com/users/gabime/orgs","repos_url":"https://api.github.com/users/gabime/repos","events_url":"https://api.github.com/users/gabime/events{/privacy}","received_events_url":"https://api.github.com/users/gabime/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gabime/spdlog","description":"Super fast C++ logging library.","fork":false,"url":"https://api.github.com/repos/gabime/spdlog","forks_url":"https://api.github.com/repos/gabime/spdlog/forks","keys_url":"https://api.github.com/repos/gabime/spdlog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gabime/spdlog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gabime/spdlog/teams","hooks_url":"https://api.github.com/repos/gabime/spdlog/hooks","issue_events_url":"https://api.github.com/repos/gabime/spdlog/issues/events{/number}","events_url":"https://api.github.com/repos/gabime/spdlog/events","assignees_url":"https://api.github.com/repos/gabime/spdlog/assignees{/user}","branches_url":"https://api.github.com/repos/gabime/spdlog/branches{/branch}","tags_url":"https://api.github.com/repos/gabime/spdlog/tags","blobs_url":"https://api.github.com/repos/gabime/spdlog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gabime/spdlog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gabime/spdlog/git/refs{/sha}","trees_url":"https://api.github.com/repos/gabime/spdlog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gabime/spdlog/statuses/{sha}","languages_url":"https://api.github.com/repos/gabime/spdlog/languages","stargazers_url":"https://api.github.com/repos/gabime/spdlog/stargazers","contributors_url":"https://api.github.com/repos/gabime/spdlog/contributors","subscribers_url":"https://api.github.com/repos/gabime/spdlog/subscribers","subscription_url":"https://api.github.com/repos/gabime/spdlog/subscription","commits_url":"https://api.github.com/repos/gabime/spdlog/commits{/sha}","git_commits_url":"https://api.github.com/repos/gabime/spdlog/git/commits{/sha}","comments_url":"https://api.github.com/repos/gabime/spdlog/comments{/number}","issue_comment_url":"https://api.github.com/repos/gabime/spdlog/issues/comments{/number}","contents_url":"https://api.github.com/repos/gabime/spdlog/contents/{+path}","compare_url":"https://api.github.com/repos/gabime/spdlog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gabime/spdlog/merges","archive_url":"https://api.github.com/repos/gabime/spdlog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gabime/spdlog/downloads","issues_url":"https://api.github.com/repos/gabime/spdlog/issues{/number}","pulls_url":"https://api.github.com/repos/gabime/spdlog/pulls{/number}","milestones_url":"https://api.github.com/repos/gabime/spdlog/milestones{/number}","notifications_url":"https://api.github.com/repos/gabime/spdlog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gabime/spdlog/labels{/name}","releases_url":"https://api.github.com/repos/gabime/spdlog/releases{/id}","created_at":"2014-11-01T01:28:53Z","updated_at":"2015-09-14T08:24:27Z","pushed_at":"2015-09-10T22:01:21Z","git_url":"git://github.com/gabime/spdlog.git","ssh_url":"git@github.com:gabime/spdlog.git","clone_url":"https://github.com/gabime/spdlog.git","svn_url":"https://github.com/gabime/spdlog","homepage":"","size":3710,"stargazers_count":594,"watchers_count":594,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":130,"mirror_url":null,"open_issues_count":21,"forks":130,"open_issues":21,"watchers":594,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gabime/spdlog/pulls/130"},"html":{"href":"https://github.com/gabime/spdlog/pull/130"},"issue":{"href":"https://api.github.com/repos/gabime/spdlog/issues/130"},"comments":{"href":"https://api.github.com/repos/gabime/spdlog/issues/130/comments"},"review_comments":{"href":"https://api.github.com/repos/gabime/spdlog/pulls/130/comments"},"review_comment":{"href":"https://api.github.com/repos/gabime/spdlog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gabime/spdlog/pulls/130/commits"},"statuses":{"href":"https://api.github.com/repos/gabime/spdlog/statuses/24a8cb07487b15b5f3da4cee03df9c119fd00f61"}}}}