additional cmake fixes, improve default log level setting

This commit is contained in:
nadavi 2019-08-14 18:10:25 -06:00
parent 1fc542d068
commit 9f49bbab86
4 changed files with 26 additions and 11 deletions

@ -101,12 +101,12 @@ function(vtkm_unit_tests)
if(VTKm_UT_TEST_ARGS)
list(FIND VTKm_UT_TEST_ARGS "-v" index)
if(index EQUAL -1)
list(APPEND VTKm_UT_TEST_ARGS "-v" "0")
list(APPEND VTKm_UT_TEST_ARGS "-v" "INFO")
else()
message(STATUS "Test manually supplied the logging level, not overriding")
endif()
else()
list(APPEND VTKm_UT_TEST_ARGS "-v" "0")
list(APPEND VTKm_UT_TEST_ARGS "-v" "INFO")
endif()
if(VTKm_UT_MPI)
@ -115,9 +115,14 @@ function(vtkm_unit_tests)
set(extraArgs EXTRA_INCLUDE "vtkm/cont/testing/Testing.h"
FUNCTION "vtkm::cont::testing::Environment env")
else()
set(extraArgs)
set(extraArgs EXTRA_INCLUDE "vtkm/cont/Logging.h")
endif()
# Logging is turned on by default now to Warning levels
# To get tests to correctly output info level logs we need to set
# the StderrLogLevel
set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "vtkm::cont::SetStderrLogLevel(vtkm::cont::LogLevel::Info);")
#the creation of the test source list needs to occur before the labeling as
#cuda. This is so that we get the correctly named entry points generated
create_test_sourcelist(test_sources ${test_prog}.cxx ${VTKm_UT_SOURCES} ${extraArgs})

@ -103,6 +103,9 @@ namespace vtkm
namespace cont
{
static bool logSet = false;
VTKM_CONT
void InitLogging(int& argc, char* argv[])
{
@ -124,7 +127,10 @@ void InitLogging(int& argc, char* argv[])
loguru::set_name_to_verbosity_callback(&nameToVerbosityCallback);
// Set the Default verbosity level to WARNING
loguru::g_stderr_verbosity = loguru::Verbosity_WARNING;
if (!logSet)
{
SetStderrLogLevel(vtkm::cont::LogLevel::Warn);
}
loguru::init(argc, argv);
LOG_F(INFO, "Logging initialized.");
@ -150,6 +156,7 @@ void SetStderrLogLevel(LogLevel level)
{
#ifdef VTKM_ENABLE_LOGGING
loguru::g_stderr_verbosity = static_cast<loguru::Verbosity>(level);
logSet = true;
#else // VTKM_ENABLE_LOGGING
(void)level;
#endif // VTKM_ENABLE_LOGGING

@ -9,6 +9,9 @@
//============================================================================
#include <vtkm/cont/Error.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/cont/testing/Testing.h>
namespace
@ -18,28 +21,28 @@ void RecursiveFunction(int recurse)
{
if (recurse < 5)
{
RecursiveFunction(recurse++);
RecursiveFunction(++recurse);
}
else
{
throw vtkm::cont::Error("Too much recursion");
throw vtkm::cont::ErrorBadValue("Too much recursion");
}
}
void ValidateError(const vtkm::cont::Error& error)
{
std::cout << error.what() << std::endl;
std::string stackTrace = "";
std::string message = "Too much recursion";
VTKM_LOG_S(vtkm::cont::LogLevel::Info, "stack trace: " << error.GetStackTrace());
VTKM_TEST_ASSERT(test_equal(message, error.GetMessage()), "Message was incorrect");
VTKM_TEST_ASSERT(test_equal(stackTrace, error.GetStackTrace()), "StackTrace was incorrect");
VTKM_TEST_ASSERT(test_equal((message + "\n" + stackTrace).c_str(), error.what()),
VTKM_TEST_ASSERT(test_equal(message + "\n" + error.GetStackTrace(), std::string(error.what())),
"what() was incorrect");
}
void DoErrorTest()
{
std::cout << "Check base error msgs" << std::endl;
VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Check base error mesgs");
try
{
RecursiveFunction(0);

@ -22,7 +22,7 @@
#include <vtkm/Types.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/cont/Initialize.h>
#include <exception>
#include <iostream>
@ -317,7 +317,7 @@ public:
static VTKM_CONT int Run(Func function, int argc, char* argv[])
{
vtkm::cont::InitLogging(argc, argv);
vtkm::cont::Initialize(argc, argv);
try
{