{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/31414250","id":31414250,"diff_hunk":"@@ -223,38 +265,35 @@ int LogPrintStr(const std::string &str)\n         ret = fwrite(str.data(), 1, str.size(), stdout);\n         fflush(stdout);\n     }\n-    else if (fPrintToDebugLog && AreBaseParamsConfigured())\n+    else if (fPrintToDebugLog)\n     {\n-        static bool fStartedNewLine = true;\n         boost::call_once(&DebugPrintInit, debugPrintInitFlag);\n-\n-        if (fileout == NULL)\n-            return ret;\n-\n         boost::mutex::scoped_lock scoped_lock(*mutexDebugLog);\n \n-        // reopen the log file, if requested\n-        if (fReopenDebugLog) {\n-            fReopenDebugLog = false;\n-            boost::filesystem::path pathDebug = GetDataDir() / \"debug.log\";\n-            if (freopen(pathDebug.string().c_str(),\"a\",fileout) != NULL)\n-                setbuf(fileout, NULL); // unbuffered\n-        }\n+        string strTimestamped = LogTimestampStr(str);\n \n-        // Debug print useful for profiling\n-        if (fLogTimestamps && fStartedNewLine)\n-            ret += fprintf(fileout, \"%s \", DateTimeStrFormat(\"%Y-%m-%d %H:%M:%S\", GetTime()).c_str());\n-        if (!str.empty() && str[str.size()-1] == '\\n')\n-            fStartedNewLine = true;\n+        // buffer if we haven't opened the log yet\n+        if (fileout == NULL) {\n+            ret = strTimestamped.length();","path":"src/util.cpp","position":108,"original_position":108,"commit_id":"cd5ef8342b855c5556ced2f25c560cb435b3a2cc","original_commit_id":"cd5ef8342b855c5556ced2f25c560cb435b3a2cc","user":{"login":"laanwj","id":126646,"avatar_url":"https://avatars.githubusercontent.com/u/126646?v=3","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"body":"Just to be sure: add assertion that vMsgsBeforeOpenLog is not null","created_at":"2015-06-01T10:25:11Z","updated_at":"2015-06-01T10:25:11Z","html_url":"https://github.com/bitcoin/bitcoin/pull/6149#discussion_r31414250","pull_request_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149","_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/31414250"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/6149#discussion_r31414250"},"pull_request":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149"}}},"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149","id":35562304,"html_url":"https://github.com/bitcoin/bitcoin/pull/6149","diff_url":"https://github.com/bitcoin/bitcoin/pull/6149.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/6149.patch","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6149","number":6149,"state":"open","locked":false,"title":"Buffer log messages and explicitly open logs","user":{"login":"ajweiss","id":430315,"avatar_url":"https://avatars.githubusercontent.com/u/430315?v=3","gravatar_id":"","url":"https://api.github.com/users/ajweiss","html_url":"https://github.com/ajweiss","followers_url":"https://api.github.com/users/ajweiss/followers","following_url":"https://api.github.com/users/ajweiss/following{/other_user}","gists_url":"https://api.github.com/users/ajweiss/gists{/gist_id}","starred_url":"https://api.github.com/users/ajweiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajweiss/subscriptions","organizations_url":"https://api.github.com/users/ajweiss/orgs","repos_url":"https://api.github.com/users/ajweiss/repos","events_url":"https://api.github.com/users/ajweiss/events{/privacy}","received_events_url":"https://api.github.com/users/ajweiss/received_events","type":"User","site_admin":false},"body":"Prevents stomping on debug logs in datadirs that are locked by other\r\ninstances and lost parameter interaction messages that can get wiped by\r\nShrinkDebugFile().\r\n\r\nThe log is now opened explicitly and all emitted messages are buffered\r\nuntil this open occurs.  The version message and log cut have also been\r\nmoved to the earliest possible sensible location to prevent messages from\r\nappearing \"before the cut.\"\r\n\r\nThanks @jgarzik for setting me on the right track.\r\n","created_at":"2015-05-16T00:53:17Z","updated_at":"2015-06-01T10:25:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1d8b96deaa8ce0b6f15d0970fe8eb0674aea8754","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149/commits","review_comments_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149/comments","review_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6149/comments","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/cd5ef8342b855c5556ced2f25c560cb435b3a2cc","head":{"label":"ajweiss:ajw_1505_early_log_buffer","ref":"ajw_1505_early_log_buffer","sha":"cd5ef8342b855c5556ced2f25c560cb435b3a2cc","user":{"login":"ajweiss","id":430315,"avatar_url":"https://avatars.githubusercontent.com/u/430315?v=3","gravatar_id":"","url":"https://api.github.com/users/ajweiss","html_url":"https://github.com/ajweiss","followers_url":"https://api.github.com/users/ajweiss/followers","following_url":"https://api.github.com/users/ajweiss/following{/other_user}","gists_url":"https://api.github.com/users/ajweiss/gists{/gist_id}","starred_url":"https://api.github.com/users/ajweiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajweiss/subscriptions","organizations_url":"https://api.github.com/users/ajweiss/orgs","repos_url":"https://api.github.com/users/ajweiss/repos","events_url":"https://api.github.com/users/ajweiss/events{/privacy}","received_events_url":"https://api.github.com/users/ajweiss/received_events","type":"User","site_admin":false},"repo":{"id":19507426,"name":"bitcoin","full_name":"ajweiss/bitcoin","owner":{"login":"ajweiss","id":430315,"avatar_url":"https://avatars.githubusercontent.com/u/430315?v=3","gravatar_id":"","url":"https://api.github.com/users/ajweiss","html_url":"https://github.com/ajweiss","followers_url":"https://api.github.com/users/ajweiss/followers","following_url":"https://api.github.com/users/ajweiss/following{/other_user}","gists_url":"https://api.github.com/users/ajweiss/gists{/gist_id}","starred_url":"https://api.github.com/users/ajweiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajweiss/subscriptions","organizations_url":"https://api.github.com/users/ajweiss/orgs","repos_url":"https://api.github.com/users/ajweiss/repos","events_url":"https://api.github.com/users/ajweiss/events{/privacy}","received_events_url":"https://api.github.com/users/ajweiss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ajweiss/bitcoin","description":"Bitcoin Core integration/staging tree","fork":true,"url":"https://api.github.com/repos/ajweiss/bitcoin","forks_url":"https://api.github.com/repos/ajweiss/bitcoin/forks","keys_url":"https://api.github.com/repos/ajweiss/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ajweiss/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ajweiss/bitcoin/teams","hooks_url":"https://api.github.com/repos/ajweiss/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/ajweiss/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/ajweiss/bitcoin/events","assignees_url":"https://api.github.com/repos/ajweiss/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/ajweiss/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/ajweiss/bitcoin/tags","blobs_url":"https://api.github.com/repos/ajweiss/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ajweiss/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ajweiss/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/ajweiss/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ajweiss/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/ajweiss/bitcoin/languages","stargazers_url":"https://api.github.com/repos/ajweiss/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/ajweiss/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/ajweiss/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/ajweiss/bitcoin/subscription","commits_url":"https://api.github.com/repos/ajweiss/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/ajweiss/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/ajweiss/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/ajweiss/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/ajweiss/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/ajweiss/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ajweiss/bitcoin/merges","archive_url":"https://api.github.com/repos/ajweiss/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ajweiss/bitcoin/downloads","issues_url":"https://api.github.com/repos/ajweiss/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/ajweiss/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/ajweiss/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/ajweiss/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ajweiss/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/ajweiss/bitcoin/releases{/id}","created_at":"2014-05-06T19:20:03Z","updated_at":"2015-02-09T21:45:58Z","pushed_at":"2015-05-22T18:16:38Z","git_url":"git://github.com/ajweiss/bitcoin.git","ssh_url":"git@github.com:ajweiss/bitcoin.git","clone_url":"https://github.com/ajweiss/bitcoin.git","svn_url":"https://github.com/ajweiss/bitcoin","homepage":"https://bitcoin.org/en/download","size":47599,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":false,"has_wiki":false,"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":"bitcoin:master","ref":"master","sha":"be31ff7d8ddb86d4499c7619ac2ec3a59434a596","user":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars.githubusercontent.com/u/528860?v=3","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"repo":{"id":1181927,"name":"bitcoin","full_name":"bitcoin/bitcoin","owner":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars.githubusercontent.com/u/528860?v=3","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bitcoin/bitcoin","description":"Bitcoin Core integration/staging tree","fork":false,"url":"https://api.github.com/repos/bitcoin/bitcoin","forks_url":"https://api.github.com/repos/bitcoin/bitcoin/forks","keys_url":"https://api.github.com/repos/bitcoin/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitcoin/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitcoin/bitcoin/teams","hooks_url":"https://api.github.com/repos/bitcoin/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/bitcoin/bitcoin/events","assignees_url":"https://api.github.com/repos/bitcoin/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/bitcoin/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/bitcoin/bitcoin/tags","blobs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitcoin/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitcoin/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/bitcoin/bitcoin/languages","stargazers_url":"https://api.github.com/repos/bitcoin/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/bitcoin/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/bitcoin/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/bitcoin/bitcoin/subscription","commits_url":"https://api.github.com/repos/bitcoin/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitcoin/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitcoin/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/bitcoin/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitcoin/bitcoin/merges","archive_url":"https://api.github.com/repos/bitcoin/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitcoin/bitcoin/downloads","issues_url":"https://api.github.com/repos/bitcoin/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/bitcoin/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/bitcoin/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/bitcoin/bitcoin/releases{/id}","created_at":"2010-12-19T15:16:43Z","updated_at":"2015-06-01T09:58:09Z","pushed_at":"2015-06-01T09:49:37Z","git_url":"git://github.com/bitcoin/bitcoin.git","ssh_url":"git@github.com:bitcoin/bitcoin.git","clone_url":"https://github.com/bitcoin/bitcoin.git","svn_url":"https://github.com/bitcoin/bitcoin","homepage":"https://bitcoin.org/en/download","size":130409,"stargazers_count":6945,"watchers_count":6945,"language":"C++","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4850,"mirror_url":null,"open_issues_count":420,"forks":4850,"open_issues":420,"watchers":6945,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/6149"},"issue":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/6149"},"comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/6149/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6149/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin/bitcoin/statuses/cd5ef8342b855c5556ced2f25c560cb435b3a2cc"}}}}