From 5706e0e5f31fd7ef9974e30eeee722f6943cb65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Tue, 6 Jul 2021 19:50:07 +0200 Subject: [PATCH] Remove custom logging functions --- src/autoprofilewatcher.cpp | 6 ++-- src/eventhandlers/uinputeventhandler.cpp | 4 +-- src/inputdaemon.cpp | 18 +++++----- src/joybutton.cpp | 20 +++++------ src/logger.cpp | 2 +- src/logger.h | 46 ------------------------ src/main.cpp | 24 ++++++------- src/mainwindow.cpp | 10 +++--- src/sdleventreader.cpp | 2 +- src/x11extras.cpp | 14 ++++---- 10 files changed, 48 insertions(+), 98 deletions(-) diff --git a/src/autoprofilewatcher.cpp b/src/autoprofilewatcher.cpp index 40336947..bb06e8da 100644 --- a/src/autoprofilewatcher.cpp +++ b/src/autoprofilewatcher.cpp @@ -135,9 +135,9 @@ void AutoProfileWatcher::runAppCheck() currentApplication = nowWindow; currentAppWindowTitle = nowWindowName; - Logger::LogDebug(QObject::tr("Active window changed to: Title = \"%1\", " - "Class = \"%2\", Program = \"%3\" or \"%4\".") - .arg(nowWindowName, nowWindowClass, appLocation, baseAppFileName)); + qInfo() << QObject::tr("Active window changed to: Title = \"%1\", " + "Class = \"%2\", Program = \"%3\" or \"%4\".") + .arg(nowWindowName, nowWindowClass, appLocation, baseAppFileName); QSet fullSet; diff --git a/src/eventhandlers/uinputeventhandler.cpp b/src/eventhandlers/uinputeventhandler.cpp index 9bf29f57..1d5bbc9c 100644 --- a/src/eventhandlers/uinputeventhandler.cpp +++ b/src/eventhandlers/uinputeventhandler.cpp @@ -479,12 +479,12 @@ void UInputEventHandler::printPostMessages() { if (!lastErrorString.isEmpty()) { - Logger::LogInfo(lastErrorString); + qInfo() << lastErrorString; } if (!uinputDeviceLocation.isEmpty()) { - Logger::LogInfo(tr("Using uinput device file %1").arg(uinputDeviceLocation)); + qInfo() << tr("Using uinput device file %1").arg(uinputDeviceLocation); } } diff --git a/src/inputdaemon.cpp b/src/inputdaemon.cpp index 0bbe790a..a2f37133 100644 --- a/src/inputdaemon.cpp +++ b/src/inputdaemon.cpp @@ -327,7 +327,7 @@ void InputDaemon::refresh() stop(); - Logger::LogInfo("Refreshing joystick list"); + qInfo() << "Refreshing joystick list"; QEventLoop q; connect(eventWorker, &SDLEventReader::sdlStarted, &q, &QEventLoop::quit); @@ -528,9 +528,8 @@ void InputDaemon::addInputDevice(int index, QMap &uniques, int &co m_joysticks->insert(tempJoystickID, damncontroller); trackcontrollers.insert(tempJoystickID, damncontroller); - Logger::LogInfo(QString("New game controller found - #%1 [%2]") - .arg(index + 1) - .arg(QTime::currentTime().toString("hh:mm:ss.zzz"))); + qInfo() << QString("New game controller found - #%1 [%2]".arg(index + 1).arg( + QTime::currentTime().toString("hh:mm:ss.zzz"))); emit deviceAdded(damncontroller); } else @@ -540,9 +539,8 @@ void InputDaemon::addInputDevice(int index, QMap &uniques, int &co Joystick *joystick = openJoystickDevice(index); if (joystick != nullptr) { - Logger::LogInfo(QString("New joystick found - #%1 [%2]") - .arg(index + 1) - .arg(QTime::currentTime().toString("hh:mm:ss.zzz"))); + qInfo() << QString("New joystick found - #%1 [%2]".arg(index + 1).arg( + QTime::currentTime().toString("hh:mm:ss.zzz"))); emit deviceAdded(joystick); } @@ -1143,9 +1141,9 @@ void InputDaemon::secondInputPass(QQueue *sdlEventQueue) if (device != nullptr) { - Logger::LogInfo(QString("Removing joystick #%1 [%2]") - .arg(device->getRealJoyNumber()) - .arg(QTime::currentTime().toString("hh:mm:ss.zzz"))); + qInfo() << QString("Removing joystick #%1 [%2]") + .arg(device->getRealJoyNumber()) + .arg(QTime::currentTime().toString("hh:mm:ss.zzz")); removeDevice(device); } diff --git a/src/joybutton.cpp b/src/joybutton.cpp index f6b6457d..6031fbf1 100644 --- a/src/joybutton.cpp +++ b/src/joybutton.cpp @@ -250,9 +250,9 @@ void JoyButton::joyEvent(bool pressed, bool ignoresets) } else if (!isButtonPressed && !activePress && turboTimer.isActive()) { turboTimer.stop(); - Logger::LogDebug(tr("Finishing turbo for button #%1 - %2") - .arg(m_parentSet->getInputDevice()->getRealJoyNumber()) - .arg(getPartialName())); + qDebug() << tr("Finishing turbo for button #%1 - %2") + .arg(m_parentSet->getInputDevice()->getRealJoyNumber()) + .arg(getPartialName()); if (isKeyPressed) turboEvent(); @@ -280,9 +280,9 @@ void JoyButton::joyEvent(bool pressed, bool ignoresets) } } else if (!isButtonPressed && !activePress) { - Logger::LogDebug(tr("Processing release for button #%1 - %2") - .arg(m_parentSet->getInputDevice()->getRealJoyNumber()) - .arg(getPartialName())); + qDebug() << tr("Processing release for button #%1 - %2") + .arg(m_parentSet->getInputDevice()->getRealJoyNumber()) + .arg(getPartialName()); waitForReleaseDeskEvent(); } @@ -306,9 +306,9 @@ void JoyButton::updateParamsAfterDistEvent() { if (distanceEvent()) { - Logger::LogDebug(tr("Distance change for button #%1 - %2") - .arg(m_parentSet->getInputDevice()->getRealJoyNumber()) - .arg(getPartialName())); + qDebug() << tr("Distance change for button #%1 - %2") + .arg(m_parentSet->getInputDevice()->getRealJoyNumber()) + .arg(getPartialName()); quitEvent = true; buttonHold.restart(); @@ -345,7 +345,7 @@ void JoyButton::startSequenceOfPressActive(bool isTurbo, QString debugText) currentAccelerationDistance = getAccelerationDistance(); - Logger::LogDebug(debugText.arg(m_parentSet->getInputDevice()->getRealJoyNumber()).arg(getPartialName())); + qDebug() << debugText.arg(m_parentSet->getInputDevice()->getRealJoyNumber()).arg(getPartialName()); } /** diff --git a/src/logger.cpp b/src/logger.cpp index 4c728dcd..3914776c 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -367,7 +367,7 @@ void Logger::setCurrentLogFile(QString filename) instance->outputFile.open(QIODevice::WriteOnly | QIODevice::Append); instance->outFileStream.setDevice(&instance->outputFile); instance->setCurrentStream(&instance->outFileStream); - instance->LogInfo(QObject::tr("Logging started"), true, true); + qInfo() << "Logging started"; } void Logger::setCurrentErrorLogFile(QString filename) diff --git a/src/logger.h b/src/logger.h index c119ad70..a49cd9a8 100644 --- a/src/logger.h +++ b/src/logger.h @@ -92,52 +92,6 @@ class Logger : public QObject static void appendLog(LogLevel level, const QString &message, bool newline = true); static void directLog(LogLevel level, const QString &message, bool newline = true); - // Some convenience functions that will hopefully speed up - // logging operations. - inline static void LogInfo(const QString &message, bool newline = true, bool direct = false) - { - if (!direct) - { - appendLog(LOG_INFO, message, newline); - } else - { - directLog(LOG_INFO, message, newline); - } - } - - inline static void LogDebug(const QString &message, bool newline = true, bool direct = false) - { - if (!direct) - { - appendLog(LOG_DEBUG, message, newline); - } else - { - directLog(LOG_DEBUG, message, newline); - } - } - - inline static void LogWarning(const QString &message, bool newline = true, bool direct = false) - { - if (!direct) - { - appendLog(LOG_WARNING, message, newline); - } else - { - directLog(LOG_WARNING, message, newline); - } - } - - inline static void LogError(const QString &message, bool newline = true, bool direct = false) - { - if (!direct) - { - appendLog(LOG_ERROR, message, newline); - } else - { - directLog(LOG_ERROR, message, newline); - } - } - inline static Logger *getInstance() { Q_ASSERT(instance != nullptr); diff --git a/src/main.cpp b/src/main.cpp index 8a5a6dc3..583280e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -424,13 +424,13 @@ int main(int argc, char *argv[]) if (pid == 0) { - appLogger.LogInfo(QObject::tr("Daemon launched"), true, true); + qInfo() << QObject::tr("Daemon launched"); localServer = new LocalAntiMicroServer(); localServer->startLocalServer(); } else if (pid < 0) { - appLogger.LogError(QObject::tr("Failed to launch daemon"), true, true); + qCritical() << QObject::tr("Failed to launch daemon"); deleteInputDevices(joysticks); delete joysticks; @@ -439,7 +439,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } else if (pid > 0) // We got a good pid, Close the Parent Process { - appLogger.LogInfo(QObject::tr("Launching daemon"), true, true); + qInfo() << QObject::tr("Launching daemon"); deleteInputDevices(joysticks); delete joysticks; @@ -462,8 +462,7 @@ int main(int argc, char *argv[]) if (X11Extras::getInstance()->display() == nullptr) { - appLogger.LogError(QObject::tr("Display string \"%1\" is not valid.").arg(cmdutility.getDisplayString()), - true, true); + qCritical() << QObject::tr("Display string \"%1\" is not valid.").arg(cmdutility.getDisplayString()); deleteInputDevices(joysticks); delete joysticks; @@ -486,7 +485,7 @@ int main(int argc, char *argv[]) if (sid < 0) { - appLogger.LogError(QObject::tr("Failed to set a signature id for the daemon"), true, true); + qCritical() << QObject::tr("Failed to set a signature id for the daemon"); deleteInputDevices(joysticks); delete joysticks; @@ -507,7 +506,7 @@ int main(int argc, char *argv[]) if ((chdir("/")) < 0) { - appLogger.LogError(QObject::tr("Failed to change working directory to /"), true, true); + qCritical() << QObject::tr("Failed to change working directory to /"); deleteInputDevices(joysticks); delete joysticks; @@ -546,8 +545,7 @@ int main(int argc, char *argv[]) if (X11Extras::getInstance()->display() == nullptr) { - appLogger.LogError(QObject::tr("Display string \"%1\" is not valid.").arg(cmdutility.getDisplayString()), - true, true); + qCritical() << QObject::tr("Display string \"%1\" is not valid.").arg(cmdutility.getDisplayString()); deleteInputDevices(joysticks); delete joysticks; @@ -767,7 +765,7 @@ int main(int argc, char *argv[]) if (!status && cmdutility.getEventGenerator() != EventHandlerFactory::fallBackIdentifier()) { QString eventDisplayName = EventHandlerFactory::handlerDisplayName(EventHandlerFactory::fallBackIdentifier()); - appLogger.LogInfo(QObject::tr("Attempting to use fallback option %1 for event generation.").arg(eventDisplayName)); + qInfo() << QObject::tr("Attempting to use fallback option %1 for event generation.").arg(eventDisplayName); if (keyMapper != nullptr) { @@ -793,7 +791,7 @@ int main(int argc, char *argv[]) if (!status) { - appLogger.LogError(QObject::tr("Failed to open event generator. Exiting.")); + qCritical() << QObject::tr("Failed to open event generator. Exiting."); appLogger.Log(); deleteInputDevices(joysticks); @@ -821,7 +819,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } else { - appLogger.LogInfo(QObject::tr("Using %1 as the event generator.").arg(factory->handler()->getName())); + qInfo() << QObject::tr("Using %1 as the event generator.").arg(factory->handler()->getName()); } PadderCommon::mouseHelperObj.initDeskWid(); @@ -874,7 +872,7 @@ int main(int argc, char *argv[]) int app_result = antimicrox.exec(); appLogger.Log(); // Log any remaining messages if they exist. - appLogger.LogInfo(QObject::tr("Quitting Program"), true, true); + qInfo() << QObject::tr("Quitting Program"); delete localServer; localServer = nullptr; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fae15eb5..a5b4fd5c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -293,8 +293,8 @@ void MainWindow::controllerMapOpening() { qDebug() << "Could not find a proper controller identifier. Exiting"; - Logger::LogInfo(tr("Could not find a proper controller identifier. " - "Exiting.")); + qInfo() << tr("Could not find a proper controller identifier. " + "Exiting."); qApp->quit(); } } @@ -1398,7 +1398,7 @@ void MainWindow::openGameControllerMappingWindow(bool openAsMain) } } else if (openAsMain) { - Logger::LogInfo(tr("Could not find controller. Exiting.")); + qInfo() << tr("Could not find controller. Exiting."); qApp->quit(); } } @@ -1517,10 +1517,10 @@ void MainWindow::autoprofileLoad(AutoProfileInfo *info) { if (info != nullptr) { - Logger::LogDebug(QObject::tr("Auto-switching to profile \"%1\".").arg(info->getProfileLocation())); + qDebug() << QObject::tr("Auto-switching to profile \"%1\".").arg(info->getProfileLocation()); } else { - Logger::LogError(QObject::tr("Auto-switching to nullptr profile!")); + qCritical() << QObject::tr("Auto-switching to nullptr profile!"); } #if defined(WITH_X11) diff --git a/src/sdleventreader.cpp b/src/sdleventreader.cpp index ba258662..12a70d7e 100644 --- a/src/sdleventreader.cpp +++ b/src/sdleventreader.cpp @@ -172,7 +172,7 @@ int SDLEventReader::eventStatus() switch (SDL_PeepEvents(nullptr, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) { case -1: { - Logger::LogError(QString("SDL Error: %1").arg(QString(SDL_GetError())), true, true); + qCritical() << QString("SDL Error: %1").arg(QString(SDL_GetError())), true, true; result = 0; break; diff --git a/src/x11extras.cpp b/src/x11extras.cpp index 4327bbfd..f7f1b06a 100644 --- a/src/x11extras.cpp +++ b/src/x11extras.cpp @@ -634,14 +634,14 @@ void X11Extras::x11ResetMouseAccelerationChange(QString pointerName) if (!result) { - Logger::LogInfo(tr("xinput extension was not found. No mouse acceleration changes will occur.")); + qInfo() << tr("xinput extension was not found. No mouse acceleration changes will occur."); } else { int ximajor = 2, ximinor = 0; if (XIQueryVersion(display, &ximajor, &ximinor) != Success) { - Logger::LogInfo(tr("xinput version must be at least 2.0. No mouse acceleration changes will occur.")); + qInfo() << tr("xinput version must be at least 2.0. No mouse acceleration changes will occur."); result = false; } } @@ -673,14 +673,14 @@ void X11Extras::x11ResetMouseAccelerationChange(QString pointerName) if (feedback_id <= -1) { - Logger::LogInfo(tr("PtrFeedbackClass was not found for virtual pointer." - "No change to mouse acceleration will occur for device with id=%1") - .arg(device->device_id)); + qInfo() << tr("PtrFeedbackClass was not found for virtual pointer." + "No change to mouse acceleration will occur for device with id=%1") + .arg(device->device_id); result = false; } else { - Logger::LogInfo(tr("Changing mouse acceleration for device with id=%1").arg(device->device_id)); + qInfo() << tr("Changing mouse acceleration for device with id=%1").arg(device->device_id); XPtrFeedbackControl feedback; feedback.c_class = PtrFeedbackClass; @@ -725,7 +725,7 @@ struct X11Extras::ptrInformation X11Extras::getPointInformation(QString pointerN if (XIQueryVersion(display, &ximajor, &ximinor) != Success) { - Logger::LogInfo(QObject::tr("xinput version must be at least 2.0. No mouse acceleration changes will occur.")); + qInfo() << QObject::tr("xinput version must be at least 2.0. No mouse acceleration changes will occur."); result = false; } }