26 const std::string &program,
29 : message_handler(_message_handler),
31 always_flush(always_flush),
42 out <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
49 program_xml.
name=
"program";
50 program_xml.
data=program;
68 const std::string &program)
71 cmdline.isset(
"xml-ui") || cmdline.isset(
"xml-interface")
73 : cmdline.isset(
"json-ui") || cmdline.isset(
"json-interface")
77 cmdline.isset(
"flush"),
78 cmdline.isset(
"timestamp") ? cmdline.get_value(
"timestamp") ==
"monotonic"
80 : cmdline.get_value(
"timestamp") ==
"wall"
88 std::make_unique<console_message_handlert>(
always_flush);
127 return "STATUS-MESSAGE";
132 const std::string &message)
140 std::stringstream ss;
141 const std::string timestamp =
time->stamp();
142 ss << timestamp << (timestamp.empty() ?
"" :
" ") << message;
154 print(level, message, location);
172 INVARIANT(
false,
"Cannot print xml data on PLAIN UI");
179 INVARIANT(
false,
"Cannot print xml data on JSON UI");
194 INVARIANT(
false,
"Cannot print json data on PLAIN UI");
197 INVARIANT(
false,
"Cannot print json data on XML UI");
210 const std::string &message,
221 level, message, location);
227 std::string tmp_message(message);
229 if(!tmp_message.empty() && *tmp_message.rbegin()==
'\n')
230 tmp_message.resize(tmp_message.size()-1);
234 ui_msg(type, tmp_message, location);
242 const std::string &type,
243 const std::string &msg,
262 const std::string &type,
263 const std::string &msg1,
267 result.
name=
"message";
275 const std::string timestamp =
time->stamp();
276 if(!timestamp.empty())
284 const std::string &type,
285 const std::string &msg1,
293 result[
"sourceLocation"] =
json(location);
297 const std::string timestamp =
time->stamp();
298 if(!timestamp.empty())
Provides methods for streaming JSON arrays.
virtual void print(unsigned level, const std::string &message)=0
virtual void flush(unsigned)=0
const irep_idt & get_file() const
A way of representing nested key/value data.
Timestamp class hierarchy.
clockt
Derived types of timestampert.
void print(unsigned level, const structured_datat &data) override
virtual void json_ui_msg(const std::string &type, const std::string &msg, const source_locationt &location)
const char * level_string(unsigned level)
virtual uit get_ui() const
message_handlert * message_handler
std::unique_ptr< const timestampert > time
virtual void flush(unsigned level) override
virtual void xml_ui_msg(const std::string &type, const std::string &msg, const source_locationt &location)
std::unique_ptr< json_stream_arrayt > json_stream
virtual ~ui_message_handlert()
ui_message_handlert(const class cmdlinet &, const std::string &program)
virtual void ui_msg(const std::string &type, const std::string &msg, const source_locationt &location)
std::unique_ptr< console_message_handlert > console_message_handler
void set_attribute(const std::string &attribute, unsigned value)
xmlt & new_element(const std::string &key)
jsont to_json(const structured_datat &data)
Convert the structured_datat into an json object.
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
xmlt xml(const irep_idt &property_id, const property_infot &property_info)
std::string to_pretty(const structured_datat &data)
Convert the structured_data into plain text.
time_t time(time_t *tloc)
xmlt to_xml(const structured_datat &data)
Convert the structured_datat into an xml object.