Skip to content

Commit

Permalink
OrcCommand: GetSamples: add support for 'log' option
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienfl-orc committed Feb 11, 2021
1 parent d926c91 commit 1c9bcdc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/OrcCommand/ConfigFile_GetSamples.cpp
Expand Up @@ -12,6 +12,8 @@

#include "ConfigFile_GetSamples.h"

#include "Log/UtilitiesLoggerConfiguration.h"

using namespace Orc;
using namespace Orc::Config;
using namespace Orc::Config::Common;
Expand Down Expand Up @@ -77,8 +79,11 @@ HRESULT Orc::Config::GetSamples::root(ConfigItem& item)
return hr;
if (FAILED(hr = item.AddChild(::samples, GETSAMPLES_SAMPLES)))
return hr;
// Deprecated: for compatibility with 10.0.x (was always ignored)
if (FAILED(hr = item.AddChild(logging, GETSAMPLES_LOGGING)))
return hr;
if (FAILED(hr = item.AddChild(Orc::Command::UtilitiesLoggerConfiguration::Register, GETSAMPLES_LOG)))
return hr;
if (FAILED(hr = item.AddChild(L"autoruns", output, GETSAMPLES_AUTORUNS)))
return hr;
if (FAILED(hr = item.AddAttribute(L"nolimits", GETSAMPLES_NOLIMITS, ConfigItem::OPTION)))
Expand Down
7 changes: 4 additions & 3 deletions src/OrcCommand/ConfigFile_GetSamples.h
Expand Up @@ -30,9 +30,10 @@ constexpr auto GETSAMPLES_LOCATIONS = 6L;
constexpr auto GETSAMPLES_KNOWNLOCATIONS = 7L;
constexpr auto GETSAMPLES_SAMPLES = 8L;
constexpr auto GETSAMPLES_LOGGING = 9L;
constexpr auto GETSAMPLES_AUTORUNS = 10L;
constexpr auto GETSAMPLES_NOLIMITS = 11L;
constexpr auto GETSAMPLES_NOSIGCHECK = 12L;
constexpr auto GETSAMPLES_LOG = 10L;
constexpr auto GETSAMPLES_AUTORUNS = 11L;
constexpr auto GETSAMPLES_NOLIMITS = 12L;
constexpr auto GETSAMPLES_NOSIGCHECK = 13L;

namespace Orc::Config::GetSamples {
ORCLIB_API HRESULT root(ConfigItem& item);
Expand Down
14 changes: 14 additions & 0 deletions src/OrcCommand/GetSamples_Config.cpp
Expand Up @@ -71,6 +71,8 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, const WCHAR* argv[])
{
HRESULT hr = E_FAIL;

UtilitiesLoggerConfiguration::Parse(argc, argv, m_utilitiesConfig.log);

for (int i = 0; i < argc; i++)
{
switch (argv[i][0])
Expand Down Expand Up @@ -168,6 +170,16 @@ HRESULT Main::GetConfigurationFromConfig(const ConfigItem& configitem)

ConfigFile reader;

if (configitem[GETSAMPLES_LOGGING])
{
Log::Warn(L"The '<logging> configuration element is deprecated, please use '<log>' instead");
}

if (configitem[GETSAMPLES_LOG])
{
UtilitiesLoggerConfiguration::Parse(configitem[GETSAMPLES_LOG], m_utilitiesConfig.log);
}

if (FAILED(
hr = config.samplesOutput.Configure(
static_cast<OutputSpec::Kind>(OutputSpec::Kind::Archive | OutputSpec::Kind::Directory),
Expand Down Expand Up @@ -288,6 +300,8 @@ HRESULT Main::CheckConfiguration()
{
HRESULT hr = E_FAIL;

UtilitiesLoggerConfiguration::Apply(m_logging, m_utilitiesConfig.log);

// TODO: make a function to use also in GetThis_config.cpp
if (!config.limits.bIgnoreLimits
&& (config.limits.dwlMaxBytesTotal == INFINITE && config.limits.dwMaxSampleCount == INFINITE))
Expand Down

0 comments on commit 1c9bcdc

Please sign in to comment.