Skip to content

Commit 0a9983b

Browse files
Revert "Add support for logging to a log file in the $XDG_STATE_DIR/flameshot…" (flameshot-org#4425)
This reverts commit 0f37bf0.
1 parent 7ed3cfc commit 0a9983b

File tree

14 files changed

+18
-319
lines changed

14 files changed

+18
-319
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,3 @@ if (APPLE)
539539

540540

541541
endif ()
542-
543-
if(${Qt6Core_VERSION} VERSION_GREATER_EQUAL 6.7)
544-
target_compile_definitions(flameshot PRIVATE QT_STATE_DIR_SUPPORTED=1)
545-
endif()

src/config/generalconf.cpp

Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors
33
#include "generalconf.h"
44
#include "src/core/flameshot.h"
5-
#include "src/utils/abstractlogger.h"
65
#include "src/utils/confighandler.h"
7-
#include "src/utils/logfile.h"
86
#include <QCheckBox>
97
#include <QComboBox>
108
#include <QFile>
@@ -58,7 +56,6 @@ GeneralConf::GeneralConf(QWidget* parent)
5856
initAntialiasingPinZoom();
5957
initUndoLimit();
6058
initInsecurePixelate();
61-
initLogToFile();
6259
#ifdef ENABLE_IMGUR
6360
initCopyAndCloseAfterUpload();
6461
initUploadWithoutConfirmation();
@@ -124,9 +121,6 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
124121
if (allowEmptySavePath || !config.savePath().isEmpty()) {
125122
m_savePath->setText(config.savePath());
126123
}
127-
m_logToFile->setChecked(config.logToFile());
128-
m_logFilePath->setText(config.logFilePath());
129-
130124
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
131125
m_showTray->setChecked(!config.disabledTrayIcon());
132126
#endif
@@ -250,7 +244,6 @@ void GeneralConf::resetConfiguration()
250244
if (reply == QMessageBox::Yes) {
251245
m_savePath->setText(
252246
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
253-
m_logFilePath->setText(LogFile::defaultLogFilePath());
254247
ConfigHandler().setDefaultSettings();
255248
_updateComponents(true);
256249
}
@@ -719,33 +712,6 @@ void GeneralConf::changeSavePath()
719712
}
720713
}
721714

722-
void GeneralConf::changeLogFilePath()
723-
{
724-
QString path = ConfigHandler().logFilePath();
725-
726-
if (path.isEmpty()) {
727-
path = LogFile::defaultLogFilePath();
728-
}
729-
730-
path = QFileDialog::getExistingDirectory(
731-
this,
732-
tr("Choose a Folder"),
733-
path,
734-
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
735-
736-
if (!QFileInfo(path).isWritable()) {
737-
QMessageBox::about(
738-
this, tr("Error"), tr("Unable to write to directory."));
739-
path = QString();
740-
}
741-
742-
if (!path.isEmpty()) {
743-
m_logFilePath->setText(path);
744-
ConfigHandler().setLogFilePath(path);
745-
LogFile::resetLogFile();
746-
}
747-
}
748-
749715
void GeneralConf::initCopyPathAfterSave()
750716
{
751717
m_copyPathAfterSave = new QCheckBox(tr("Copy file path after save"), this);
@@ -920,7 +886,7 @@ void GeneralConf::initInsecurePixelate()
920886
{
921887
m_insecurePixelate = new QCheckBox(tr("Insecure Pixelate"), this);
922888
m_insecurePixelate->setToolTip(
923-
tr("Draw the pixelation effect in an insecure but more aesthetic way."));
889+
tr("Draw the pixelation effect in an insecure but more asethetic way."));
924890
m_insecurePixelate->setChecked(ConfigHandler().insecurePixelate());
925891
m_scrollAreaLayout->addWidget(m_insecurePixelate);
926892

@@ -930,70 +896,6 @@ void GeneralConf::initInsecurePixelate()
930896
&GeneralConf::setInsecurePixelate);
931897
}
932898

