47 #include <QTextStream> 58 display_absolute_time_(false),
59 human_readable_time_(false),
60 display_logger_(false),
61 display_function_(false),
62 use_regular_expressions_(false),
63 debug_color_(
Qt::gray),
64 info_color_(
Qt::black),
65 warn_color_(QColor(255,127,0)),
66 error_color_(
Qt::red),
67 fatal_color_(
Qt::magenta),
69 failedSearchText_(
""),
72 QObject::connect(
db_, SIGNAL(databaseCleared()),
109 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
124 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
139 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
155 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
171 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
187 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
204 const QStringList &list)
213 const QStringList &list)
280 if (parent.isValid()) {
310 int searchNotFound = -1;
312 bool partialSearch =
false;
316 return searchNotFound;
337 partialSearch =
true;
346 QString tempString = item.
text.join(
"|");
347 if(tempString.toUpper().contains(searchText))
360 return searchNotFound;
363 index = index + increment;
385 const QModelIndex &index,
int role)
const 391 case Qt::DisplayRole:
392 case Qt::ToolTipRole:
395 case Qt::ForegroundRole:
403 if (index.parent().isValid() &&
404 static_cast<size_t>(index.row()) >=
msg_mapping_.size()) {
411 if (role == Qt::DisplayRole) {
413 if (item.
level == rosgraph_msgs::Log::DEBUG) {
415 }
else if (item.
level == rosgraph_msgs::Log::INFO) {
417 }
else if (item.
level == rosgraph_msgs::Log::WARN) {
419 }
else if (item.
level == rosgraph_msgs::Log::ERROR) {
421 }
else if (item.
level == rosgraph_msgs::Log::FATAL) {
429 int milliseconds = item.
stamp.
nsec / 1000000 ;
430 const time_t time =
static_cast<time_t
>(item.
stamp.
sec);
431 std::ostringstream oss;
432 oss << std::put_time(std::localtime(&time),
"%Y-%m-%d %H:%M:%S");
433 snprintf(stamp,
sizeof(stamp),
"%s::%03d",oss.str().c_str(), milliseconds);
435 snprintf(stamp,
sizeof(stamp),
443 int32_t secs = t.
sec;
444 int hours = secs / 60 / 60;
445 int minutes = (secs / 60) % 60;
446 int seconds = (secs % 60);
447 int milliseconds = t.
nsec / 1000000;
449 snprintf(stamp,
sizeof(stamp),
451 hours, minutes, seconds, milliseconds);
456 snprintf(
id,
sizeof(
id),
"%s::%s", item.
node.c_str(), item.
function.c_str());
458 snprintf(
id,
sizeof(
id),
"%s", item.
node.c_str());
460 snprintf(
id,
sizeof(
id),
"::%s", item.
function.c_str());
467 snprintf(header,
sizeof(header),
"%c %s [%s] ", level, stamp,
id);
469 snprintf(header,
sizeof(header),
"%c %s [] ", level, stamp);
470 }
else if (display_id) {
471 snprintf(header,
sizeof(header),
"%c [%s] ", level,
id);
473 snprintf(header,
sizeof(header),
"%c [] ", level);
481 size_t len = strnlen(header,
sizeof(header));
482 for (
size_t i = 0; i < len; i++) {
487 return QVariant(QString(header) + item.
text[line_idx.
line_index]);
490 switch (item.
level) {
491 case rosgraph_msgs::Log::DEBUG:
493 case rosgraph_msgs::Log::INFO:
495 case rosgraph_msgs::Log::WARN:
497 case rosgraph_msgs::Log::ERROR:
499 case rosgraph_msgs::Log::FATAL:
505 else if (role == Qt::ToolTipRole) {
507 snprintf(buffer,
sizeof(buffer),
508 "<p style='white-space:pre'>" 509 "Timestamp: %d.%09d\n" 524 QString text = (QString(buffer) +
525 item.
text.join(
"\n") +
528 return QVariant(text);
531 snprintf(buffer,
sizeof(buffer),
532 "Timestamp: %d.%09d\n" 545 QString text = (QString(buffer) +
546 item.
text.join(
"\n"));
548 return QVariant(text);
568 if (filename.endsWith(
".bag", Qt::CaseInsensitive)) {
585 rosgraph_msgs::Log log;
586 log.file = item.
file;
588 log.header.seq = item.
seq;
594 qWarning(
"Msg with seq %d had time (%d); it's less than ros::TIME_MIN, which is invalid. " 595 "Writing 'now' instead.",
598 log.header.stamp = item.
stamp;
600 log.level = item.
level;
601 log.line = item.
line;
602 log.msg = item.
text.join(
"\n").toStdString();
603 log.name = item.
node;
604 bag.write(
"/rosout", log.header.stamp, log);
617 QFile outFile(filename);
618 outFile.open(QFile::WriteOnly);
619 QTextStream outstream(&outFile);
622 QString line =
data(index(i), Qt::DisplayRole).toString();
623 outstream << line <<
'\n';
637 std::deque<LineMap> new_items;
650 for (
int i = 0; i < item.
text.size(); i++) {
655 if (!new_items.empty()) {
656 beginInsertRows(QModelIndex(),
687 for (
int i = 0; i < item.
text.size(); i++) {
696 beginInsertRows(QModelIndex(),
779 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
static const QString INFO_COLOR
static const QString DISPLAY_FUNCTION
bool testIncludeFilter(const LogEntry &item)
static const QString DISPLAY_TIMESTAMPS
LogDatabaseProxyModel(LogDatabase *db)
void setFatalColor(const QColor &fatal_color)
static const QString FATAL_COLOR
void setIncludeFilters(const QStringList &list)
void setDisplayTime(bool display)
std::deque< LineMap > early_mapping_
bool acceptLogEntry(const LogEntry &item)
static const QString USE_REGEXPS
void processOldMessages()
const Time TIME_MIN(0, 1)
void handleDatabaseCleared()
std::deque< LineMap > msg_mapping_
void scheduleIdleProcessing()
static const QString WARN_COLOR
void setColorizeLogs(bool colorize_logs)
std::set< std::string > names_
const ros::Time & minTime() const
void setDisplayFunction(bool function_name)
bool display_absolute_time_
bool use_regular_expressions_
void setUseRegularExpressions(bool useRegexps)
void setInfoColor(const QColor &info_color)
void processNewMessages()
void setSeverityFilter(uint8_t severity_mask)
void setWarnColor(const QColor &warn_color)
void setDisplayLogger(bool logger_name)
void setErrorColor(const QColor &error_color)
static const QString DISPLAY_LOGGER
QStringList exclude_strings_
void setExcludeFilters(const QStringList &list)
void saveToFile(const QString &filename) const
static const QString EXCLUDE_FILTER
static const QString DEBUG_COLOR
void setAbsoluteTime(bool absolute)
bool isExcludeValid() const
bool human_readable_time_
const std::deque< LogEntry > & log()
static const QString COLORIZE_LOGS
void setNodeFilter(const std::set< std::string > &names)
int getItemIndex(const QString searchText, int index, int increment)
static const QString HUMAN_READABLE_TIME
static const QString ABSOLUTE_TIMESTAMPS
void saveBagFile(const QString &filename) const
virtual int rowCount(const QModelIndex &parent) const
void setDebugColor(const QColor &debug_color)
static const QString ERROR_COLOR
QString failedSearchText_
static const QString INCLUDE_FILTER
void setHumanReadableTime(bool human_readable_time)
void setExcludeRegexpPattern(const QString &pattern)
size_t earliest_log_index_
bool isIncludeValid() const
QStringList include_strings_
void clearSearchFailure()
void saveTextFile(const QString &filename) const
virtual QVariant data(const QModelIndex &index, int role) const
void setIncludeRegexpPattern(const QString &pattern)