GH-1008 implement log window max line count
Defaults to 100k lines
This commit is contained in:
parent
1feb4bb387
commit
9684d3b0a0
@ -454,6 +454,8 @@ void MultiMC::initGlobalSettings(bool test_mode)
|
|||||||
m_settings->registerSetting("ConsoleFont", defaultMonospace);
|
m_settings->registerSetting("ConsoleFont", defaultMonospace);
|
||||||
}
|
}
|
||||||
m_settings->registerSetting("ConsoleFontSize", defaultSize);
|
m_settings->registerSetting("ConsoleFontSize", defaultSize);
|
||||||
|
m_settings->registerSetting("ConsoleMaxLines", 100000);
|
||||||
|
m_settings->registerSetting("ConsoleOverflowStop", true);
|
||||||
|
|
||||||
FTBPlugin::initialize(m_settings);
|
FTBPlugin::initialize(m_settings);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
|
#include <settings/Setting.h>
|
||||||
#include "GuiUtil.h"
|
#include "GuiUtil.h"
|
||||||
|
|
||||||
LogPage::LogPage(BaseProcess *proc, QWidget *parent)
|
LogPage::LogPage(BaseProcess *proc, QWidget *parent)
|
||||||
@ -29,6 +30,18 @@ LogPage::LogPage(BaseProcess *proc, QWidget *parent)
|
|||||||
}
|
}
|
||||||
defaultFormat->setFont(QFont(fontFamily, fontSize));
|
defaultFormat->setFont(QFont(fontFamily, fontSize));
|
||||||
|
|
||||||
|
// ensure we don't eat all the RAM
|
||||||
|
auto lineSetting = MMC->settings()->getSetting("ConsoleMaxLines");
|
||||||
|
int maxLines = lineSetting->get().toInt(&conversionOk);
|
||||||
|
if(!conversionOk)
|
||||||
|
{
|
||||||
|
maxLines = lineSetting->defValue().toInt();
|
||||||
|
qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines;
|
||||||
|
}
|
||||||
|
ui->text->setMaximumBlockCount(maxLines);
|
||||||
|
|
||||||
|
m_stopOnOverflow = MMC->settings()->get("ConsoleOverflowStop").toBool();
|
||||||
|
|
||||||
auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this);
|
auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this);
|
||||||
connect(findShortcut, SIGNAL(activated()), SLOT(findActivated()));
|
connect(findShortcut, SIGNAL(activated()), SLOT(findActivated()));
|
||||||
auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this);
|
auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this);
|
||||||
@ -126,6 +139,11 @@ void LogPage::findPreviousActivated()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogPage::setParentContainer(BasePageContainer * container)
|
||||||
|
{
|
||||||
|
m_parentContainer = container;
|
||||||
|
}
|
||||||
|
|
||||||
void LogPage::write(QString data, MessageLevel::Enum mode)
|
void LogPage::write(QString data, MessageLevel::Enum mode)
|
||||||
{
|
{
|
||||||
if (!m_write_active)
|
if (!m_write_active)
|
||||||
@ -135,6 +153,26 @@ void LogPage::write(QString data, MessageLevel::Enum mode)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(m_stopOnOverflow && m_write_active)
|
||||||
|
{
|
||||||
|
if(mode != MessageLevel::PrePost && mode != MessageLevel::MultiMC)
|
||||||
|
{
|
||||||
|
if(ui->text->blockCount() >= ui->text->maximumBlockCount())
|
||||||
|
{
|
||||||
|
m_write_active = false;
|
||||||
|
data = tr("MultiMC stopped watching the game log because the log length surpassed %1 lines.\n"
|
||||||
|
"You may have to fix your mods because the game is still loggging to files and"
|
||||||
|
" likely wasting harddrive space at an alarming rate!")
|
||||||
|
.arg(ui->text->maximumBlockCount());
|
||||||
|
mode = MessageLevel::Fatal;
|
||||||
|
ui->trackLogCheckbox->setCheckState(Qt::Unchecked);
|
||||||
|
if(!isVisible())
|
||||||
|
{
|
||||||
|
m_parentContainer->selectPage(id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// save the cursor so it can be restored.
|
// save the cursor so it can be restored.
|
||||||
auto savedCursor = ui->text->cursor();
|
auto savedCursor = ui->text->cursor();
|
||||||
|
@ -53,6 +53,7 @@ public:
|
|||||||
return "Minecraft-Logs";
|
return "Minecraft-Logs";
|
||||||
}
|
}
|
||||||
virtual bool shouldDisplay() const;
|
virtual bool shouldDisplay() const;
|
||||||
|
virtual void setParentContainer(BasePageContainer *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
/**
|
||||||
@ -81,6 +82,8 @@ private:
|
|||||||
bool m_scroll_active = true;
|
bool m_scroll_active = true;
|
||||||
int m_saved_offset = 0;
|
int m_saved_offset = 0;
|
||||||
bool m_write_active = true;
|
bool m_write_active = true;
|
||||||
|
bool m_stopOnOverflow = true;
|
||||||
|
|
||||||
QTextCharFormat * defaultFormat;
|
QTextCharFormat * defaultFormat;
|
||||||
|
BasePageContainer * m_parentContainer;
|
||||||
};
|
};
|
||||||
|
@ -299,6 +299,8 @@ void MultiMCPage::applySettings()
|
|||||||
QString consoleFontFamily = ui->consoleFont->currentFont().family();
|
QString consoleFontFamily = ui->consoleFont->currentFont().family();
|
||||||
s->set("ConsoleFont", consoleFontFamily);
|
s->set("ConsoleFont", consoleFontFamily);
|
||||||
s->set("ConsoleFontSize", ui->fontSizeBox->value());
|
s->set("ConsoleFontSize", ui->fontSizeBox->value());
|
||||||
|
s->set("ConsoleMaxLines", ui->lineLimitSpinBox->value());
|
||||||
|
s->set("ConsoleOverflowStop", ui->checkStopLogging->checkState() != Qt::Unchecked);
|
||||||
|
|
||||||
// FTB
|
// FTB
|
||||||
s->set("TrackFTBInstances", ui->trackFtbBox->isChecked());
|
s->set("TrackFTBInstances", ui->trackFtbBox->isChecked());
|
||||||
@ -388,6 +390,8 @@ void MultiMCPage::loadSettings()
|
|||||||
}
|
}
|
||||||
ui->fontSizeBox->setValue(fontSize);
|
ui->fontSizeBox->setValue(fontSize);
|
||||||
refreshFontPreview();
|
refreshFontPreview();
|
||||||
|
ui->lineLimitSpinBox->setValue(s->get("ConsoleMaxLines").toInt());
|
||||||
|
ui->checkStopLogging->setChecked(s->get("ConsoleOverflowStop").toBool());
|
||||||
|
|
||||||
// FTB
|
// FTB
|
||||||
ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool());
|
ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool());
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>487</width>
|
<width>487</width>
|
||||||
<height>519</height>
|
<height>557</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -433,6 +433,47 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
|
<property name="title">
|
||||||
|
<string>History limit</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkStopLogging">
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop logging when log overflows</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QSpinBox" name="lineLimitSpinBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string> lines</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>10000</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1000000</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>100000</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="themeBox_2">
|
<widget class="QGroupBox" name="themeBox_2">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -520,6 +561,8 @@
|
|||||||
<tabstop>themeComboBox</tabstop>
|
<tabstop>themeComboBox</tabstop>
|
||||||
<tabstop>showConsoleCheck</tabstop>
|
<tabstop>showConsoleCheck</tabstop>
|
||||||
<tabstop>autoCloseConsoleCheck</tabstop>
|
<tabstop>autoCloseConsoleCheck</tabstop>
|
||||||
|
<tabstop>lineLimitSpinBox</tabstop>
|
||||||
|
<tabstop>checkStopLogging</tabstop>
|
||||||
<tabstop>consoleFont</tabstop>
|
<tabstop>consoleFont</tabstop>
|
||||||
<tabstop>fontSizeBox</tabstop>
|
<tabstop>fontSizeBox</tabstop>
|
||||||
<tabstop>fontPreview</tabstop>
|
<tabstop>fontPreview</tabstop>
|
||||||
|
Loading…
Reference in New Issue
Block a user