diff options
author | Josh Blum <josh@joshknows.com> | 2011-05-04 20:40:36 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-05-04 20:40:36 -0700 |
commit | 9734a74366dd095256c2e2c58c5c9bcd7547f72d (patch) | |
tree | 34b169cd39dab8809937b6fc98eb57364521e61a /host/lib/utils/msg.cpp | |
parent | 09be0518cee887878f3b070adea25eccc4c06e60 (diff) | |
download | uhd-9734a74366dd095256c2e2c58c5c9bcd7547f72d.tar.gz uhd-9734a74366dd095256c2e2c58c5c9bcd7547f72d.tar.bz2 uhd-9734a74366dd095256c2e2c58c5c9bcd7547f72d.zip |
uhd: various tweaks to log and msg, replaced a few remaining stdio
Diffstat (limited to 'host/lib/utils/msg.cpp')
-rw-r--r-- | host/lib/utils/msg.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/host/lib/utils/msg.cpp b/host/lib/utils/msg.cpp index 0eaca05a5..e850b5a6d 100644 --- a/host/lib/utils/msg.cpp +++ b/host/lib/utils/msg.cpp @@ -34,11 +34,19 @@ static void msg_to_cout(const std::string &msg){ std::stringstream ss; - BOOST_FOREACH(const std::string &line, tokenizer(msg, "\n")){ - ss << "-- " << line << std::endl; + static bool just_had_a_newline = true; + BOOST_FOREACH(char ch, msg){ + if (just_had_a_newline){ + just_had_a_newline = false; + ss << "-- "; + } + if (ch == '\n'){ + just_had_a_newline = true; + } + ss << ch; } - std::cout << ss.str(); + std::cout << ss.str() << std::flush; } static void msg_to_cerr(const std::string &title, const std::string &msg){ @@ -49,7 +57,7 @@ static void msg_to_cerr(const std::string &title, const std::string &msg){ ss << " " << line << std::endl; } - std::cerr << ss.str(); + std::cerr << ss.str() << std::flush; } /*********************************************************************** @@ -110,6 +118,6 @@ uhd::msg::_msg::~_msg(void){ msg_mutex.unlock(); } -std::ostream & uhd::msg::_msg::get(void){ +std::ostream & uhd::msg::_msg::operator()(void){ return msg_ss; } |