Skip to content

Commit

Permalink
OrcCommand: GetSamples: forward log options to 'GetThis'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienfl-orc committed Feb 11, 2021
1 parent 1c9bcdc commit fc89ff1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/OrcCommand/GetSamples_Run.cpp
Expand Up @@ -26,6 +26,7 @@
#include "FileStream.h"

#include "TaskTracker.h"
#include "Text/Iconv.h"

using namespace Orc::Command::GetSamples;
using namespace Orc;
Expand Down Expand Up @@ -396,6 +397,26 @@ HRESULT Main::RunGetThis(const std::wstring& strConfigFile, LPCWSTR szTempDir)
std::make_shared<OnComplete>(OnComplete::Delete, L"GetThisConfig.xml", strConfigFile, nullptr));
}

auto logConfig = m_utilitiesConfig.log;
const auto fileSinkOutput = m_logging.fileSink()->OutputPath();
if (fileSinkOutput && logConfig.file.path)
{
std::error_code ec;

// Override output log path with the one currently being use to ensure using the same file
const auto logPath = fmt::format(L"\"{}\"", fileSinkOutput->c_str());
logConfig.file.path = logPath;

// Override any disposition to be sure to append
logConfig.file.disposition = FileDisposition::Append;
}

const auto logArguments = UtilitiesLoggerConfiguration::ToCommandLineArguments(logConfig);
if (logArguments)
{
strConfigArg += L" " + *logArguments;
}

command->AddArgument(strConfigArg, 0L);

JobObject no_job;
Expand Down
3 changes: 3 additions & 0 deletions src/OrcLib/CommandExecute.cpp
Expand Up @@ -392,6 +392,9 @@ HRESULT CommandExecute::Execute(const JobObject& job, bool bBreakAway)
}
}

// Command as 'GetSamples' will create a child process 'GetThis' with the current log file path for appending
Log::Flush();

if (ResumeThread(m_pi.hThread) == -1)
{
hr = HRESULT_FROM_WIN32(GetLastError());
Expand Down

0 comments on commit fc89ff1

Please sign in to comment.