933-
void GeneralConf::initLogToFile()
934-
{
935-
auto* box = new QGroupBox(tr("Logging"));
936-
box->setFlat(true);
937-
m_layout->addWidget(box);
938-
939-
auto* vboxLayout = new QVBoxLayout();
940-
box->setLayout(vboxLayout);
941-
942-
m_logToFile = new QCheckBox(tr("Log to file"), this);
943-
m_logToFile->setToolTip(
944-
tr("Save all log messages produced by flameshot to a file"));
945-
m_logToFile->setChecked(ConfigHandler().logToFile());
946-
947-
connect(m_logToFile, &QCheckBox::clicked, this, &GeneralConf::setLogToFile);
948-
vboxLayout->addWidget(m_logToFile);
949-
950-
auto* pathLayout = new QHBoxLayout();
951-
952-
QString path = ConfigHandler().logFilePath();
953-
m_logFilePath = new QLineEdit(path, this);
954-
m_logFilePath->setToolTip(
955-
tr("The directory where log files will be saved"));
956-
m_logFilePath->setDisabled(true);
957-
QString foreground = this->palette().windowText().color().name();
958-
m_logFilePath->setStyleSheet(QStringLiteral("color:%1").arg(foreground));
959-
pathLayout->addWidget(m_logFilePath);
960-
961-
m_changeLogFilePathButton = new QPushButton(tr("Change..."), this);
962-
pathLayout->addWidget(m_changeLogFilePathButton);
963-
connect(m_changeLogFilePathButton,
964-
&QPushButton::clicked,
965-
this,
966-
&GeneralConf::changeLogFilePath);
967-
968-
vboxLayout->addLayout(pathLayout);
969-
970-
auto* levelLayout = new QHBoxLayout();
971-
auto* levelLabel = new QLabel(tr("Minimum Log Level"));
972-
levelLabel->setToolTip(
973-
tr("Specify the minimum severity level of log messages that "
974-
"should be saved to disk"));
975-
levelLayout->addWidget(levelLabel);
976-
977-
m_logFileLevel = new QComboBox(this);
978-
979-
m_logFileLevel->addItem(tr("Info (All Log Messages)"),
980-
AbstractLogger::Channel::Info);
981-
m_logFileLevel->addItem(tr("Warnings and Errors"),
982-
AbstractLogger::Channel::Warning);
983-
m_logFileLevel->addItem(tr("Errors"), AbstractLogger::Channel::Error);
984-
985-
auto level = ConfigHandler().value("logFileLevel").toInt();
986-
m_logFileLevel->setCurrentIndex(m_logFileLevel->findData(level));
987-
988-
connect(
989-
m_logFileLevel,
990-
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
991-
this,
992-
&GeneralConf::setLogFileLevel);
993-
levelLayout->addWidget(m_logFileLevel);
994-
vboxLayout->addLayout(levelLayout);
995-
}
996-
997899
void GeneralConf::setSelGeoHideTime(int v)
998900
{
999901
ConfigHandler().setValue("showSelectionGeometryHideTime", v);
@@ -1033,14 +935,4 @@ void GeneralConf::setReverseArrow(bool checked)
1033935
void GeneralConf::setInsecurePixelate(bool checked)
1034936
{
1035937
ConfigHandler().setInsecurePixelate(checked);
1036-
}
1037-
1038-
void GeneralConf::setLogToFile(bool checked)
1039-
{
1040-
ConfigHandler().setLogToFile(checked);
1041-
}
1042-
1043-
void GeneralConf::setLogFileLevel(int index)
1044-
{
1045-
ConfigHandler().setValue("logFileLevel", m_logFileLevel->itemData(index));
1046-
}
938+
}

src/config/generalconf.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ private slots:
5050
void undoLimit(int limit);
5151
void saveAfterCopyChanged(bool checked);
5252
void changeSavePath();
53-
void changeLogFilePath();
5453
void importConfiguration();
5554
void exportFileConfiguration();
5655
void resetConfiguration();
@@ -63,8 +62,6 @@ private slots:
6362
void setJpegQuality(int v);
6463
void setReverseArrow(bool checked);
6564
void setInsecurePixelate(bool checked);
66-
void setLogToFile(bool checked);
67-
void setLogFileLevel(int index);
6865

6966
private:
7067
const QString chooseFolder(const QString& currentPath = "");
@@ -104,7 +101,6 @@ private slots:
104101
void initJpegQuality();
105102
void initReverseArrow();
106103
void initInsecurePixelate();
107-
void initLogToFile();
108104

