Skip to content

Commit

Permalink
feat: replace settings by logs directory in log tab (fix #3205)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jun 13, 2024
1 parent 5dcf26d commit fce0186
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/gui/src/tabs/log-tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ void LogTab::open()

void LogTab::openDir()
{
QDir dir(savePath());
if (dir.exists()) {
showInGraphicalShell(dir.absolutePath());
}
showInGraphicalShell(Logger::getInstance().logDirectory());
}

void LogTab::changeEvent(QEvent *event)
Expand Down
8 changes: 4 additions & 4 deletions src/gui/src/tabs/log-tab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ QTextEdit {
}</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
Expand All @@ -56,7 +56,7 @@ QTextEdit {
<bool>false</bool>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
<enum>QPlainTextEdit::LineWrapMode::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
Expand All @@ -82,7 +82,7 @@ QTextEdit {
<item>
<widget class="QPushButton" name="buttonOpenDir">
<property name="text">
<string>Open settings directory</string>
<string>Open log directory</string>
</property>
</widget>
</item>
Expand Down
5 changes: 4 additions & 1 deletion src/lib/src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
void Logger::initialize()
{
// Create the "logs/" directory if it doesn't exist
const QDir logsDirectory = savePath(QStringLiteral("logs/"), false, true);
m_logDirectory = savePath(QStringLiteral("logs/"), false, true);
const QDir logsDirectory(m_logDirectory);
if (!logsDirectory.exists()) {
logsDirectory.mkpath(".");
}
Expand Down Expand Up @@ -51,6 +52,8 @@ void Logger::setLogFile(const QString &path)
}
QString Logger::logFile() const
{ return m_logFile.fileName(); }
QString Logger::logDirectory() const
{ return m_logDirectory; }

/**
* Sets the minimum log level for which messages will not be ignored.
Expand Down
2 changes: 2 additions & 0 deletions src/lib/src/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ class Logger : public QObject
void logToConsole();

QString logFile() const;
QString logDirectory() const;

signals:
void newLog(const QString &message);

private:
Logger() = default;
QString m_logDirectory;
QFile m_logFile, m_fCommandsLog, m_fCommandsSqlLog;
LogLevel m_level = LogLevel::Info;
LogLevel m_consoleOutputLevel = LogLevel::Error;
Expand Down

0 comments on commit fce0186

Please sign in to comment.