mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 15:31:26 +12:00
Qt: Add timestamp filter to log viewer
This is incredibly useful if you want to copy paste two logs into Meld for example
This commit is contained in:
parent
895af3c3ab
commit
184bd51b87
2 changed files with 28 additions and 3 deletions
|
@ -67,6 +67,10 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
||||||
QAction* open = new QAction(tr("&Open log file"));
|
QAction* open = new QAction(tr("&Open log file"));
|
||||||
QAction* filter = new QAction(tr("&Filter log"));
|
QAction* filter = new QAction(tr("&Filter log"));
|
||||||
|
|
||||||
|
QAction* timestamps = new QAction(tr("&Show Timestamps"));
|
||||||
|
timestamps->setCheckable(true);
|
||||||
|
timestamps->setChecked(m_show_timestamps);
|
||||||
|
|
||||||
QAction* threads = new QAction(tr("&Show Threads"));
|
QAction* threads = new QAction(tr("&Show Threads"));
|
||||||
threads->setCheckable(true);
|
threads->setCheckable(true);
|
||||||
threads->setChecked(m_show_threads);
|
threads->setChecked(m_show_threads);
|
||||||
|
@ -110,6 +114,8 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(filter);
|
menu.addAction(filter);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
menu.addAction(timestamps);
|
||||||
|
menu.addSeparator();
|
||||||
menu.addAction(threads);
|
menu.addAction(threads);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(last_actions_only);
|
menu.addAction(last_actions_only);
|
||||||
|
@ -145,6 +151,12 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
||||||
filter_log();
|
filter_log();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(timestamps, &QAction::toggled, this, [this](bool checked)
|
||||||
|
{
|
||||||
|
m_show_timestamps = checked;
|
||||||
|
filter_log();
|
||||||
|
});
|
||||||
|
|
||||||
connect(last_actions_only, &QAction::toggled, this, [this](bool checked)
|
connect(last_actions_only, &QAction::toggled, this, [this](bool checked)
|
||||||
{
|
{
|
||||||
m_last_actions_only = checked;
|
m_last_actions_only = checked;
|
||||||
|
@ -223,7 +235,7 @@ void log_viewer::filter_log()
|
||||||
if (!m_log_levels.test(static_cast<u32>(logs::level::notice))) excluded_log_levels.push_back("·! ");
|
if (!m_log_levels.test(static_cast<u32>(logs::level::notice))) excluded_log_levels.push_back("·! ");
|
||||||
if (!m_log_levels.test(static_cast<u32>(logs::level::trace))) excluded_log_levels.push_back("·T ");
|
if (!m_log_levels.test(static_cast<u32>(logs::level::trace))) excluded_log_levels.push_back("·T ");
|
||||||
|
|
||||||
if (m_filter_term.isEmpty() && excluded_log_levels.empty() && m_show_threads && !m_last_actions_only)
|
if (m_filter_term.isEmpty() && excluded_log_levels.empty() && m_show_timestamps && m_show_threads && !m_last_actions_only)
|
||||||
{
|
{
|
||||||
set_text_and_keep_position(m_full_log);
|
set_text_and_keep_position(m_full_log);
|
||||||
return;
|
return;
|
||||||
|
@ -231,9 +243,10 @@ void log_viewer::filter_log()
|
||||||
|
|
||||||
QString result;
|
QString result;
|
||||||
QTextStream stream(&m_full_log);
|
QTextStream stream(&m_full_log);
|
||||||
const QRegularExpression thread_regexp("\{.*\} ");
|
const QRegularExpression thread_regexp("\\{.*\\} ");
|
||||||
|
const QRegularExpression timestamp_regexp("\\d?\\d:\\d\\d:\\d\\d\\.\\d\\d\\d\\d\\d\\d ");
|
||||||
|
|
||||||
const auto add_line = [this, &result, &excluded_log_levels, &thread_regexp](QString& line)
|
const auto add_line = [this, &result, &excluded_log_levels, ×tamp_regexp, &thread_regexp](QString& line)
|
||||||
{
|
{
|
||||||
bool exclude_line = false;
|
bool exclude_line = false;
|
||||||
|
|
||||||
|
@ -253,6 +266,17 @@ void log_viewer::filter_log()
|
||||||
|
|
||||||
if (m_filter_term.isEmpty() || line.contains(m_filter_term))
|
if (m_filter_term.isEmpty() || line.contains(m_filter_term))
|
||||||
{
|
{
|
||||||
|
if (line.isEmpty())
|
||||||
|
{
|
||||||
|
result += "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_show_timestamps)
|
||||||
|
{
|
||||||
|
line.remove(timestamp_regexp);
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_show_threads)
|
if (!m_show_threads)
|
||||||
{
|
{
|
||||||
line.remove(thread_regexp);
|
line.remove(thread_regexp);
|
||||||
|
|
|
@ -34,6 +34,7 @@ private:
|
||||||
LogHighlighter* m_log_highlighter;
|
LogHighlighter* m_log_highlighter;
|
||||||
std::unique_ptr<find_dialog> m_find_dialog;
|
std::unique_ptr<find_dialog> m_find_dialog;
|
||||||
std::bitset<32> m_log_levels = std::bitset<32>(0b11111111u);
|
std::bitset<32> m_log_levels = std::bitset<32>(0b11111111u);
|
||||||
|
bool m_show_timestamps = true;
|
||||||
bool m_show_threads = true;
|
bool m_show_threads = true;
|
||||||
bool m_last_actions_only = false;
|
bool m_last_actions_only = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue