@@ -21,6 +21,7 @@ Author: Daniel Kroening, kroening@kroening.com
2121
2222ui_message_handlert::ui_message_handlert ()
2323 : _ui(uit::PLAIN),
24+ always_flush(false ),
2425 time(timestampert::make(timestampert::clockt::NONE)),
2526 out(std::cout),
2627 json_stream(nullptr )
@@ -30,8 +31,10 @@ ui_message_handlert::ui_message_handlert()
3031ui_message_handlert::ui_message_handlert (
3132 uit __ui,
3233 const std::string &program,
34+ bool always_flush,
3335 timestampert::clockt clock_type)
3436 : _ui(__ui),
37+ always_flush(always_flush),
3538 time(timestampert::make(clock_type)),
3639 out(std::cout),
3740 json_stream(nullptr )
@@ -79,6 +82,7 @@ ui_message_handlert::ui_message_handlert(
7982 ? uit::JSON_UI
8083 : uit::PLAIN,
8184 program,
85+ cmdline.isset(" flush" ),
8286 cmdline.isset(" timestamp" )
8387 ? cmdline.get_value(" timestamp" ) == "monotonic"
8488 ? timestampert::clockt::MONOTONIC
@@ -130,11 +134,13 @@ void ui_message_handlert::print(
130134 {
131135 case uit::PLAIN:
132136 {
133- console_message_handlert console_message_handler;
137+ console_message_handlert console_message_handler (always_flush) ;
134138 std::stringstream ss;
135139 const std::string timestamp = time->stamp ();
136140 ss << timestamp << (timestamp.empty () ? " " : " " ) << message;
137141 console_message_handler.print (level, ss.str ());
142+ if (always_flush)
143+ console_message_handler.flush (level);
138144 }
139145 break ;
140146
@@ -307,7 +313,7 @@ void ui_message_handlert::flush(unsigned level)
307313 {
308314 case uit::PLAIN:
309315 {
310- console_message_handlert console_message_handler;
316+ console_message_handlert console_message_handler (always_flush) ;
311317 console_message_handler.flush (level);
312318 }
313319 break ;
0 commit comments