{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/IISIntegration/pulls/comments/191611591","pull_request_review_id":124214808,"id":191611591,"diff_hunk":"@@ -0,0 +1,155 @@\n+// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the MIT License. See License.txt in the project root for license information.\n+\n+#include \"stdafx.h\"\n+\n+FileOutputManager::~FileOutputManager()\n+{\n+    HANDLE   handle = NULL;\n+    WIN32_FIND_DATA fileData;\n+\n+    if (m_hLogFileHandle != INVALID_HANDLE_VALUE)\n+    {\n+        m_Timer.CancelTimer();\n+        CloseHandle(m_hLogFileHandle);\n+        m_hLogFileHandle = INVALID_HANDLE_VALUE;\n+    }\n+\n+    // delete empty log file\n+    handle = FindFirstFile(m_struLogFilePath.QueryStr(), &fileData);\n+    if (handle != INVALID_HANDLE_VALUE &&\n+        fileData.nFileSizeHigh == 0 &&\n+        fileData.nFileSizeLow == 0) // skip check of nFileSizeHigh\n+    {\n+        FindClose(handle);\n+        // no need to check whether the deletion succeeds\n+        // as nothing can be done\n+        DeleteFile(m_struLogFilePath.QueryStr());\n+    }\n+\n+    // this fails with an invalid handle\n+    _dup2(m_fdStdOut, _fileno(stdout));\n+    _dup2(m_fdStdErr, _fileno(stderr));\n+}\n+\n+void FileOutputManager::NotifyStartupComplete()\n+{\n+}\n+\n+bool FileOutputManager::GetStdOutContent(STRU* struStdOutput)\n+{\n+    //\n+    // Ungraceful shutdown, try to log an error message.\n+    // This will be a common place for errors as it means the hostfxr_main returned\n+    // or there was an exception.\n+    //\n+    CHAR            pzFileContents[4096] = { 0 };\n+    DWORD           dwNumBytesRead;\n+    LARGE_INTEGER   li = { 0 };\n+    BOOL            fLogged = FALSE;\n+    DWORD           dwFilePointer = 0;\n+\n+    if (m_hLogFileHandle != INVALID_HANDLE_VALUE)\n+    {\n+        if (GetFileSizeEx(m_hLogFileHandle, &li) && li.LowPart > 0 && li.HighPart == 0)\n+        {\n+            if (li.LowPart > 4096)\n+            {\n+                dwFilePointer = SetFilePointer(m_hLogFileHandle, -4096, NULL, FILE_END);\n+            }\n+            else\n+            {\n+                dwFilePointer = SetFilePointer(m_hLogFileHandle, 0, NULL, FILE_BEGIN);\n+            }\n+\n+            if (dwFilePointer != INVALID_SET_FILE_POINTER)\n+            {\n+                // Read file fails.\n+                if (ReadFile(m_hLogFileHandle, pzFileContents, 4096, &dwNumBytesRead, NULL))\n+                {\n+                    if (SUCCEEDED(struStdOutput->CopyA(pzFileContents, dwNumBytesRead)))\n+                    {\n+                        fLogged = TRUE;\n+                    }\n+                }\n+            }\n+        }\n+    }\n+\n+    return fLogged;\n+}\n+\n+FileOutputManager::FileOutputManager(PCWSTR pwzStdOutLogFileName, PCWSTR pwzApplicationPath)\n+    : m_hLogFileHandle(INVALID_HANDLE_VALUE)\n+{\n+    m_wsApplicationPath = std::wstring(pwzApplicationPath);","path":"src/AspNetCoreModuleV2/CommonLib/FileOutputManager.cpp","position":85,"original_position":85,"commit_id":"61e866ce312eb764cc5d66db6013a5bfb893b913","original_commit_id":"61e866ce312eb764cc5d66db6013a5bfb893b913","user":{"login":"jkotalik","id":8302101,"avatar_url":"https://avatars0.githubusercontent.com/u/8302101?v=4","gravatar_id":"","url":"https://api.github.com/users/jkotalik","html_url":"https://github.com/jkotalik","followers_url":"https://api.github.com/users/jkotalik/followers","following_url":"https://api.github.com/users/jkotalik/following{/other_user}","gists_url":"https://api.github.com/users/jkotalik/gists{/gist_id}","starred_url":"https://api.github.com/users/jkotalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkotalik/subscriptions","organizations_url":"https://api.github.com/users/jkotalik/orgs","repos_url":"https://api.github.com/users/jkotalik/repos","events_url":"https://api.github.com/users/jkotalik/events{/privacy}","received_events_url":"https://api.github.com/users/jkotalik/received_events","type":"User","site_admin":false},"body":"Why? I don't see what is wrong with throwing in a constructor.","created_at":"2018-05-30T00:12:58Z","updated_at":"2018-05-30T00:12:58Z","html_url":"https://github.com/aspnet/IISIntegration/pull/858#discussion_r191611591","pull_request_url":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/aspnet/IISIntegration/pulls/comments/191611591"},"html":{"href":"https://github.com/aspnet/IISIntegration/pull/858#discussion_r191611591"},"pull_request":{"href":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858"}},"in_reply_to_id":191600355},"pull_request":{"url":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858","id":190364580,"html_url":"https://github.com/aspnet/IISIntegration/pull/858","diff_url":"https://github.com/aspnet/IISIntegration/pull/858.diff","patch_url":"https://github.com/aspnet/IISIntegration/pull/858.patch","issue_url":"https://api.github.com/repos/aspnet/IISIntegration/issues/858","number":858,"state":"open","locked":false,"title":"Improve logging architecture; add tests for logging and startup exceptions","user":{"login":"jkotalik","id":8302101,"avatar_url":"https://avatars0.githubusercontent.com/u/8302101?v=4","gravatar_id":"","url":"https://api.github.com/users/jkotalik","html_url":"https://github.com/jkotalik","followers_url":"https://api.github.com/users/jkotalik/followers","following_url":"https://api.github.com/users/jkotalik/following{/other_user}","gists_url":"https://api.github.com/users/jkotalik/gists{/gist_id}","starred_url":"https://api.github.com/users/jkotalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkotalik/subscriptions","organizations_url":"https://api.github.com/users/jkotalik/orgs","repos_url":"https://api.github.com/users/jkotalik/repos","events_url":"https://api.github.com/users/jkotalik/events{/privacy}","received_events_url":"https://api.github.com/users/jkotalik/received_events","type":"User","site_admin":false},"body":"Adds native and managed tests. Refactors stdout redirection into separate classes to managed their lifetime better and test them.\r\n\r\nI changed the file logger to call _wfreopen_s instead of SetStdHandle() as that allows for native calls to print/write to be captured.\r\n\r\nFew known issues:\r\n- Two functional tests are skipped currently due to FILE_IN_USE errors. I am currently investigating why.\r\n- Pipe stdout redirection still doesn't capture native logs. Working on that too.\r\n\r\nThings I would like to add in future PRs:\r\n- Windows event log tests\r\n- Startup exception tests\r\n","created_at":"2018-05-24T17:28:16Z","updated_at":"2018-05-30T00:12:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bae231d229a22f9831fe5928746b1456bbad0433","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858/commits","review_comments_url":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858/comments","review_comment_url":"https://api.github.com/repos/aspnet/IISIntegration/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/IISIntegration/issues/858/comments","statuses_url":"https://api.github.com/repos/aspnet/IISIntegration/statuses/61e866ce312eb764cc5d66db6013a5bfb893b913","head":{"label":"aspnet:jkotalik/stdOutLogging","ref":"jkotalik/stdOutLogging","sha":"61e866ce312eb764cc5d66db6013a5bfb893b913","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":42883699,"name":"IISIntegration","full_name":"aspnet/IISIntegration","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/IISIntegration","description":"ASP.NET Core IIS integration","fork":false,"url":"https://api.github.com/repos/aspnet/IISIntegration","forks_url":"https://api.github.com/repos/aspnet/IISIntegration/forks","keys_url":"https://api.github.com/repos/aspnet/IISIntegration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/IISIntegration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/IISIntegration/teams","hooks_url":"https://api.github.com/repos/aspnet/IISIntegration/hooks","issue_events_url":"https://api.github.com/repos/aspnet/IISIntegration/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/IISIntegration/events","assignees_url":"https://api.github.com/repos/aspnet/IISIntegration/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/IISIntegration/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/IISIntegration/tags","blobs_url":"https://api.github.com/repos/aspnet/IISIntegration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/IISIntegration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/IISIntegration/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/IISIntegration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/IISIntegration/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/IISIntegration/languages","stargazers_url":"https://api.github.com/repos/aspnet/IISIntegration/stargazers","contributors_url":"https://api.github.com/repos/aspnet/IISIntegration/contributors","subscribers_url":"https://api.github.com/repos/aspnet/IISIntegration/subscribers","subscription_url":"https://api.github.com/repos/aspnet/IISIntegration/subscription","commits_url":"https://api.github.com/repos/aspnet/IISIntegration/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/IISIntegration/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/IISIntegration/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/IISIntegration/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/IISIntegration/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/IISIntegration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/IISIntegration/merges","archive_url":"https://api.github.com/repos/aspnet/IISIntegration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/IISIntegration/downloads","issues_url":"https://api.github.com/repos/aspnet/IISIntegration/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/IISIntegration/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/IISIntegration/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/IISIntegration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/IISIntegration/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/IISIntegration/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/IISIntegration/deployments","created_at":"2015-09-21T17:55:09Z","updated_at":"2018-05-29T16:06:24Z","pushed_at":"2018-05-30T00:09:41Z","git_url":"git://github.com/aspnet/IISIntegration.git","ssh_url":"git@github.com:aspnet/IISIntegration.git","clone_url":"https://github.com/aspnet/IISIntegration.git","svn_url":"https://github.com/aspnet/IISIntegration","homepage":"","size":11224,"stargazers_count":93,"watchers_count":93,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"archived":false,"open_issues_count":97,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":43,"open_issues":97,"watchers":93,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"2a467bfd6d2c07054465ddf4ec43466b6a88920c","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":42883699,"name":"IISIntegration","full_name":"aspnet/IISIntegration","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/IISIntegration","description":"ASP.NET Core IIS integration","fork":false,"url":"https://api.github.com/repos/aspnet/IISIntegration","forks_url":"https://api.github.com/repos/aspnet/IISIntegration/forks","keys_url":"https://api.github.com/repos/aspnet/IISIntegration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/IISIntegration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/IISIntegration/teams","hooks_url":"https://api.github.com/repos/aspnet/IISIntegration/hooks","issue_events_url":"https://api.github.com/repos/aspnet/IISIntegration/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/IISIntegration/events","assignees_url":"https://api.github.com/repos/aspnet/IISIntegration/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/IISIntegration/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/IISIntegration/tags","blobs_url":"https://api.github.com/repos/aspnet/IISIntegration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/IISIntegration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/IISIntegration/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/IISIntegration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/IISIntegration/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/IISIntegration/languages","stargazers_url":"https://api.github.com/repos/aspnet/IISIntegration/stargazers","contributors_url":"https://api.github.com/repos/aspnet/IISIntegration/contributors","subscribers_url":"https://api.github.com/repos/aspnet/IISIntegration/subscribers","subscription_url":"https://api.github.com/repos/aspnet/IISIntegration/subscription","commits_url":"https://api.github.com/repos/aspnet/IISIntegration/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/IISIntegration/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/IISIntegration/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/IISIntegration/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/IISIntegration/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/IISIntegration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/IISIntegration/merges","archive_url":"https://api.github.com/repos/aspnet/IISIntegration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/IISIntegration/downloads","issues_url":"https://api.github.com/repos/aspnet/IISIntegration/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/IISIntegration/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/IISIntegration/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/IISIntegration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/IISIntegration/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/IISIntegration/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/IISIntegration/deployments","created_at":"2015-09-21T17:55:09Z","updated_at":"2018-05-29T16:06:24Z","pushed_at":"2018-05-30T00:09:41Z","git_url":"git://github.com/aspnet/IISIntegration.git","ssh_url":"git@github.com:aspnet/IISIntegration.git","clone_url":"https://github.com/aspnet/IISIntegration.git","svn_url":"https://github.com/aspnet/IISIntegration","homepage":"","size":11224,"stargazers_count":93,"watchers_count":93,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"archived":false,"open_issues_count":97,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":43,"open_issues":97,"watchers":93,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858"},"html":{"href":"https://github.com/aspnet/IISIntegration/pull/858"},"issue":{"href":"https://api.github.com/repos/aspnet/IISIntegration/issues/858"},"comments":{"href":"https://api.github.com/repos/aspnet/IISIntegration/issues/858/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/IISIntegration/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/IISIntegration/pulls/858/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/IISIntegration/statuses/61e866ce312eb764cc5d66db6013a5bfb893b913"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jkotalik"}}