summaryrefslogtreecommitdiffstats
path: root/host/lib/utils
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-05-04 20:40:36 -0700
committerJosh Blum <josh@joshknows.com>2011-05-04 20:40:36 -0700
commit9734a74366dd095256c2e2c58c5c9bcd7547f72d (patch)
tree34b169cd39dab8809937b6fc98eb57364521e61a /host/lib/utils
parent09be0518cee887878f3b070adea25eccc4c06e60 (diff)
downloaduhd-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')
-rw-r--r--host/lib/utils/log.cpp2
-rw-r--r--host/lib/utils/msg.cpp18
2 files changed, 14 insertions, 6 deletions
diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp
index f67a14411..8b270af6b 100644
--- a/host/lib/utils/log.cpp
+++ b/host/lib/utils/log.cpp
@@ -209,6 +209,6 @@ uhd::_log::log::~log(void){
uhd_logger_stream_resource().aquire(false);
}
-std::ostream & uhd::_log::log::get(void){
+std::ostream & uhd::_log::log::operator()(void){
return uhd_logger_stream_resource().get();
}
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;
}