Commit c7537f36 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Fix logs with streams + fix unit-test 'debug'

parent 7337c276
Pipeline #3542 passed with stage
in 5 minutes and 5 seconds
...@@ -189,6 +189,7 @@ namespace hpp ...@@ -189,6 +189,7 @@ namespace hpp
{ {
writePrefix (std::cerr, channel, file, line, function); writePrefix (std::cerr, channel, file, line, function);
std::cerr << incindent << data.rdbuf() << decindent << std::flush; std::cerr << incindent << data.rdbuf() << decindent << std::flush;
data.rdbuf()->pubseekpos(0);
} }
namespace namespace
...@@ -273,6 +274,7 @@ namespace hpp ...@@ -273,6 +274,7 @@ namespace hpp
writePrefix (stream, channel, file, line, function); writePrefix (stream, channel, file, line, function);
stream << incindent << data.rdbuf() << decindent << std::flush; stream << incindent << data.rdbuf() << decindent << std::flush;
data.rdbuf()->pubseekpos(0);
} }
Logging::Logging () Logging::Logging ()
......
...@@ -29,7 +29,7 @@ MACRO(DEFINE_TEST NAME LIB) ...@@ -29,7 +29,7 @@ MACRO(DEFINE_TEST NAME LIB)
# Link against Boost. # Link against Boost.
TARGET_LINK_LIBRARIES(${NAME} ${Boost_LIBRARIES}) TARGET_LINK_LIBRARIES(${NAME} ${Boost_LIBRARIES})
ADD_TEST(${NAME} ${RUNTIME_OUTPUT_DIRECTORY}/${NAME}) ADD_TEST(NAME ${NAME} COMMAND ${RUNTIME_OUTPUT_DIRECTORY}/${NAME})
ENDMACRO(DEFINE_TEST) ENDMACRO(DEFINE_TEST)
...@@ -39,3 +39,9 @@ DEFINE_TEST(assertion hpp-util) ...@@ -39,3 +39,9 @@ DEFINE_TEST(assertion hpp-util)
DEFINE_TEST(exception hpp-util) DEFINE_TEST(exception hpp-util)
DEFINE_TEST(exception-factory hpp-util) DEFINE_TEST(exception-factory hpp-util)
DEFINE_TEST(timer hpp-util) DEFINE_TEST(timer hpp-util)
SET(HPP_LOGGINGDIR "${CMAKE_CURRENT_BINARY_DIR}")
CONFIG_FILES(run_debug.sh)
ADD_EXECUTABLE(debug debug.cc)
TARGET_LINK_LIBRARIES(debug hpp-util ${Boost_LIBRARIES})
ADD_TEST(NAME debug COMMAND ${RUNTIME_OUTPUT_DIRECTORY}/run_debug.sh)
...@@ -26,12 +26,13 @@ using namespace hpp::debug; ...@@ -26,12 +26,13 @@ using namespace hpp::debug;
int run_test () int run_test ()
{ {
ConsoleOutput console;
JournalOutput out ("debug.test.log"); JournalOutput out ("debug.test.log");
Channel channel ("TEST", boost::assign::list_of<Output*> (&out)); Channel channel ("TEST", boost::assign::list_of<Output*> (&out)(&console));
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 100; ++i) {
std::stringstream ss; std::stringstream ss;
ss << i << hpp::iendl; ss << i << hpp::iendl;
out.write (channel, __FILE__, __LINE__, __PRETTY_FUNCTION__, ss.str()); channel.write (__FILE__, __LINE__, __PRETTY_FUNCTION__, ss);
} }
return 0; return 0;
} }
......
#!/bin/bash
export HPP_LOGGINGDIR=@HPP_LOGGINGDIR@
@CMAKE_BINARY_DIR@/tests/debug
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment