Ejemplo n.º 1
0
void LoggingHandler::writeTableEntry(const Poco::Message& msg, const std::string& trClass, std::ostream& out)
{
	out << "<tr class=\"" << trClass << "\">";
	out << "<td><img src =\"" << image(msg.getPriority()) << "\" width=\"20\" height=\"20\" alt=\"" << convert(msg.getPriority()) << "\" title =\"" << convert(msg.getPriority()) << "\"/></td>";
	out << "<td>" << msg.getSource() << "</td>";
	out << "<td>" << msg.getText() << "</td>";
	out << "<td>" << convert(msg.getPriority()) << "</td>";
	out << "<td>" << Poco::DateTimeFormatter::format(msg.getTime(), Poco::DateTimeFormat::SORTABLE_FORMAT) << "</td>";
	out << "<td>" << msg.getTid() << "</td>";
	out << "<td>" << msg.getThread() << "</td>";
	out << "<td>" << msg.getPid() << "</td>";
	out << "</tr>";
}
std::string messageToJSON(const Poco::Message& message)
{
	std::ostringstream json;
	
	json 
		<< "{"
		<< quote("source") << ":"
		<< jsonize(message.getSource())
		<< ","
		<< quote("text") << ":"
		<< jsonize(message.getText())
		<< ","
		<< quote("priority") << ":"
		<< static_cast<int>(message.getPriority())
		<< ","
		<< quote("timestamp") << ":"
		<< quote(Poco::DateTimeFormatter::format(message.getTime(), Poco::DateTimeFormat::ISO8601_FRAC_FORMAT))
		<< "}";
	
	return json.str();
}