[log] translating 3rd party logging messages
Hello,
shown my translator for Qt using boost.log:
void qt_message_translator(QtMsgType type, const QMessageLogContext
&context, const QString &msg)
{
QString const context_message =
QString("Qt [")
+ context.function + " ("
+ context.file + ":"
+ QString::number(context.line)
+ ")] ";
QByteArray const ctx_msg = context_message.toUtf8();
QByteArray const qt_msg = msg.toUtf8();
boost::log::sources::severity_logger
The problem is more of cosmetic nature; the logging format output is different from what is used normally - it looks alien. Since the context data is available I assume I can write an own logging source writing/fill the log records filled with the context information. Additionally I want to add a "Scope" or "Library" flag "Qt" (Scope may be not the best choise since it's used in another context). But I didn't find an example in the boost.log module to find the entry; is writing an own source the right way? How to use it in the qt_message_translator?
as far I understood so far, the entry point is described at http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/detailed/sources..... if (logging::record rec = m_logger.open_record()) { rec.attribute_values().insert("Message", attrs::make_attribute_value(std::string("Connection established"))); m_logger.push_record(boost::move(rec)); } where I can write a record with Message and LineID. But what is the complementary attribute for Filename and Function?? Thanks, Olaf
as far I understood so far, the entry point is described at http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/detailed/sources.....
if (logging::record rec = m_logger.open_record()) { rec.attribute_values().insert("Message", attrs::make_attribute_value(std::string("Connection established"))); m_logger.push_record(boost::move(rec)); }
where I can write a record with Message and LineID. But what is the complementary attribute for Filename and Function??
a little bit further, but even failed to compile: // from qt logger context int ctx_line =42; const char *ctx_file = "the_file.cpp"; const char *ctx_function = "the_function"; // string_literal expected // errror: no matching function for call to 'boost::log::v2s_mt_posix::attributes::named_scope_entry::named_scope_entry(const char* const&, const char* const&, const int&)' // how to convert ?? attributes::named_scope_entry scope(ctx_function, ctx_file, ctx_line); // error: no matching function for call to 'boost::log::v2s_mt_posix::attribute_value_set::insert(const char [6], boost::log::v2s_mt_posix::attributes::named_scope_entry&)' record.attribute_values().insert("Scope", scope); The first lacks probably my missing knowledge about const char* and const char[], isn't it? Thanks, Olaf
participants (1)
-
Olaf Peter