Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging rework #807

Merged
merged 27 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bc9f286
moved the log to a dock widget
isanae Jul 12, 2019
54d98e2
removed unused or redundant stuff in error_report.h
isanae Jul 16, 2019
6217f91
renamed logbuffer files to loglist
isanae Jul 16, 2019
d1b4dec
moved setup to new LogList class
isanae Jul 16, 2019
bca6283
use log::Levels instead of ints
isanae Jul 17, 2019
ad77e31
moved Console to util
isanae Jul 17, 2019
4dfaa36
logging initialized early, log file set later
isanae Jul 17, 2019
3bf7717
moved Settings out of OrganizerCore so it can be created by itself to…
isanae Jul 17, 2019
28c46ee
reversed log level menu actions to fit settings combobox
isanae Jul 17, 2019
eb19038
dump executables on startup
isanae Jul 17, 2019
35ae099
check for files likely to be eaten by an AV on startup
isanae Jul 17, 2019
2ef32d1
moved environment dump to member function
isanae Jul 17, 2019
20ac714
fixed bad compare for nahimic
isanae Jul 17, 2019
c84240b
only display "inactive" for security products
isanae Jul 17, 2019
f95479b
log guid for security products
isanae Jul 19, 2019
b2a1e13
split env
isanae Jul 19, 2019
d8760ed
refactored Metrics and Display, no change in functionality
isanae Jul 19, 2019
f13f5e2
replaced qInfo() with log::info()
isanae Jul 19, 2019
aae6d6a
replaced qWarning()
isanae Jul 19, 2019
e071dfd
changed qCritical() to log::error()
isanae Jul 19, 2019
b3d0ddb
changed qDebug() to log::debug()
isanae Jul 19, 2019
f49efd6
replaced formatSystemMessageQ() with formatSystemMessage()
isanae Jul 19, 2019
5304d52
removed some useless logging
isanae Jul 19, 2019
3c7712a
moved setLogLevel() to OrganizerCore
isanae Jul 20, 2019
6f1a8f5
added clear option to log list
isanae Jul 20, 2019
9aa7a5a
renamed log actions
isanae Jul 20, 2019
e4cf2c3
missing bracket
isanae Aug 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)

ADD_COMPILE_OPTIONS($<$<CXX_COMPILER_ID:MSVC>:/MP> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELEASE>:/O2>> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELWITHDEBINFO>:/O2>>)
ADD_COMPILE_OPTIONS(
$<$<CXX_COMPILER_ID:MSVC>:/MP>
$<$<CXX_COMPILER_ID:MSVC>:/D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING>
$<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELEASE>:/O2>>
$<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELWITHDEBINFO>:/O2>>)

PROJECT(organizer)

Expand All @@ -11,9 +15,11 @@ set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
set(CMAKE_INSTALL_MESSAGE NEVER)

SET(DEPENDENCIES_DIR CACHE PATH "")

# hint to find qt in dependencies path
LIST(APPEND CMAKE_PREFIX_PATH ${QT_ROOT}/lib/cmake)
LIST(APPEND CMAKE_PREFIX_PATH ${LZ4_ROOT}/dll)
LIST(APPEND CMAKE_PREFIX_PATH ${FMT_ROOT}/build)

ADD_SUBDIRECTORY(src)

