Skip to content
Snippets Groups Projects
Commit 97fe3e64 authored by Tobias Winchen's avatar Tobias Winchen
Browse files

Allow also upper /lor case log levels in set level

parent c75d1915
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ set(gtest_common ...@@ -6,6 +6,7 @@ set(gtest_common
src/detector_accumulator_tester.cu src/detector_accumulator_tester.cu
src/packer_tester.cu src/packer_tester.cu
src/unpacker_tester.cu src/unpacker_tester.cu
src/core_tests.cpp
) )
add_executable(gtest_common ${gtest_common} ) add_executable(gtest_common ${gtest_common} )
......
#include <algorithm>
#include "psrdada_cpp/cli_utils.hpp" #include "psrdada_cpp/cli_utils.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
...@@ -12,6 +14,9 @@ namespace psrdada_cpp { ...@@ -12,6 +14,9 @@ namespace psrdada_cpp {
void set_log_level(std::string level) void set_log_level(std::string level)
{ {
std::transform(level.begin(), level.end(), level.begin(), [](unsigned char c){ return std::tolower(c); });
using namespace boost::log; using namespace boost::log;
if (level == "debug") if (level == "debug")
{ {
...@@ -30,4 +35,4 @@ namespace psrdada_cpp { ...@@ -30,4 +35,4 @@ namespace psrdada_cpp {
core::get()->set_filter(trivial::severity >= trivial::error); core::get()->set_filter(trivial::severity >= trivial::error);
} }
} }
} //namespace } //namespace
\ No newline at end of file
...@@ -5,6 +5,7 @@ link_directories(${GTEST_LIBRARY_DIR}) ...@@ -5,6 +5,7 @@ link_directories(${GTEST_LIBRARY_DIR})
set(gtest_base_cpp set(gtest_base_cpp
src/dada_output_stream_tester.cu src/dada_output_stream_tester.cu
src/gtest_base.cpp src/gtest_base.cpp
src/core_tests.cpp
) )
add_executable(gtest_base ${gtest_base_cpp} ) add_executable(gtest_base ${gtest_base_cpp} )
......
#include <gtest/gtest.h>
#include <boost/shared_ptr.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/utility/setup/console.hpp>
#include "psrdada_cpp/cli_utils.hpp"
typedef boost::log::sinks::synchronous_sink<boost::log::sinks::text_ostream_backend> sink_t;
namespace psrdada_cpp {
namespace test {
TEST(SetLogLevel, UPPER)
{
// setting log elvel with mixed upper / lower caps should work
std::stringstream ss;
boost::shared_ptr<sink_t> streamSink = boost::log::add_console_log(ss);
set_log_level("INFO");
BOOST_LOG_TRIVIAL(debug) << "Should not be in log";
EXPECT_EQ(ss.rdbuf()->in_avail(), 0);
BOOST_LOG_TRIVIAL(info) << "Should be in log";
EXPECT_GT(ss.rdbuf()->in_avail(), 0);
}
}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment