|
|
@ -167,14 +167,18 @@ protected:
|
|
|
|
int color_range_start, color_range_end;
|
|
|
|
int color_range_start, color_range_end;
|
|
|
|
color_range_start = static_cast<int>(msg.color_range_start);
|
|
|
|
color_range_start = static_cast<int>(msg.color_range_start);
|
|
|
|
color_range_end = static_cast<int>(msg.color_range_end);
|
|
|
|
color_range_end = static_cast<int>(msg.color_range_end);
|
|
|
|
if (is_utf8_) {
|
|
|
|
if (is_utf8_)
|
|
|
|
|
|
|
|
{
|
|
|
|
payload = QString::fromUtf8(str.data(), static_cast<int>(str.size()));
|
|
|
|
payload = QString::fromUtf8(str.data(), static_cast<int>(str.size()));
|
|
|
|
// convert color ranges from byte index to character index.
|
|
|
|
// convert color ranges from byte index to character index.
|
|
|
|
if (msg.color_range_start < msg.color_range_end) {
|
|
|
|
if (msg.color_range_start < msg.color_range_end)
|
|
|
|
|
|
|
|
{
|
|
|
|
color_range_start = QString::fromUtf8(str.data(), msg.color_range_start).size();
|
|
|
|
color_range_start = QString::fromUtf8(str.data(), msg.color_range_start).size();
|
|
|
|
color_range_end = QString::fromUtf8(str.data(), msg.color_range_end).size();
|
|
|
|
color_range_end = QString::fromUtf8(str.data(), msg.color_range_end).size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
payload = QString::fromLatin1(str.data(), static_cast<int>(str.size()));
|
|
|
|
payload = QString::fromLatin1(str.data(), static_cast<int>(str.size()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -293,13 +297,15 @@ inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name, QObj
|
|
|
|
|
|
|
|
|
|
|
|
// log to QTextEdit with colorize output
|
|
|
|
// log to QTextEdit with colorize output
|
|
|
|
template<typename Factory = spdlog::synchronous_factory>
|
|
|
|
template<typename Factory = spdlog::synchronous_factory>
|
|
|
|
inline std::shared_ptr<logger> qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
|
|
|
|
inline std::shared_ptr<logger> qt_color_logger_mt(
|
|
|
|
|
|
|
|
const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Factory::template create<sinks::qt_color_sink_mt>(logger_name, qt_text_edit, max_lines, false, is_utf8);
|
|
|
|
return Factory::template create<sinks::qt_color_sink_mt>(logger_name, qt_text_edit, max_lines, false, is_utf8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Factory = spdlog::synchronous_factory>
|
|
|
|
template<typename Factory = spdlog::synchronous_factory>
|
|
|
|
inline std::shared_ptr<logger> qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
|
|
|
|
inline std::shared_ptr<logger> qt_color_logger_st(
|
|
|
|
|
|
|
|
const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Factory::template create<sinks::qt_color_sink_st>(logger_name, qt_text_edit, max_lines, false, is_utf8);
|
|
|
|
return Factory::template create<sinks::qt_color_sink_st>(logger_name, qt_text_edit, max_lines, false, is_utf8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|