Expand Down
37 changes: 31 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SET(organizer_SRCS
mainwindow.cpp
main.cpp
loghighlighter.cpp
logbuffer.cpp
loglist.cpp
lockeddialogbase.cpp
lockeddialog.cpp
waitingonclosedialog.cpp
Expand Down Expand Up @@ -129,6 +129,12 @@ SET(organizer_SRCS
filerenamer.cpp
texteditor.cpp
expanderwidget.cpp
env.cpp
envmetrics.cpp
envmodule.cpp
envsecurity.cpp
envshortcut.cpp
envwindows.cpp

shared/windows_error.cpp
shared/error_report.cpp
Expand Down Expand Up @@ -181,7 +187,7 @@ SET(organizer_HDRS
messagedialog.h
mainwindow.h
loghighlighter.h
logbuffer.h
loglist.h
lockeddialogbase.h
lockeddialog.h
waitingonclosedialog.h
Expand Down Expand Up @@ -239,6 +245,12 @@ SET(organizer_HDRS
filerenamer.h
texteditor.h
expanderwidget.h
env.h
envmetrics.h
envmodule.h
envsecurity.h
envshortcut.h
envwindows.h

shared/windows_error.h
shared/error_report.h
Expand Down Expand Up @@ -350,6 +362,15 @@ set(downloads
downloadmanager
)

set(env
env
envmetrics
envmodule
envsecurity
envshortcut
envwindows
)

set(executables
executableslist
editexecutablesdialog
Expand Down Expand Up @@ -436,7 +457,7 @@ set(widgets
filterwidget
icondelegate
lcdnumber
logbuffer
loglist
loghighlighter
modflagicondelegate
modidlineedit
Expand All @@ -447,8 +468,8 @@ set(widgets
)

set(src_filters
application core browser dialogs downloads executables locking modinfo modinfo\\dialog
modlist plugins previews profiles settings utilities widgets
application core browser dialogs downloads env executables locking modinfo
modinfo\\dialog modlist plugins previews profiles settings utilities widgets
)

foreach(filter in list ${src_filters})
Expand Down Expand Up @@ -520,6 +541,9 @@ LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
FIND_PACKAGE(zlib REQUIRED)
# TODO FindZlib doesn't find the static zlib library

# fmt
find_package(fmt REQUIRED)

INCLUDE_DIRECTORIES(${project_path}/uibase/src
${project_path}/bsatk/src
${project_path}/esptk/src
Expand Down Expand Up @@ -551,10 +575,11 @@ ELSE()
ENDIF()

ADD_EXECUTABLE(ModOrganizer WIN32 ${organizer_HDRS} ${organizer_SRCS} ${organizer_UIS} ${organizer_RCS} ${organizer_QRCS} ${organizer_translations_qm})

TARGET_LINK_LIBRARIES(ModOrganizer
Qt5::Widgets Qt5::WinExtras Qt5::WebEngineWidgets Qt5::Quick
Qt5::Qml Qt5::QuickWidgets Qt5::Network Qt5::WebSockets
${Boost_LIBRARIES}
${Boost_LIBRARIES} fmt::fmt
zlibstatic
uibase esptk bsatk githubpp
${usvfs_name}
Expand Down
9 changes: 4 additions & 5 deletions src/bbcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/

#include "bbcode.h"

#include <log.h>
#include <QRegExp>
#include <map>


namespace BBCode {

namespace log = MOBase::log;

class BBCodeMap {

Expand Down Expand Up @@ -88,7 +88,7 @@ class BBCodeMap {
return temp.replace(tagIter->second.first, QString("<font style=\"color: #%1;\">%2</font>").arg(color, content));
}
} else {
qWarning("don't know how to deal with tag %s", qUtf8Printable(tagName));
log::warn("don't know how to deal with tag {}", tagName);
}
} else {
if (tagName == "*") {
Expand All @@ -99,8 +99,7 @@ class BBCodeMap {
} else {
// expression doesn't match. either the input string is invalid
// or the expression is
qWarning("%s doesn't match the expression for %s",
qUtf8Printable(temp), qUtf8Printable(tagName));
log::warn("{} doesn't match the expression for {}", temp, tagName);
length = 0;
return QString();
}
Expand Down
12 changes: 7 additions & 5 deletions src/browserdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "messagedialog.h"
#include "report.h"
#include "persistentcookiejar.h"
#include "settings.h"

#include <utility.h>
#include "settings.h"
#include <log.h>

#include <QWebEngineSettings>
#include <QNetworkCookieJar>
Expand All @@ -38,6 +39,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QDesktopWidget>
#include <QKeyEvent>

using namespace MOBase;


BrowserDialog::BrowserDialog(QWidget *parent)
Expand Down Expand Up @@ -192,12 +194,12 @@ void BrowserDialog::unsupportedContent(QNetworkReply *reply)
try {
QWebEnginePage *page = qobject_cast<QWebEnginePage*>(sender());
if (page == nullptr) {
qCritical("sender not a page");
log::error("sender not a page");
return;
}
BrowserView *view = qobject_cast<BrowserView*>(page->view());
if (view == nullptr) {
qCritical("no view?");
log::error("no view?");
return;
}

Expand All @@ -206,14 +208,14 @@ void BrowserDialog::unsupportedContent(QNetworkReply *reply)
if (isVisible()) {
MessageDialog::showMessage(tr("failed to start download"), this);
}
qCritical("exception downloading unsupported content: %s", e.what());
log::error("exception downloading unsupported content: {}", e.what());
}
}


void BrowserDialog::downloadRequested(const QNetworkRequest &request)
{
qCritical("download request %s ignored", request.url().toString().toUtf8().constData());
log::error("download request {} ignored", request.url().toString());
}


Expand Down
17 changes: 9 additions & 8 deletions src/categories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.

#include <utility.h>
#include <report.h>
#include <log.h>

#include <QObject>
#include <QFile>
Expand Down Expand Up @@ -61,8 +62,9 @@ void CategoryFactory::loadCategories()
++lineNum;
QList<QByteArray> cells = line.split('|');
if (cells.count() != 4) {
qCritical("invalid category line %d: %s (%d cells)",
lineNum, line.constData(), cells.count());
log::error(
"invalid category line {}: {} ({} cells)",
lineNum, line.constData(), cells.count());
} else {
std::vector<int> nexusIDs;
if (cells[2].length() > 0) {
Expand All @@ -72,7 +74,7 @@ void CategoryFactory::loadCategories()
bool ok = false;
int temp = iter->toInt(&ok);
if (!ok) {
qCritical("invalid category id %s", iter->constData());
log::error("invalid category id {}", iter->constData());
}
nexusIDs.push_back(temp);
}
Expand All @@ -82,8 +84,7 @@ void CategoryFactory::loadCategories()
int id = cells[0].toInt(&cell0Ok);
int parentID = cells[3].trimmed().toInt(&cell3Ok);
if (!cell0Ok || !cell3Ok) {
qCritical("invalid category line %d: %s",
lineNum, line.constData());
log::error("invalid category line {}: {}", lineNum, line.constData());
}
addCategory(id, QString::fromUtf8(cells[1].constData()), nexusIDs, parentID);
}
Expand Down Expand Up @@ -294,7 +295,7 @@ bool CategoryFactory::isDecendantOf(int id, int parentID) const
return isDecendantOf(m_Categories[index].m_ParentID, parentID);
}
} else {
qWarning("%d is no valid category id", id);
log::warn("{} is no valid category id", id);
return false;
}
}
Expand Down Expand Up @@ -359,10 +360,10 @@ unsigned int CategoryFactory::resolveNexusID(int nexusID) const
{
std::map<int, unsigned int>::const_iterator iter = m_NexusMap.find(nexusID);
if (iter != m_NexusMap.end()) {
qDebug("nexus category id %d maps to internal %d", nexusID, iter->second);
log::debug("nexus category id {} maps to internal {}", nexusID, iter->second);
return iter->second;
} else {
qDebug("nexus category id %d not mapped", nexusID);
log::debug("nexus category id {} not mapped", nexusID);
return 0U;
}
}
4 changes: 2 additions & 2 deletions src/directoryrefresher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void DirectoryRefresher::addModFilesToStructure(DirectoryEntry *directoryStructu
FilesOrigin &origin = directoryStructure->createOrigin(ToWString(modName), directoryW, priority);
for (const QString &filename : stealFiles) {
if (filename.isEmpty()) {
qWarning("Trying to find file with no name");
log::warn("Trying to find file with no name");
continue;
}
QFileInfo fileInfo(filename);
Expand All @@ -143,7 +143,7 @@ void DirectoryRefresher::addModFilesToStructure(DirectoryEntry *directoryStructu
QString warnStr = fileInfo.absolutePath();
if (warnStr.isEmpty())
warnStr = filename;
qWarning("file not found: %s", qUtf8Printable(warnStr));
log::warn("file not found: {}", warnStr);
}
}
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/downloadlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.

#include "downloadlist.h"
#include "downloadmanager.h"
#include <log.h>
#include <QEvent>
#include <QColor>
#include <QIcon>

#include <QSortFilterProxyModel>

using namespace MOBase;

DownloadList::DownloadList(DownloadManager *manager, QObject *parent)
: QAbstractTableModel(parent), m_Manager(manager)
Expand Down Expand Up @@ -192,7 +193,7 @@ void DownloadList::update(int row)
else if (row < this->rowCount())
emit dataChanged(this->index(row, 0, QModelIndex()), this->index(row, this->columnCount(QModelIndex())-1, QModelIndex()));
else
qCritical("invalid row %d in download list, update failed", row);
log::error("invalid row {} in download list, update failed", row);
}

QString DownloadList::sizeFormat(quint64 size) const
Expand Down
5 changes: 4 additions & 1 deletion src/downloadlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.

#include "downloadlist.h"
#include "downloadlistwidget.h"
#include <log.h>
#include <QPainter>
#include <QMouseEvent>
#include <QMenu>
Expand All @@ -29,6 +30,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QCheckBox>
#include <QWidgetAction>

using namespace MOBase;

void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QModelIndex sourceIndex = m_SortProxy->mapToSource(index);
Expand Down Expand Up @@ -286,7 +289,7 @@ void DownloadListWidget::issueDelete()

void DownloadListWidget::issueRemoveFromView()
{
qDebug() << "removing from view: " << m_ContextRow;
log::debug("removing from view: {}", m_ContextRow);
emit removeDownload(m_ContextRow, false);
}

Expand Down
Loading