109105
void _updateComponents(bool allowEmptySavePath);
110106

@@ -154,8 +150,4 @@ private slots:
154150
QSpinBox* m_jpegQuality;
155151
QCheckBox* m_reverseArrow;
156152
QCheckBox* m_insecurePixelate;
157-
QCheckBox* m_logToFile;
158-
QLineEdit* m_logFilePath;
159-
QPushButton* m_changeLogFilePathButton;
160-
QComboBox* m_logFileLevel;
161153
};

src/utils/CMakeLists.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@ target_sources(
2525
colorutils.cpp
2626
history.cpp
2727
strfparse.cpp
28-
logfile.cpp
2928
)
3029

3130
IF (UNIX AND NOT APPLE)
32-
target_sources(
33-
flameshot
34-
PRIVATE request.h
35-
request.cpp
36-
)
31+
target_sources(
32+
flameshot
33+
PRIVATE request.h
34+
request.cpp
35+
)
3736
ENDIF()
3837

3938
IF (WIN32)
40-
target_sources(
41-
flameshot
42-
PRIVATE winlnkfileparse.cpp
43-
)
39+
target_sources(
40+
flameshot
41+
PRIVATE winlnkfileparse.cpp
42+
)
4443
ENDIF()

src/utils/abstractlogger.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#include "abstractlogger.h"
2-
#include "confighandler.h"
3-
#include "logfile.h"
42
#include "systemnotification.h"
53
#include <cassert>
64

7-
#include <QDateTime>
85
#include <QFileInfo>
96

107
AbstractLogger::AbstractLogger(Channel channel, int targets)
118
: m_defaultChannel(channel)
129
, m_targets(targets)
13-
{}
10+
{
11+
if (targets & LogFile) {
12+
// TODO
13+
}
14+
}
1415

1516
/**
1617
* @brief Construct an AbstractLogger with output to a string.
@@ -55,12 +56,8 @@ AbstractLogger& AbstractLogger::sendMessage(const QString& msg, Channel channel)
5556
*stream << messageHeader(channel, String) << msg << "\n";
5657
}
5758
}
58-
if (m_targets & LogFile && ConfigHandler().logToFile()) {
59-
if (channel >= ConfigHandler().logFileLevel()) {
60-
QString data;
61-
data = messageHeader(channel, LogFile) + msg + "\n";
62-
LogFile::write(&data);
63-
}
59+
if (m_targets & LogFile) {
60+
// TODO
6461
}
6562
if (m_targets & Stderr) {
6663
QTextStream stream(stderr);
@@ -135,9 +132,6 @@ QString AbstractLogger::messageHeader(Channel channel, Target target)
135132
if (target == Notification) {
136133
messageChannel[0] = messageChannel[0].toUpper();
137134
return "Flameshot " + messageChannel;
138-
} else if (target == LogFile) {
139-
return QDateTime::currentDateTime().toString(Qt::ISODateWithMs) + ":[" +
140-
messageChannel + "]: ";
141135
} else {
142136
return "flameshot: " + messageChannel + ": ";
143137
}

src/utils/confighandler.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
138138
OPTION("jpegQuality" , BoundedInt ( 0,100,75 )),
139139
OPTION("reverseArrow" ,Bool ( false )),
140140
OPTION("insecurePixelate" ,Bool ( false )),
141-
OPTION("logToFile" ,Bool ( true )),
142-
OPTION("logFilePath" ,LoggingDir ( )),
143-
OPTION("logFileLevel" ,BoundedInt ( AbstractLogger::Channel::Info, AbstractLogger::Channel::Error, AbstractLogger::Channel::Info)),
144141
};
145142

146143
static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {

src/utils/confighandler.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ class ConfigHandler : public QObject
141141
CONFIG_GETTER_SETTER(showSelectionGeometryHideTime,
142142
showSelectionGeometryHideTime,
143143
int)
144-
CONFIG_GETTER_SETTER(logToFile, setLogToFile, bool)
145-
CONFIG_GETTER_SETTER(logFilePath, setLogFilePath, QString)
146-
CONFIG_GETTER_SETTER(logFileLevel, setLogFileLevel, int)
147144

148145
// SPECIAL CASES
149146
bool startupLaunch();

src/utils/logfile.cpp

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)