[kstars] /: Migrating KStars to use QLoggingCategory framework which supports granular control over logging in runtime.

Jasem Mutlaq null at kde.org
Sun Aug 6 19:29:38 UTC 2017


Git commit 5028e958caf97eaadd5c30cd442254e37fd84088 by Jasem Mutlaq.
Committed on 06/08/2017 at 19:26.
Pushed by mutlaqja into branch 'master'.

Migrating KStars to use QLoggingCategory framework which supports granular control over logging in runtime.

The migration is still not complete yet but the base structure is there and operational and we should migrate any qDebug..et al when appropiate to use the QLoggingCategory framework. When you write code, you must abide by this, I will not accept any code that does not use the framework when logging.

BUGS:383177
CCMAIL:kstars-devel at kde.org

M  +1    -0    CMakeLists.txt
M  +2    -0    datahandlers/CMakeLists.txt
M  +17   -16   datahandlers/catalogdb.cpp
M  +12   -0    kstars/CMakeLists.txt
M  +0    -1    kstars/auxiliary/kspaths.cpp
M  +15   -13   kstars/auxiliary/ksuserdb.cpp
M  +47   -14   kstars/auxiliary/ksutils.cpp
M  +6    -1    kstars/auxiliary/ksutils.h
M  +3    -2    kstars/ekos/align/align.cpp
M  +12   -19   kstars/ekos/capture/capture.cpp
M  +8    -8    kstars/ekos/ekosmanager.cpp
M  +38   -72   kstars/ekos/focus/focus.cpp
M  +3    -2    kstars/ekos/guide/guide.cpp
M  +3    -2    kstars/ekos/scheduler/scheduler.cpp
M  +33   -61   kstars/fitsviewer/fitsdata.cpp
M  +4    -2    kstars/fitsviewer/fitsviewer.cpp
M  +7    -12   kstars/indi/drivermanager.cpp
M  +3    -2    kstars/indi/indidevice.cpp
M  +5    -9    kstars/indi/indilistener.cpp
M  +8    -12   kstars/indi/inditelescope.cpp
M  +4    -3    kstars/indi/servermanager.cpp
M  +6    -2    kstars/kstars.cpp
M  +3    -1    kstars/kstarsdata.cpp
M  +3    -1    kstars/kstarsdbus.cpp
M  +2    -2    kstars/main.cpp
M  +12   -0    kstars/options/opsadvanced.cpp
M  +1    -0    kstars/options/opsadvanced.h
M  +3    -1    kstars/skycomponents/constellationlines.cpp
M  +5    -3    kstars/skycomponents/deepstarcomponent.cpp
M  +6    -6    kstars/time/simclock.cpp

https://commits.kde.org/kstars/5028e958caf97eaadd5c30cd442254e37fd84088

diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb05b30a0..f453fc006 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,6 +75,7 @@ include(ECMInstallIcons)
 include(ECMAddAppIcon)
 include(KDEInstallDirs)
 include(MacroBoolTo01)
+include(ECMQtDeclareLoggingCategory)
 if(NOT ANDROID)
     #We get error "could not find main method" with this module
     include(KDECompilerSettings NO_POLICY_SCOPE)
diff --git a/datahandlers/CMakeLists.txt b/datahandlers/CMakeLists.txt
index cd6a0819a..f17c96a83 100644
--- a/datahandlers/CMakeLists.txt
+++ b/datahandlers/CMakeLists.txt
@@ -18,6 +18,8 @@ IF (UNITY_BUILD)
     ENABLE_UNITY_BUILD(LibKSDataHandlers LibKSDataHandlers_SRC 10 cpp)
 ENDIF ()
 
+ecm_qt_declare_logging_category(LibKSDataHandlers_SRC HEADER catalog_debug.h IDENTIFIER KSTARS_CATALOG CATEGORY_NAME org.kde.kstars.catalog)
+
 add_library(LibKSDataHandlers STATIC ${LibKSDataHandlers_SRC})
 
 # Added this because includedir was missing, is this required?
diff --git a/datahandlers/catalogdb.cpp b/datahandlers/catalogdb.cpp
index fd9d544af..b7da52a38 100644
--- a/datahandlers/catalogdb.cpp
+++ b/datahandlers/catalogdb.cpp
@@ -25,11 +25,12 @@
 #include "deepskyobject.h"
 #include "skycomponent.h"
 
-#include <QDebug>
 #include <QSqlTableModel>
 #include <QSqlRecord>
 #include <QSqlQuery>
 
+#include <catalog_debug.h>
+
 bool CatalogDB::Initialize()
 {
     skydb_         = QSqlDatabase::addDatabase("QSQLITE", "skydb");
@@ -41,18 +42,18 @@ bool CatalogDB::Initialize()
     bool first_run = false;
     if (!testdb.exists())
     {
-        qDebug() << "DSO DB does not exist!";
+        qCWarning(KSTARS_CATALOG) << "DSO DB does not exist!";
         first_run = true;
     }
     skydb_.setDatabaseName(dbfile);
     if (!skydb_.open())
     {
-        qWarning() << i18n("Unable to open DSO database file!");
-        qWarning() << LastError();
+        qCWarning(KSTARS_CATALOG) << i18n("Unable to open DSO database file!");
+        qCWarning(KSTARS_CATALOG) << LastError();
     }
     else
     {
-        qDebug() << "Opened the DSO Database. Ready!";
+        qCDebug(KSTARS_CATALOG) << "Opened the DSO Database. Ready!";
         if (first_run == true)
         {
             FirstRun();
@@ -64,7 +65,7 @@ bool CatalogDB::Initialize()
 
 void CatalogDB::FirstRun()
 {
-    qWarning() << i18n("Rebuilding Additional Sky Catalog Database");
+    qCWarning(KSTARS_CATALOG) << i18n("Rebuilding Additional Sky Catalog Database");
     QVector<QString> tables;
     tables.append("CREATE TABLE Version ("
                   "Version CHAR DEFAULT NULL)");
@@ -112,7 +113,7 @@ void CatalogDB::FirstRun()
         QSqlQuery query(skydb_);
         if (!query.exec(tables[i]))
         {
-            qDebug() << query.lastError();
+            qCWarning(KSTARS_CATALOG) << query.lastError();
         }
     }
     return;
@@ -245,7 +246,7 @@ void CatalogDB::ClearDSOEntries(int catalog_id)
         QSqlQuery query(skydb_);
         if (!query.exec(del_query[i]))
         {
-            qDebug() << query.lastError();
+            qCWarning(KSTARS_CATALOG) << query.lastError();
         }
     }
 
@@ -291,8 +292,8 @@ bool CatalogDB::AddEntry(const CatalogEntryData &catalog_entry, int catid)
 {
     if (!skydb_.open())
     {
-        qWarning() << "Failed to open database to add catalog entry!";
-        qWarning() << LastError();
+        qCWarning(KSTARS_CATALOG) << "Failed to open database to add catalog entry!";
+        qCWarning(KSTARS_CATALOG) << LastError();
         return false;
     }
     bool retVal = _AddEntry(catalog_entry, catid);
@@ -306,13 +307,13 @@ bool CatalogDB::_AddEntry(const CatalogEntryData &catalog_entry, int catid)
     // If RA, Dec are Null, it denotes an invalid object and should not be written
     if (catid < 0)
     {
-        qWarning() << "Catalog ID " << catid << " is invalid! Cannot add object.";
+        qCWarning(KSTARS_CATALOG) << "Catalog ID " << catid << " is invalid! Cannot add object.";
         return false;
     }
     if (catalog_entry.ra == KSParser::EBROKEN_DOUBLE || catalog_entry.ra == 0.0 || std::isnan(catalog_entry.ra) ||
         catalog_entry.dec == KSParser::EBROKEN_DOUBLE || catalog_entry.dec == 0.0 || std::isnan(catalog_entry.dec))
     {
-        qDebug() << "Attempt to add incorrect ra & dec with ID:" << catalog_entry.ID
+        qCWarning(KSTARS_CATALOG) << "Attempt to add incorrect ra & dec with ID:" << catalog_entry.ID
                  << " Long Name: " << catalog_entry.long_name;
         return false;
     }
@@ -341,9 +342,9 @@ bool CatalogDB::_AddEntry(const CatalogEntryData &catalog_entry, int catid)
         add_query.bindValue(":Flux", catalog_entry.flux);
         if (!add_query.exec())
         {
-            qWarning() << "Custom Catalog Insert Query FAILED!";
-            qWarning() << add_query.lastQuery() << endl;
-            qWarning() << add_query.lastError() << endl;
+            qCWarning(KSTARS_CATALOG) << "Custom Catalog Insert Query FAILED!";
+            qCWarning(KSTARS_CATALOG) << add_query.lastQuery();
+            qCWarning(KSTARS_CATALOG) << add_query.lastError() << endl;
         }
 
         // Find UID of the Row just added
@@ -375,7 +376,7 @@ bool CatalogDB::_AddEntry(const CatalogEntryData &catalog_entry, int catid)
     }
     else
     {
-        qWarning() << "FIXME: This query has not been tested!!!!";
+        //qWarning() << "FIXME: This query has not been tested!!!!";
         add_od.prepare("INSERT INTO ObjectDesignation (id_Catalog, UID_DSO, LongName"
                        ", IDNumber) VALUES (:catid, :rowuid, :longname,"
                        "(SELECT MAX(ISNULL(IDNumber,1))+1 FROM ObjectDesignation WHERE id_Catalog = :catid) )");
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 1d714ae8c..3437a5ad8 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -871,6 +871,18 @@ set(kstars_SRCS
     ${libkstarswidgets_ui_SRCS}
 )
 
+# Generate all the necessary QtLoggingCategory files
+ecm_qt_declare_logging_category(kstars_SRCS HEADER kstars_debug.h IDENTIFIER KSTARS CATEGORY_NAME org.kde.kstars)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER indi_debug.h IDENTIFIER KSTARS_INDI CATEGORY_NAME org.kde.kstars.indi)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER fits_debug.h IDENTIFIER KSTARS_FITS CATEGORY_NAME org.kde.kstars.fits)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_debug.h IDENTIFIER KSTARS_EKOS CATEGORY_NAME org.kde.kstars.ekos)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_capture_debug.h IDENTIFIER KSTARS_EKOS_CAPTURE CATEGORY_NAME org.kde.kstars.ekos.capture)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_focus_debug.h IDENTIFIER KSTARS_EKOS_FOCUS CATEGORY_NAME org.kde.kstars.ekos.focus)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_align_debug.h IDENTIFIER KSTARS_EKOS_ALIGN CATEGORY_NAME org.kde.kstars.ekos.align)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_guide_debug.h IDENTIFIER KSTARS_EKOS_GUIDE CATEGORY_NAME org.kde.kstars.ekos.guide)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_mount_debug.h IDENTIFIER KSTARS_EKOS_MOUNT CATEGORY_NAME org.kde.kstars.ekos.mount)
+ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_scheduler_debug.h IDENTIFIER KSTARS_EKOS_SCHEDULER CATEGORY_NAME org.kde.kstars.ekos.scheduler)
+
 kconfig_add_kcfg_files(kstars_SRCS ${kstars_KCFG_SRCS})
 
 IF (UNITY_BUILD)
diff --git a/kstars/auxiliary/kspaths.cpp b/kstars/auxiliary/kspaths.cpp
index 3663bb77e..ebb778eb5 100644
--- a/kstars/auxiliary/kspaths.cpp
+++ b/kstars/auxiliary/kspaths.cpp
@@ -1,6 +1,5 @@
 #include "auxiliary/kspaths.h"
 #include <QFileInfo>
-#include <QDebug>
 
 QString KSPaths::locate(QStandardPaths::StandardLocation location, const QString &fileName,
                         QStandardPaths::LocateOptions options)
diff --git a/kstars/auxiliary/ksuserdb.cpp b/kstars/auxiliary/ksuserdb.cpp
index 7f2b2326b..77143ed95 100644
--- a/kstars/auxiliary/ksuserdb.cpp
+++ b/kstars/auxiliary/ksuserdb.cpp
@@ -28,6 +28,8 @@
 #include <QSqlRecord>
 #include <QSqlTableModel>
 
+#include <kstars_debug.h>
+
 /*
  * TODO (spacetime):
  * The database supports storing logs. But it needs to be implemented.
@@ -50,19 +52,19 @@ bool KSUserDB::Initialize()
     bool first_run = false;
     if (!testdb.exists())
     {
-        qDebug() << "User DB does not exist. New User DB will be created.";
+        qCInfo(KSTARS) << "User DB does not exist. New User DB will be created.";
         first_run = true;
     }
     userdb_.setDatabaseName(dbfile);
     if (!userdb_.open())
     {
-        qWarning() << "Unable to open user database file.";
-        qWarning() << LastError();
+        qCWarning(KSTARS) << "Unable to open user database file.";
+        qCritical(KSTARS) << LastError();
         return false;
     }
     else
     {
-        qDebug() << "Opened the User DB. Ready.";
+        qCDebug(KSTARS) << "Opened the User DB. Ready.";
         if (first_run == true)
             FirstRun();
         else
@@ -101,19 +103,19 @@ bool KSUserDB::Initialize()
                 QString versionQuery = QString("UPDATE Version SET Version='%1'").arg(KSTARS_VERSION);
 
                 if (!query.exec(versionQuery))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
 
                 // Profiles
                 if (!query.exec("CREATE TABLE IF NOT EXISTS profile (id INTEGER DEFAULT NULL PRIMARY KEY "
                                 "AUTOINCREMENT, name TEXT NOT NULL, host TEXT, port INTEGER, city TEXT, province TEXT, "
                                 "country TEXT, indiwebmanagerport INTEGER DEFAULT NULL)"))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
 
                 // Drivers
                 if (!query.exec("CREATE TABLE IF NOT EXISTS driver (id INTEGER DEFAULT NULL PRIMARY KEY AUTOINCREMENT, "
                                 "label TEXT NOT NULL, role TEXT NOT NULL, profile INTEGER NOT NULL, FOREIGN "
                                 "KEY(profile) REFERENCES profile(id))"))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
 
 // Custom Drivers
 //if (!query.exec("CREATE TABLE IF NOT EXISTS custom_driver (id INTEGER DEFAULT NULL PRIMARY KEY AUTOINCREMENT, drivers TEXT NOT NULL, profile INTEGER NOT NULL, FOREIGN KEY(profile) REFERENCES profile(id))"))
@@ -125,16 +127,16 @@ bool KSUserDB::Initialize()
                     qDebug() << query.lastError();
 #else
                 if (!query.exec("INSERT INTO profile (name) VALUES ('Simulators')"))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
 #endif
 
                 // Add sample profile drivers
                 if (!query.exec("INSERT INTO driver (label, role, profile) VALUES ('Telescope Simulator', 'Mount', 1)"))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
                 if (!query.exec("INSERT INTO driver (label, role, profile) VALUES ('CCD Simulator', 'CCD', 1)"))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
                 if (!query.exec("INSERT INTO driver (label, role, profile) VALUES ('Focuser Simulator', 'Focuser', 1)"))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
             }
 
             // If prior to 2.6.1 upgrade database for dark library tables
@@ -144,14 +146,14 @@ bool KSUserDB::Initialize()
                 QString versionQuery = QString("UPDATE Version SET Version='%1'").arg(KSTARS_VERSION);
 
                 if (!query.exec(versionQuery))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
 
                 // Dark Frame
                 if (!query.exec("CREATE TABLE IF NOT EXISTS darkframe (id INTEGER DEFAULT NULL PRIMARY KEY "
                                 "AUTOINCREMENT, ccd TEXT NOT NULL, chip INTEGER DEFAULT 0, binX INTEGER, binY INTEGER, "
                                 "temperature REAL, duration REAL, filename TEXT NOT NULL, timestamp DATETIME DEFAULT "
                                 "CURRENT_TIMESTAMP)"))
-                    qDebug() << query.lastError();
+                    qCWarning(KSTARS) << query.lastError();
             }
 
             // If prior to 2.7.3 upgrade database to add column for focus offset
diff --git a/kstars/auxiliary/ksutils.cpp b/kstars/auxiliary/ksutils.cpp
index 78e51b3c3..70ea95cc2 100644
--- a/kstars/auxiliary/ksutils.cpp
+++ b/kstars/auxiliary/ksutils.cpp
@@ -31,6 +31,7 @@
 
 #include <QPointer>
 #include <QProcessEnvironment>
+#include <QLoggingCategory>
 
 namespace KSUtils
 {
@@ -918,28 +919,30 @@ void Logging::UseFile()
         file.close();
     }
 
+    qSetMessagePattern("[%{time yyyy-MM-dd h:mm:ss.zzz t} %{if-debug}DEBG%{endif}%{if-info}INFO%{endif}%{if-warning}WARN%{endif}%{if-critical}CRIT%{endif}%{if-fatal}FATL%{endif}] %{if-category}[%{category}]%{endif} - %{message}");
     qInstallMessageHandler(File);
 }
 
-void Logging::File(QtMsgType type, const QMessageLogContext &, const QString &msg)
+void Logging::File(QtMsgType type, const QMessageLogContext &context, const QString &msg)
 {
     QFile file(_filename);
     if (file.open(QFile::Append | QIODevice::Text))
     {
         QTextStream stream(&file);
-        Write(stream, type, msg);
+        Write(stream, type, context, msg);
     }
 }
 
 void Logging::UseStdout()
 {
+    qSetMessagePattern("[%{time yyyy-MM-dd h:mm:ss.zzz t} %{if-debug}DEBG%{endif}%{if-info}INFO%{endif}%{if-warning}WARN%{endif}%{if-critical}CRIT%{endif}%{if-fatal}FATL%{endif}] %{if-category}[%{category}]%{endif} - %{message}");
     qInstallMessageHandler(Stdout);
 }
 
-void Logging::Stdout(QtMsgType type, const QMessageLogContext &, const QString &msg)
+void Logging::Stdout(QtMsgType type, const QMessageLogContext &context, const QString &msg)
 {
     QTextStream stream(stdout, QIODevice::WriteOnly);
-    Write(stream, type, msg);
+    Write(stream, type, context, msg);
 }
 
 void Logging::UseStderr()
@@ -947,35 +950,42 @@ void Logging::UseStderr()
     qInstallMessageHandler(Stderr);
 }
 
-void Logging::Stderr(QtMsgType type, const QMessageLogContext &, const QString &msg)
+void Logging::Stderr(QtMsgType type, const QMessageLogContext &context, const QString &msg)
 {
     QTextStream stream(stderr, QIODevice::WriteOnly);
-    Write(stream, type, msg);
+    Write(stream, type,context,  msg);
 }
 
-void Logging::Write(QTextStream &stream, QtMsgType type, const QString &msg)
-{
-    stream << QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss.zzz") << " - ";
+void Logging::Write(QTextStream &stream, QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{    
+
+    stream << QDateTime::currentDateTime().toString("[yyyy-MM-ddThh:mm:ss.zzz t ");
 
     switch (type)
     {
+        case QtInfoMsg:
+            stream << "INFO ]";
+            break;
         case QtDebugMsg:
-            stream << "DEBG - ";
+            stream << "DEBG ]";
             break;
         case QtWarningMsg:
-            stream << "WARN - ";
+            stream << "WARN ]";
             break;
         case QtCriticalMsg:
-            stream << "CRIT - ";
+            stream << "CRIT ]";
             break;
         case QtFatalMsg:
-            stream << "FATL - ";
+            stream << "FATL ]";
             break;
         default:
-            stream << "UNKN - ";
+            stream << "UNKN ]";
     }
 
+
+    stream << "[" << qSetFieldWidth(30) << context.category << qSetFieldWidth(0) << "] - ";
     stream << msg << endl;
+    //stream << qFormatLogMessage(type, context, msg) << endl;
 }
 
 void Logging::UseDefault()
@@ -991,6 +1001,29 @@ void Logging::Disable()
 void Logging::Disabled(QtMsgType, const QMessageLogContext &, const QString &)
 {
 }
+
+void Logging::SyncFilterRules()
+{
+    QString rules = QString("org.kde.kstars.ekos.debug=%1\n"
+                            "org.kde.kstars.fits.debug=%2\n"
+                            "org.kde.kstars.ekos.capture.debug=%3\n"
+                            "org.kde.kstars.ekos.focus.debug=%4\n"
+                            "org.kde.kstars.ekos.guide.debug=%5\n"
+                            "org.kde.kstars.ekos.align.debug=%6\n"
+                            "org.kde.kstars.ekos.mount.debug=%7\n"
+                            "org.kde.kstars.debug=%1").arg(
+                            Options::verboseLogging() ? "true" : "false",
+                            Options::fITSLogging() ? "true" : "false",
+                            Options::captureLogging() ? "true" : "false",
+                            Options::focusLogging() ? "true" : "false",
+                            Options::guideLogging() ? "true" : "false",
+                            Options::alignmentLogging() ? "true" : "false",
+                            Options::mountLogging() ? "true" : "false"
+                            );
+
+    QLoggingCategory::setFilterRules(rules);
+}
+
 /**
   This method provides a centralized location for the default paths to important external files used in the Options
   on different operating systems.  Note that on OS X, if the user builds the app without indi, astrometry, and xplanet internally
diff --git a/kstars/auxiliary/ksutils.h b/kstars/auxiliary/ksutils.h
index 0bf47646f..a37aa67a4 100644
--- a/kstars/auxiliary/ksutils.h
+++ b/kstars/auxiliary/ksutils.h
@@ -231,6 +231,11 @@ class Logging
          */
     static void Disable();
 
+    /**
+     * @brief SyncFilterRules Sync QtLogging filter rules from Options
+     */
+    static void SyncFilterRules();
+
   private:
     static QString _filename;
 
@@ -238,7 +243,7 @@ class Logging
     static void File(QtMsgType type, const QMessageLogContext &context, const QString &msg);
     static void Stdout(QtMsgType type, const QMessageLogContext &context, const QString &msg);
     static void Stderr(QtMsgType type, const QMessageLogContext &context, const QString &msg);
-    static void Write(QTextStream &stream, QtMsgType type, const QString &msg);
+    static void Write(QTextStream &stream, QtMsgType type, const QMessageLogContext &context, const QString &msg);
 };
 
 QString getDefaultPath(QString option);
diff --git a/kstars/ekos/align/align.cpp b/kstars/ekos/align/align.cpp
index cb73e353b..6aa353563 100644
--- a/kstars/ekos/align/align.cpp
+++ b/kstars/ekos/align/align.cpp
@@ -42,6 +42,8 @@
 
 #include <memory>
 
+#include <ekos_align_debug.h>
+
 #define PAH_CUTOFF_FOV            30 // Minimum FOV width in arcminutes for PAH to work
 #define MAXIMUM_SOLVER_ITERATIONS 10
 
@@ -3038,8 +3040,7 @@ void Align::appendLogText(const QString &text)
     logText.insert(0, i18nc("log entry; %1 is the date, %2 is the text", "%1 %2",
                             QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"), text));
 
-    if (Options::alignmentLogging())
-        qDebug() << "Alignment: " << text;
+    qCInfo(KSTARS_EKOS_ALIGN) << text;
 
     emit newLog();
 }
diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp
index 948a5f106..787d1f10f 100644
--- a/kstars/ekos/capture/capture.cpp
+++ b/kstars/ekos/capture/capture.cpp
@@ -31,6 +31,8 @@
 
 #include <KNotifications/KNotification>
 
+#include <ekos_capture_debug.h>
+
 #define INVALID_VALUE -1e6
 #define MF_TIMER_TIMEOUT    90000
 #define GD_TIMER_TIMEOUT    60000
@@ -1252,8 +1254,7 @@ bool Capture::resumeSequence()
 
         // check if time for forced refocus
 
-	if (Options::captureLogging())
-	  qDebug() << "Elapsed Time (secs): " << getRefocusEveryNTimerElapsedSec() << " Requested Interval (secs): " << refocusEveryN->value()*60;
+    qDebug(KSTARS_EKOS_CAPTURE) << "Elapsed Time (secs): " << getRefocusEveryNTimerElapsedSec() << " Requested Interval (secs): " << refocusEveryN->value()*60;
 
         if (refocusEveryNCheck->isEnabled() && refocusEveryNCheck->isChecked() && getRefocusEveryNTimerElapsedSec() >= refocusEveryN->value()*60)
             isRefocus = true;
@@ -1546,8 +1547,7 @@ void Capture::appendLogText(const QString &text)
     logText.insert(0, i18nc("log entry; %1 is the date, %2 is the text", "%1 %2",
                             QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"), text));
 
-    if (Options::captureLogging())
-        qDebug() << "Capture: " << text;
+    qCInfo(KSTARS_EKOS_CAPTURE) << text;
 
     emit newLog();
 }
@@ -1613,8 +1613,7 @@ void Capture::setExposureProgress(ISD::CCDChip *tChip, double value, IPState sta
         //if (isAutoGuiding && Options::useEkosGuider() && currentCCD->getChip(ISD::CCDChip::GUIDE_CCD) == guideChip)
         if (guideState == GUIDE_GUIDING && Options::guiderType() == 0 && suspendGuideOnDownload)
         {
-            if (Options::captureLogging())
-                qDebug() << "Capture: Autoguiding suspended until primary CCD chip completes downloading...";
+            qDebug(KSTARS_EKOS_CAPTURE) << "Autoguiding suspended until primary CCD chip completes downloading...";
             emit suspendGuiding();
         }
 
@@ -3687,8 +3686,7 @@ double Capture::setCurrentADU(double value)
     ExpRaw.append(activeJob->getExposure());
     ADURaw.append(value);
 
-    if (Options::captureLogging())
-        qDebug() << "Capture: Current ADU = " << value << " targetADU = " << targetADU
+    qDebug(KSTARS_EKOS_CAPTURE) << "Capture: Current ADU = " << value << " targetADU = " << targetADU
                  << " Exposure Count: " << ExpRaw.count();
 
     // Most CCDs are quite linear so 1st degree polynomial is quite sufficient
@@ -3700,12 +3698,9 @@ double Capture::setCurrentADU(double value)
             double chisq = 0;
 
             coeff = gsl_polynomial_fit(ADURaw.data(), ExpRaw.data(), ExpRaw.count(), 2, chisq);
-            if (Options::captureLogging())
-            {
-                qDebug() << "Capture: Running polynomial fitting. Found " << coeff.size() << " coefficients.";
-                for (size_t i = 0; i < coeff.size(); i++)
-                    qDebug() << "Capture: Coeff #" << i << "=" << coeff[i];
-            }
+            qDebug(KSTARS_EKOS_CAPTURE) << "Capture: Running polynomial fitting. Found " << coeff.size() << " coefficients.";
+            for (size_t i = 0; i < coeff.size(); i++)
+                    qDebug(KSTARS_EKOS_CAPTURE) << "Capture: Coeff #" << i << "=" << coeff[i];
         }
 
         bool looping = false;
@@ -3714,7 +3709,7 @@ double Capture::setCurrentADU(double value)
             int size = ExpRaw.count();
             looping  = (ExpRaw[size - 1] == ExpRaw[size - 2]) && (ExpRaw[size - 2] == ExpRaw[size - 3]);
             if (looping)
-                qDebug() << "Capture: Detected looping in polynomial results. Falling back to llsqr.";
+                qWarning(KSTARS_EKOS_CAPTURE) << "Capture: Detected looping in polynomial results. Falling back to llsqr.";
         }
 
         // If we get invalid data, let's fall back to llsq
@@ -3725,8 +3720,7 @@ double Capture::setCurrentADU(double value)
             double a = 0, b = 0;
             llsq(ExpRaw, ADURaw, a, b);
 
-            if (Options::captureLogging())
-                qDebug() << "Capture: polynomial fitting invalid, faling back to llsq. a=" << a << " b=" << b;
+            qWarning(KSTARS_EKOS_CAPTURE) << "Capture: polynomial fitting invalid, faling back to llsq. a=" << a << " b=" << b;
 
             // If we have valid results, let's calculate next exposure
             if (a != 0)
@@ -3749,8 +3743,7 @@ double Capture::setCurrentADU(double value)
             nextExposure = activeJob->getExposure() * .75;
     }
 
-    if (Options::captureLogging())
-        qDebug() << "Capture: next FLAT exposure is " << nextExposure;
+    qDebug(KSTARS_EKOS_CAPTURE) << "Capture: next FLAT exposure is " << nextExposure;
 
     return nextExposure;
 }
diff --git a/kstars/ekos/ekosmanager.cpp b/kstars/ekos/ekosmanager.cpp
index 6f137c9f9..c249e8542 100644
--- a/kstars/ekos/ekosmanager.cpp
+++ b/kstars/ekos/ekosmanager.cpp
@@ -40,6 +40,8 @@
 
 #include <QComboBox>
 
+#include <ekos_debug.h>
+
 #define MAX_REMOTE_INDI_TIMEOUT 15000
 #define MAX_LOCAL_INDI_TIMEOUT  5000
 
@@ -801,8 +803,7 @@ void EkosManager::cleanDevices(bool stopDrivers)
 
 void EkosManager::processNewDevice(ISD::GDInterface *devInterface)
 {
-    if (Options::verboseLogging())
-        qDebug() << "Ekos received a new device: " << devInterface->getDeviceName();
+    qCInfo(KSTARS_EKOS) << "Ekos received a new device: " << devInterface->getDeviceName();
 
     // Always reset INDI Connection status if we receive a new device
     indiConnectionStatus = EKOS_STATUS_IDLE;
@@ -843,7 +844,7 @@ void EkosManager::deviceConnected()
     if (Options::verboseLogging())
     {
         ISD::GDInterface *device = (ISD::GDInterface *)sender();
-        qDebug() << "Ekos: " << device->getDeviceName() << "is connected.";
+        qCInfo(KSTARS_EKOS) << device->getDeviceName() << "is connected.";
     }
 
     int nConnectedDevices = 0;
@@ -854,13 +855,13 @@ void EkosManager::deviceConnected()
             nConnectedDevices++;
     }
 
-    qDebug() << "Ekos: " << nConnectedDevices << " devices connected out of " << genericDevices.count();
+    qCDebug(KSTARS_EKOS) << nConnectedDevices << " devices connected out of " << genericDevices.count();
 
     //if (nConnectedDevices >= pi->drivers.count())
     if (nConnectedDevices >= genericDevices.count())
     {
         indiConnectionStatus = EKOS_STATUS_SUCCESS;
-        qDebug() << "Ekos: All INDI devices are now connected.";
+        qCInfo(KSTARS_EKOS)<< "All INDI devices are now connected.";
     }
     else
         indiConnectionStatus = EKOS_STATUS_PENDING;
@@ -929,7 +930,7 @@ void EkosManager::deviceDisconnected()
             indiConnectionStatus = EKOS_STATUS_IDLE;
 
         if (Options::verboseLogging())
-            qDebug() << "Ekos: " << dev->getDeviceName() << " is disconnected.";
+            qCDebug(KSTARS_EKOS) << dev->getDeviceName() << " is disconnected.";
 
         appendLogText(i18n("%1 is disconnected.", dev->getDeviceName()));
     }
@@ -1523,8 +1524,7 @@ void EkosManager::appendLogText(const QString &text)
     logText.insert(0, i18nc("log entry; %1 is the date, %2 is the text", "%1 %2",
                             QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"), text));
 
-    if (Options::verboseLogging())
-        qDebug() << "Ekos: " << text;
+    qCInfo(KSTARS_EKOS) << text;
 
     updateLog();
 }
diff --git a/kstars/ekos/focus/focus.cpp b/kstars/ekos/focus/focus.cpp
index f1bf6ad0c..1ea5b16dc 100644
--- a/kstars/ekos/focus/focus.cpp
+++ b/kstars/ekos/focus/focus.cpp
@@ -29,6 +29,8 @@
 #include <gsl/gsl_vector.h>
 #include <gsl/gsl_min.h>
 
+#include <ekos_focus_debug.h>
+
 #define MAXIMUM_ABS_ITERATIONS   30
 #define MAXIMUM_RESET_ITERATIONS 2
 #define AUTO_STAR_TIMEOUT        45000
@@ -746,8 +748,7 @@ void Focus::start()
     Options::setLockFocusFilter(lockFilterCheck->isChecked());
     Options::setUseFocusDarkFrame(darkFrameCheck->isChecked());
 
-    if (Options::focusLogging())
-        qDebug() << "Focus: Starting focus with box size: " << focusBoxSize->value()
+    qCDebug(KSTARS_EKOS_FOCUS)  << "Focus: Starting focus with box size: " << focusBoxSize->value()
                  << " Step Size: " << stepIN->value() << " Threshold: " << thresholdSpin->value()
                  << " Tolerance: " << toleranceIN->value()
                  << " Frames: " << 1 /*focusFramesSpin->value()*/ << " Maximum Travel: " << maxTravelIN->value();
@@ -798,8 +799,7 @@ void Focus::abort()
 
 void Focus::stop(bool aborted)
 {
-    if (Options::focusLogging())
-        qDebug() << "Focus: Stopppig Focus";
+    qCDebug(KSTARS_EKOS_FOCUS) << "Focus: Stopppig Focus";
 
     ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD);
 
@@ -950,8 +950,7 @@ bool Focus::focusIn(int ms)
     if (ms == -1)
         ms = stepIN->value();
 
-    if (Options::focusLogging())
-        qDebug() << "Focus: Focus in (" << ms << ")";
+    qCDebug(KSTARS_EKOS_FOCUS) << "Focus: Focus in (" << ms << ")";
 
     lastFocusDirection = FOCUS_IN;
 
@@ -992,8 +991,7 @@ bool Focus::focusOut(int ms)
     if (ms == -1)
         ms = stepIN->value();
 
-    if (Options::focusLogging())
-        qDebug() << "Focus: Focus out (" << ms << ")";
+    qCDebug(KSTARS_EKOS_FOCUS) << "Focus: Focus out (" << ms << ")";
 
     currentFocuser->focusOut();
 
@@ -1129,8 +1127,7 @@ void Focus::setCaptureComplete()
             }*/
         }
 
-        if (Options::focusLogging())
-            qDebug() << "Focus newFITS #" << HFRFrames.count() + 1 << ": Current HFR " << currentHFR;
+        qCDebug(KSTARS_EKOS_FOCUS) << "Focus newFITS #" << HFRFrames.count() + 1 << ": Current HFR " << currentHFR;
 
         HFRFrames.append(currentHFR);
 
@@ -1580,15 +1577,13 @@ void Focus::autoFocusAbs()
     QString deltaTxt = QString("%1").arg(fabs(currentHFR - minHFR) * 100.0, 0, 'g', 3);
     QString HFRText  = QString("%1").arg(currentHFR, 0, 'g', 3);
 
-    if (Options::focusLogging())
-    {
-        qDebug() << "Focus: ########################################";
-        qDebug() << "Focus: ========================================";
-        qDebug() << "Focus: Current HFR: " << currentHFR << " Current Position: " << currentPosition;
-        qDebug() << "Focus: Last minHFR: " << minHFR << " Last MinHFR Pos: " << minHFRPos;
-        qDebug() << "Focus: Delta: " << deltaTxt << "%";
-        qDebug() << "Focus: ========================================";
-    }
+    bool isDebugEnabled = QLoggingCategory("org.kde.kstars.ekos.focus").isDebugEnabled();
+
+    qCDebug(KSTARS_EKOS_FOCUS) << "========================================";
+    qCDebug(KSTARS_EKOS_FOCUS) << "Current HFR: " << currentHFR << " Current Position: " << currentPosition;
+    qCDebug(KSTARS_EKOS_FOCUS) << "Last minHFR: " << minHFR << " Last MinHFR Pos: " << minHFRPos;
+    qCDebug(KSTARS_EKOS_FOCUS) << "Delta: " << deltaTxt << "%";
+    qCDebug(KSTARS_EKOS_FOCUS) << "========================================";
 
     if (minHFR)
         appendLogText(i18n("FITS received. HFR %1 @ %2. Delta (%3%)", HFRText, currentPosition, deltaTxt));
@@ -1703,23 +1698,20 @@ void Focus::autoFocusAbs()
                     initSlopeHFR = lastHFR;
                     initSlopePos = lastHFRPos;
 
-                    if (Options::focusLogging())
-                        qDebug() << "Focus: Setting initial slop to " << initSlopePos << " @ HFR " << initSlopeHFR;
+                    qCDebug(KSTARS_EKOS_FOCUS) << "Setting initial slop to " << initSlopePos << " @ HFR " << initSlopeHFR;
                 }
 
                 // Let's now limit the travel distance of the focuser
                 if (lastFocusDirection == FOCUS_OUT && lastHFRPos < focusInLimit && fabs(currentHFR - lastHFR) > 0.1)
                 {
                     focusInLimit = lastHFRPos;
-                    if (Options::focusLogging())
-                        qDebug() << "Focus: New FocusInLimit " << focusInLimit;
+                    qCDebug(KSTARS_EKOS_FOCUS) << "New FocusInLimit " << focusInLimit;
                 }
                 else if (lastFocusDirection == FOCUS_IN && lastHFRPos > focusOutLimit &&
                          fabs(currentHFR - lastHFR) > 0.1)
                 {
                     focusOutLimit = lastHFRPos;
-                    if (Options::focusLogging())
-                        qDebug() << "Focus: New FocusOutLimit " << focusOutLimit;
+                    qCDebug(KSTARS_EKOS_FOCUS) << "New FocusOutLimit " << focusOutLimit;
                 }
 
                 // If we have slope, get next target position
@@ -1739,8 +1731,7 @@ void Focus::autoFocusAbs()
                             targetPosition = currentPosition + (currentHFR * factor - currentHFR) / slope;
                         }
                     }
-                    if (Options::focusLogging())
-                        qDebug() << "Focus: Using slope to calculate target pulse...";
+                    qCDebug(KSTARS_EKOS_FOCUS) << "Using slope to calculate target pulse...";
                 }
                 // Otherwise proceed iteratively
                 else
@@ -1750,12 +1741,10 @@ void Focus::autoFocusAbs()
                     else
                         targetPosition = currentPosition + pulseDuration;
 
-                    if (Options::focusLogging())
-                        qDebug() << "Focus: Proceeding iteratively to next target pulse ...";
+                    qCDebug(KSTARS_EKOS_FOCUS) << "Proceeding iteratively to next target pulse ...";
                 }
 
-                if (Options::focusLogging())
-                    qDebug() << "Focus: V-Curve Slope " << slope << " current Position " << currentPosition
+                qCDebug(KSTARS_EKOS_FOCUS) << "V-Curve Slope " << slope << " current Position " << currentPosition
                              << " targetPosition " << targetPosition;
 
                 lastHFR = currentHFR;
@@ -1765,11 +1754,7 @@ void Focus::autoFocusAbs()
                 {
                     minHFR    = lastHFR;
                     minHFRPos = currentPosition;
-                    if (Options::focusLogging())
-                    {
-                        qDebug() << "Focus: new minHFR " << minHFR << " @ positioin " << minHFRPos;
-                        qDebug() << "Focus: ########################################";
-                    }
+                    qCDebug(KSTARS_EKOS_FOCUS) << "new minHFR " << minHFR << " @ positioin " << minHFRPos;
                 }
 
                 lastHFRPos = currentPosition;
@@ -1800,34 +1785,29 @@ void Focus::autoFocusAbs()
                 initSlopeHFR = 0;
                 HFRInc       = 0;
 
-                if (Options::focusLogging())
-                    qDebug() << "Focus: We are going away from optimal HFR ";
+                qCDebug(KSTARS_EKOS_FOCUS) << "Focus is moving away from optimal HFR.";
 
                 // Let's set new limits
                 if (lastFocusDirection == FOCUS_IN)
                 {
                     focusInLimit = currentPosition;
-                    if (Options::focusLogging())
-                        qDebug() << "Focus: Setting focus IN limit to " << focusInLimit;
+                    qCDebug(KSTARS_EKOS_FOCUS) << "Setting focus IN limit to " << focusInLimit;
 
                     if (hfr_position.count() > 3)
                     {
                         focusOutLimit = hfr_position[hfr_position.count() - 3];
-                        if (Options::focusLogging())
-                            qDebug() << "Focus: Setting focus OUT limit to " << focusOutLimit;
+                        qCDebug(KSTARS_EKOS_FOCUS) << "Setting focus OUT limit to " << focusOutLimit;
                     }
                 }
                 else
                 {
                     focusOutLimit = currentPosition;
-                    if (Options::focusLogging())
-                        qDebug() << "Focus: Setting focus OUT limit to " << focusOutLimit;
+                    qCDebug(KSTARS_EKOS_FOCUS) << "Setting focus OUT limit to " << focusOutLimit;
 
                     if (hfr_position.count() > 3)
                     {
                         focusInLimit = hfr_position[hfr_position.count() - 3];
-                        if (Options::focusLogging())
-                            qDebug() << "Focus: Setting focus IN limit to " << focusInLimit;
+                        qCDebug(KSTARS_EKOS_FOCUS) << "Setting focus IN limit to " << focusInLimit;
                     }
                 }
 
@@ -1839,17 +1819,13 @@ void Focus::autoFocusAbs()
 
                     polyMinimumFound = findMinimum(minHFRPos, &min_position, &min_hfr);
 
-                    if (Options::fITSLogging())
-                    {
-                        qDebug() << "Polynomial Coefficients c0:" << coeff[0] << "c1:" << coeff[1] << "c2:" << coeff[2]
+                    qCDebug(KSTARS_EKOS_FOCUS) << "Polynomial Coefficients c0:" << coeff[0] << "c1:" << coeff[1] << "c2:" << coeff[2]
                                  << "c3:" << coeff[3];
-                        qDebug() << "Found Minimum?" << (polyMinimumFound ? "Yes" : "No");
-                        if (polyMinimumFound)
-                            qDebug() << "Minimum Solution:" << min_hfr << "@" << min_position;
-                    }
+                     qCDebug(KSTARS_EKOS_FOCUS) << "Found Minimum?" << (polyMinimumFound ? "Yes" : "No");
 
                     if (polyMinimumFound)
                     {
+                        qCDebug(KSTARS_EKOS_FOCUS) << "Minimum Solution:" << min_hfr << "@" << min_position;
                         polySolutionFound++;
                         targetPosition = floor(min_position);
                         appendLogText(i18n("Found polynomial solution @ %1", QString::number(min_position, 'f', 0)));
@@ -1868,22 +1844,19 @@ void Focus::autoFocusAbs()
                         targetPosition = minHFRPos + pulseDuration / 2;
                 }
 
-                if (Options::focusLogging())
-                    qDebug() << "Focus: new targetPosition " << targetPosition;
+                qCDebug(KSTARS_EKOS_FOCUS) << "new targetPosition " << targetPosition;
             }
 
             // Limit target Pulse to algorithm limits
             if (focusInLimit != 0 && lastFocusDirection == FOCUS_IN && targetPosition < focusInLimit)
             {
                 targetPosition = focusInLimit;
-                if (Options::focusLogging())
-                    qDebug() << "Focus: Limiting target pulse to focus in limit " << targetPosition;
+                qCDebug(KSTARS_EKOS_FOCUS) << "Limiting target pulse to focus in limit " << targetPosition;
             }
             else if (focusOutLimit != 0 && lastFocusDirection == FOCUS_OUT && targetPosition > focusOutLimit)
             {
                 targetPosition = focusOutLimit;
-                if (Options::focusLogging())
-                    qDebug() << "Focus: Limiting target pulse to focus out limit " << targetPosition;
+                qCDebug(KSTARS_EKOS_FOCUS) << "Focus: Limiting target pulse to focus out limit " << targetPosition;
             }
 
             // Limit target pulse to focuser limits
@@ -1913,8 +1886,7 @@ void Focus::autoFocusAbs()
 
             if (fabs(targetPosition - initialFocuserAbsPosition) > maxTravelIN->value())
             {
-                if (Options::focusLogging())
-                    qDebug() << "Focus: targetPosition (" << targetPosition << ") - initHFRAbsPos ("
+                qCDebug(KSTARS_EKOS_FOCUS) << "Focus: targetPosition (" << targetPosition << ") - initHFRAbsPos ("
                              << initialFocuserAbsPosition << ") exceeds maxTravel distance of " << maxTravelIN->value();
 
                 appendLogText("Maximum travel limit reached. Autofocus aborted.");
@@ -1926,12 +1898,8 @@ void Focus::autoFocusAbs()
             // Get delta for next move
             delta = (targetPosition - currentPosition);
 
-            if (Options::focusLogging())
-            {
-                qDebug() << "Focus: delta (targetPosition - currentPosition) " << delta;
-                qDebug() << "Focus: Focusing " << ((delta < 0) ? "IN" : "OUT");
-                qDebug() << "Focus: ########################################";
-            }
+            qCDebug(KSTARS_EKOS_FOCUS) << "delta (targetPosition - currentPosition) " << delta;
+            qCDebug(KSTARS_EKOS_FOCUS) << "Focusing " << ((delta < 0) ? "IN" : "OUT");
 
             // Now cross your fingers and wait
             bool rc = false;
@@ -2189,8 +2157,7 @@ void Focus::appendLogText(const QString &text)
     logText.insert(0, i18nc("log entry; %1 is the date, %2 is the text", "%1 %2",
                             QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"), text));
 
-    if (Options::focusLogging())
-        qDebug() << "Focus: " << text;
+    qCInfo(KSTARS_EKOS_FOCUS) << text;
 
     emit newLog();
 }
@@ -2544,8 +2511,7 @@ void Focus::setAbsoluteFocusTicks()
         return;
     }
 
-    if (Options::focusLogging())
-        qDebug() << "Focus: Setting focus ticks to " << absTicksSpin->value();
+    qCDebug(KSTARS_EKOS_FOCUS) << "Setting focus ticks to " << absTicksSpin->value();
 
     currentFocuser->moveAbs(absTicksSpin->value());
 }
@@ -2712,7 +2678,7 @@ bool Focus::findMinimum(double expected, double *position, double *hfr)
 
     if (status != GSL_SUCCESS)
     {
-        qDebug() << "Focus GSL error:" << gsl_strerror(status);
+        qCWarning(KSTARS_EKOS_FOCUS) << "Focus GSL error:" << gsl_strerror(status);
         return false;
     }
 
diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp
index ff337005e..90b783a27 100644
--- a/kstars/ekos/guide/guide.cpp
+++ b/kstars/ekos/guide/guide.cpp
@@ -28,6 +28,8 @@
 
 #include <KConfigDialog>
 
+#include <ekos_guide_debug.h>
+
 #define CAPTURE_TIMEOUT_THRESHOLD 10000
 #define MAX_GUIDE_STARS           10
 
@@ -874,8 +876,7 @@ void Guide::appendLogText(const QString &text)
     logText.insert(0, i18nc("log entry; %1 is the date, %2 is the text", "%1 %2",
                             QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"), text));
 
-    if (Options::guideLogging())
-        qDebug() << "Guide: " << text;
+    qCInfo(KSTARS_EKOS_GUIDE) << text;
 
     emit newLog();
 }
diff --git a/kstars/ekos/scheduler/scheduler.cpp b/kstars/ekos/scheduler/scheduler.cpp
index bdcaceb76..761ebf189 100644
--- a/kstars/ekos/scheduler/scheduler.cpp
+++ b/kstars/ekos/scheduler/scheduler.cpp
@@ -29,6 +29,8 @@
 
 #include <KNotifications/KNotification>
 
+#include <ekos_scheduler_debug.h>
+
 #define BAD_SCORE               -1000
 #define MAX_FAILURE_ATTEMPTS    3
 #define UPDATE_PERIOD_MS        1000
@@ -250,8 +252,7 @@ void Scheduler::appendLogText(const QString &text)
     logText.insert(0, i18nc("log entry; %1 is the date, %2 is the text", "%1 %2",
                             QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"), text));
 
-    if (Options::verboseLogging())
-        qDebug() << "Scheduler: " << text;
+    qCInfo(KSTARS_EKOS_SCHEDULER) << text;
 
     emit newLog();
 }
diff --git a/kstars/fitsviewer/fitsdata.cpp b/kstars/fitsviewer/fitsdata.cpp
index 39a801b07..7232674c4 100644
--- a/kstars/fitsviewer/fitsdata.cpp
+++ b/kstars/fitsviewer/fitsdata.cpp
@@ -35,6 +35,8 @@
 
 #include <float.h>
 
+#include <fits_debug.h>
+
 #define ZOOM_DEFAULT   100.0
 #define ZOOM_MIN       10
 #define ZOOM_MAX       400
@@ -104,10 +106,12 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
 
         if (tempFile && autoRemoveTemporaryFITS)
             QFile::remove(filename);
-    }
+    }    
 
     filename = inFilename;
 
+    qCInfo(KSTARS_FITS) << "Loading FITS file " << filename;
+
     if (filename.startsWith(QLatin1String("/tmp/")) || filename.contains("/Temp"))
         tempFile = true;
     else
@@ -120,8 +124,7 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
         errMessage = i18n("Could not open file %1. Error %2", filename, QString::fromUtf8(error_status));
         if (silent == false)
             KSNotification::error(errMessage, i18n("FITS Open"));
-        if (Options::fITSLogging())
-            qDebug() << errMessage;
+        qCCritical(KSTARS_FITS) << errMessage;
         return false;
     }
 
@@ -132,8 +135,7 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
         errMessage = i18n("FITS file open error (fits_get_img_param): %1", QString::fromUtf8(error_status));
         if (silent == false)
             KSNotification::error(errMessage, i18n("FITS Open"));
-        if (Options::fITSLogging())
-            qDebug() << errMessage;
+        qCCritical(KSTARS_FITS) << errMessage;
         return false;
     }
 
@@ -142,8 +144,7 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
         errMessage = i18n("1D FITS images are not supported in KStars.");
         if (silent == false)
             KSNotification::error(errMessage, i18n("FITS Open"));
-        if (Options::fITSLogging())
-            qDebug() << errMessage;
+        qCCritical(KSTARS_FITS) << errMessage;
         return false;
     }
 
@@ -187,8 +188,7 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
             errMessage = i18n("Bit depth %1 is not supported.", stats.bitpix);
             if (silent == false)
                 KSNotification::error(errMessage, i18n("FITS Open"));
-            if (Options::fITSLogging())
-                qDebug() << errMessage;
+            qCCritical(KSTARS_FITS) << errMessage;
             return false;
             break;
     }
@@ -201,8 +201,7 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
         errMessage = i18n("Image has invalid dimensions %1x%2", naxes[0], naxes[1]);
         if (silent == false)
             KSNotification::error(errMessage, i18n("FITS Open"));
-        if (Options::fITSLogging())
-            qDebug() << errMessage;
+        qCCritical(KSTARS_FITS) << errMessage;
         return false;
     }
 
@@ -223,7 +222,7 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
     //if (image_buffer == nullptr)
     if (imageBuffer == nullptr)
     {
-        qDebug() << "FITSData: Not enough memory for image_buffer channel. Requested: "
+        qCWarning(KSTARS_FITS) << "FITSData: Not enough memory for image_buffer channel. Requested: "
                  << stats.samples_per_channel * channels * stats.bytesPerPixel << " bytes.";
         clearImageBuffers();
         return false;
@@ -242,8 +241,7 @@ bool FITSData::loadFITS(const QString &inFilename, bool silent)
         if (silent == false)
             KSNotification::error(errMessage, i18n("FITS Open"));
         fits_report_error(stderr, status);
-        if (Options::fITSLogging())
-            qDebug() << errMessage;
+        qCCritical(KSTARS_FITS) << errMessage;
         return false;
     }
 
@@ -293,7 +291,7 @@ int FITSData::saveFITS(const QString &newFilename)
 
         if (QFile::copy(filename, finalFileName) == false)
         {
-            qCritical() << "FITS: Failed to copy " << filename << " to " << finalFileName;
+            qCCritical(KSTARS_FITS()) << "FITS: Failed to copy " << filename << " to " << finalFileName;
             fptr = nullptr;
             return -1;
         }
@@ -870,8 +868,7 @@ int FITSData::findCannyStar(FITSData *data, const QRect &boundary)
         }
     }
 
-    if (Options::fITSLogging())
-        qDebug() << "FITS: Weighted Center is X: " << center->x << " Y: " << center->y << " Width: " << center->width;
+    qCDebug(KSTARS_FITS) << "FITS: Weighted Center is X: " << center->x << " Y: " << center->y << " Width: " << center->width;
 
     // If no stars were detected
     if (center->width == -1)
@@ -947,8 +944,7 @@ int FITSData::findCannyStar(FITSData *data, const QRect &boundary)
 
     data->appendStar(center);
 
-    if (Options::fITSLogging())
-        qDebug() << "Flux: " << FSum << " Half-Flux: " << HF << " HFR: " << center->HFR;
+    qCDebug(KSTARS_FITS) << "Flux: " << FSum << " Half-Flux: " << HF << " HFR: " << center->HFR;
 
     return 1;
 }
@@ -1025,8 +1021,7 @@ int FITSData::findOneStar(const QRectF &boundary)
         }
     }
 
-    if (Options::fITSLogging())
-        qDebug() << "FITS: Weighted Center is X: " << massX / totalMass << " Y: " << massY / totalMass;
+   qCDebug(KSTARS_FITS) << "FITS: Weighted Center is X: " << massX / totalMass << " Y: " << massY / totalMass;
 
     Edge *center  = new Edge;
     center->width = -1;
@@ -1245,12 +1240,9 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
             dispersion_ratio = 1.8 - (MINIMUM_STDVAR - initStdDev) * 0.2;
         }
 
-        if (Options::fITSLogging())
-        {
-            qDebug() << "SNR: " << stats.SNR;
-            qDebug() << "The threshold level is " << threshold << "(actual " << threshold - min
+        qCDebug(KSTARS_FITS) << "SNR: " << stats.SNR;
+        qCDebug(KSTARS_FITS) << "The threshold level is " << threshold << "(actual " << threshold - min
                      << ")  minimum edge width" << minEdgeWidth << " minimum edge limit " << minimumEdgeCount;
-        }
 
         threshold -= min;
 
@@ -1316,16 +1308,13 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
                                      (buffer[i_center + (i * stats.width) + starDiameter / 2] - min) >=
                                  dispersion_ratio))
                             {
-                                if (Options::fITSLogging())
-                                {
-                                    qDebug()
+                                qCDebug(KSTARS_FITS)
                                         << "Edge center is " << buffer[i_center + (i * stats.width)] - min
                                         << " Edge is " << buffer[i_center + (i * stats.width) - starDiameter / 2] - min
                                         << " and ratio is "
                                         << ((buffer[i_center + (i * stats.width)] - min) /
                                             (buffer[i_center + (i * stats.width) - starDiameter / 2] - min))
                                         << " located at X: " << center << " Y: " << i + 0.5;
-                                }
 
                                 Edge *newEdge = new Edge();
 
@@ -1348,8 +1337,7 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
             }
         }
 
-        if (Options::fITSLogging())
-            qDebug() << "Total number of edges found is: " << edges.count();
+        qCDebug(KSTARS_FITS) << "Total number of edges found is: " << edges.count();
 
         // In case of hot pixels
         if (edges.count() == 1 && initStdDev > 1)
@@ -1360,9 +1348,7 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
 
         if (edges.count() >= MAX_EDGE_LIMIT)
         {
-            if (Options::fITSLogging())
-                qDebug() << "Too many edges, aborting... " << edges.count();
-
+           qCWarning(KSTARS_FITS) << "Too many edges, aborting... " << edges.count();
             qDeleteAll(edges);
             return;
         }
@@ -1388,22 +1374,17 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
     // Now, let's scan the edges and find the maximum centroid vertically
     for (int i = 0; i < edges.count(); i++)
     {
-        if (Options::fITSLogging())
-        {
-            qDebug() << "# " << i << " Edge at (" << edges[i]->x << "," << edges[i]->y << ") With a value of "
+        qCDebug(KSTARS_FITS) << "# " << i << " Edge at (" << edges[i]->x << "," << edges[i]->y << ") With a value of "
                      << edges[i]->val << " and width of " << edges[i]->width << " pixels. with sum " << edges[i]->sum;
-        }
 
         // If edge scanned already, skip
         if (edges[i]->scanned == 1)
         {
-            if (Options::fITSLogging())
-                qDebug() << "Skipping check for center " << i << " because it was already counted";
+            qCDebug(KSTARS_FITS) << "Skipping check for center " << i << " because it was already counted";
             continue;
         }
 
-        if (Options::fITSLogging())
-            qDebug() << "Invetigating edge # " << i << " now ...";
+        qCDebug(KSTARS_FITS) << "Invetigating edge # " << i << " now ...";
 
         // Get X, Y, and Val of edge
         cen_x = edges[i]->x;
@@ -1452,8 +1433,7 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
                 cen_limit = 2;
         }
 
-        if (Options::fITSLogging())
-            qDebug() << "center_count: " << cen_count << " and initstdDev= " << initStdDev << " and limit is "
+        qCDebug(KSTARS_FITS) << "center_count: " << cen_count << " and initstdDev= " << initStdDev << " and limit is "
                      << cen_limit;
 
         if (cen_limit < 1)
@@ -1471,8 +1451,7 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
             width_sum += rCenter->width;
             rCenter->width = cen_w;
 
-            if (Options::fITSLogging())
-                qDebug() << "Found a real center with number with (" << rCenter->x << "," << rCenter->y << ")";
+            qCDebug(KSTARS_FITS) << "Found a real center with number with (" << rCenter->x << "," << rCenter->y << ")";
 
             // Calculate Total Flux From Center, Half Flux, Full Summation
             double TF   = 0;
@@ -1509,8 +1488,7 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
             {
                 if (TF >= HF)
                 {
-                    if (Options::fITSLogging())
-                        qDebug() << "Stopping at TF " << TF << " after #" << k << " pixels.";
+                    qCDebug(KSTARS_FITS) << "Stopping at TF " << TF << " after #" << k << " pixels.";
                     break;
                 }
 
@@ -1525,8 +1503,7 @@ void FITSData::findCentroid(const QRectF &boundary, int initStdDev, int minEdgeW
             // Store full flux
             rCenter->val = FSum;
 
-            if (Options::fITSLogging())
-                qDebug() << "HFR for this center is " << rCenter->HFR << " pixels and the total flux is " << FSum;
+            qCDebug(KSTARS_FITS) << "HFR for this center is " << rCenter->HFR << " pixels and the total flux is " << FSum;
 
             starCenters.append(rCenter);
         }
@@ -2136,8 +2113,7 @@ bool FITSData::loadWCS()
         return true;
     }
 
-    if (Options::fITSLogging())
-        qDebug() << "Started WCS Data Processing...";
+    qCDebug(KSTARS_FITS) << "Started WCS Data Processing...";
 
     int status = 0;
     char *header;
@@ -2220,8 +2196,7 @@ bool FITSData::loadWCS()
 
     WCSLoaded = true;
 
-    if (Options::fITSLogging())
-        qDebug() << "Finished WCS Data processing...";
+    qCDebug(KSTARS_FITS) << "Finished WCS Data processing...";
 
     return true;
 #endif
@@ -3760,8 +3735,7 @@ bool FITSData::createWCSFile(const QString &newWCSFile, double orientation, doub
     fitsfile *new_fptr;
     char errMsg[512];
 
-    if (Options::fITSLogging())
-        qDebug() << "Creating new WCS file: " << newWCSFile << " with parameters orientation: " << orientation
+    qCInfo(KSTARS_FITS) << "Creating new WCS file: " << newWCSFile << " with parameters orientation: " << orientation
                  << "ra: " << ra << "dec: " << dec << "Pixel scale: " << pixscale;
 
     nelements = stats.samples_per_channel * channels;
@@ -3806,8 +3780,7 @@ bool FITSData::createWCSFile(const QString &newWCSFile, double orientation, doub
     {
         QFile::remove(filename);
         tempFile = false;
-        if (Options::fITSLogging())
-            qDebug() << "Removing FITS File: " << filename;
+        qCDebug(KSTARS_FITS) << "Removing FITS File: " << filename;
     }
 
     filename = newWCSFile;
@@ -3938,8 +3911,7 @@ bool FITSData::createWCSFile(const QString &newWCSFile, double orientation, doub
 
     WCSLoaded = false;
 
-    if (Options::fITSLogging())
-        qDebug() << "Finished creating WCS file: " << newWCSFile;
+    qCDebug(KSTARS_FITS) << "Finished creating WCS file: " << newWCSFile;
 
     return true;
 }
diff --git a/kstars/fitsviewer/fitsviewer.cpp b/kstars/fitsviewer/fitsviewer.cpp
index 5088eab37..5d0da7089 100644
--- a/kstars/fitsviewer/fitsviewer.cpp
+++ b/kstars/fitsviewer/fitsviewer.cpp
@@ -37,6 +37,8 @@
 #include <KToolBar>
 #include <KNotifications/KStatusNotifierItem>
 
+#include <fits_debug.h>
+
 #define INITIAL_W 785
 #define INITIAL_H 650
 
@@ -401,7 +403,7 @@ bool FITSViewer::removeFITS(int fitsUID)
 
     if (tab == nullptr)
     {
-        qDebug() << "Cannot find tab with UID " << fitsUID << " in the FITS Viewer";
+        qCWarning(KSTARS_FITS) << "Cannot find tab with UID " << fitsUID << " in the FITS Viewer";
         return false;
     }
 
@@ -422,7 +424,7 @@ bool FITSViewer::updateFITS(const QUrl *imageName, int fitsUID, FITSScale filter
 
     if (tab == nullptr)
     {
-        qDebug() << "Cannot find tab with UID " << fitsUID << " in the FITS Viewer";
+        qCWarning(KSTARS_FITS) << "Cannot find tab with UID " << fitsUID << " in the FITS Viewer";
         return false;
     }
 
diff --git a/kstars/indi/drivermanager.cpp b/kstars/indi/drivermanager.cpp
index dc28bf9f2..735b1732a 100644
--- a/kstars/indi/drivermanager.cpp
+++ b/kstars/indi/drivermanager.cpp
@@ -33,6 +33,7 @@
 #endif
 
 #include <QTcpServer>
+#include <indi_debug.h>
 
 #define INDI_MAX_TRIES 2
 #define ERRMSG_SIZE    1024
@@ -312,8 +313,7 @@ bool DriverManager::startDevices(QList<DriverInfo *> &dList)
 
     getUniqueHosts(dList, uHosts);
 
-    if (Options::iNDILogging())
-        qDebug() << "INDI: Starting local drivers...";
+    qCDebug(KSTARS_INDI) << "INDI: Starting local drivers...";
 
     for (auto &qdv : uHosts)
     {
@@ -352,8 +352,7 @@ bool DriverManager::startDevices(QList<DriverInfo *> &dList)
             return false;
         }
 
-        if (Options::iNDILogging())
-            qDebug() << "INDI: INDI Server started locally on port " << port;
+        qCDebug(KSTARS_INDI) << "INDI: INDI Server started locally on port " << port;
 
         for (DriverInfo *dv : qdv)
         {
@@ -386,8 +385,7 @@ bool DriverManager::startDevices(QList<DriverInfo *> &dList)
 
         for (int i = 0; i < INDI_MAX_TRIES; i++)
         {
-            if (Options::iNDILogging())
-                qDebug() << "INDI: Connecting to local INDI server on port " << port << " ...";
+            qCDebug(KSTARS_INDI) << "INDI: Connecting to local INDI server on port " << port << " ...";
 
             connectionToServer = clientManager->connectServer();
 
@@ -402,16 +400,14 @@ bool DriverManager::startDevices(QList<DriverInfo *> &dList)
 
         if (connectionToServer)
         {
-            if (Options::iNDILogging())
-                qDebug() << "Connection to INDI server is successful";
+            qCDebug(KSTARS_INDI) << "Connection to INDI server is successful";
 
             clients.append(clientManager);
             updateMenuActions();
         }
         else
         {
-            if (Options::iNDILogging())
-                qDebug() << "INDI: Connection to local INDI server on port " << port << " failed!";
+            qCDebug(KSTARS_INDI) << "INDI: Connection to local INDI server on port " << port << " failed!";
 
             KNotification::beep();
             QPointer<QMessageBox> msgBox = new QMessageBox();
@@ -438,8 +434,7 @@ bool DriverManager::startDevices(QList<DriverInfo *> &dList)
 
 void DriverManager::stopDevices(const QList<DriverInfo *> &dList)
 {
-    if (Options::iNDILogging())
-        qDebug() << "INDI: Stopping local drivers...";
+    qCDebug(KSTARS_INDI) << "INDI: Stopping local drivers...";
 
     // #1 Disconnect all clients
     for (DriverInfo *dv : dList)
diff --git a/kstars/indi/indidevice.cpp b/kstars/indi/indidevice.cpp
index 727957b09..8da992706 100644
--- a/kstars/indi/indidevice.cpp
+++ b/kstars/indi/indidevice.cpp
@@ -46,6 +46,8 @@
 #include "indigroup.h"
 #include "indielement.h"
 
+#include <indi_debug.h>
+
 const char *libindi_strings_context = "string from libindi, used in the config dialog";
 
 INDI_D::INDI_D(GUIManager *in_manager, INDI::BaseDevice *in_dv, ClientManager *in_cm) : QDialog(0)
@@ -274,8 +276,7 @@ void INDI_D::updateMessageLog(INDI::BaseDevice *idv, int messageID)
     if (Options::showINDIMessages())
         KStars::Instance()->statusBar()->showMessage(i18nc("INDI message shown in status bar", "%1", message), 0);
 
-    if (Options::iNDILogging())
-        qDebug() << idv->getDeviceName() << ": " << message.mid(21);
+    qCInfo(KSTARS_INDI) << idv->getDeviceName() << ": " << message.mid(21);
 }
 
 INDI_D::~INDI_D()
diff --git a/kstars/indi/indilistener.cpp b/kstars/indi/indilistener.cpp
index 763dc5fc2..3e7d0d7b6 100644
--- a/kstars/indi/indilistener.cpp
+++ b/kstars/indi/indilistener.cpp
@@ -28,7 +28,7 @@
 
 #include <basedevice.h>
 
-#include <QDebug>
+#include <indi_debug.h>
 
 #define NINDI_STD 35
 
@@ -111,8 +111,7 @@ ISD::GDInterface *INDIListener::getDevice(const QString &name)
 
 void INDIListener::addClient(ClientManager *cm)
 {
-    if (Options::iNDILogging())
-        qDebug() << "INDIListener: Adding a new client manager to INDI listener..";
+    qCDebug(KSTARS_INDI) << "INDIListener: Adding a new client manager to INDI listener..";
 
     Qt::ConnectionType type = Qt::BlockingQueuedConnection;
 
@@ -163,8 +162,7 @@ void INDIListener::removeClient(ClientManager *cm)
 
 void INDIListener::processDevice(DeviceInfo *dv)
 {
-    if (Options::iNDILogging())
-        qDebug() << "INDIListener: Processing device " << dv->getBaseDevice()->getDeviceName();
+    qCDebug(KSTARS_INDI) << "INDIListener: Processing device " << dv->getBaseDevice()->getDeviceName();
 
     ISD::GDInterface *gd = new ISD::GenericDevice(*dv);
 
@@ -175,8 +173,7 @@ void INDIListener::processDevice(DeviceInfo *dv)
 
 void INDIListener::removeDevice(DeviceInfo *dv)
 {
-    if (Options::iNDILogging())
-        qDebug() << "INDIListener: Removing device " << dv->getBaseDevice()->getDeviceName() << " with unique label "
+    qCDebug(KSTARS_INDI) << "INDIListener: Removing device " << dv->getBaseDevice()->getDeviceName() << " with unique label "
                  << dv->getDriverInfo()->getUniqueLabel();
 
     foreach (ISD::GDInterface *gd, devices)
@@ -208,8 +205,7 @@ void INDIListener::removeDevice(DeviceInfo *dv)
 
 void INDIListener::registerProperty(INDI::Property *prop)
 {
-    if (Options::iNDILogging())
-        qDebug() << "<" << prop->getDeviceName() << ">: <" << prop->getName() << ">";
+   qCDebug(KSTARS_INDI) << "<" << prop->getDeviceName() << ">: <" << prop->getName() << ">";
 
     foreach (ISD::GDInterface *gd, devices)
     {
diff --git a/kstars/indi/inditelescope.cpp b/kstars/indi/inditelescope.cpp
index b351e1664..b2e9a46a5 100644
--- a/kstars/indi/inditelescope.cpp
+++ b/kstars/indi/inditelescope.cpp
@@ -19,6 +19,8 @@
 
 #include <KNotification>
 
+#include <indi_debug.h>
+
 namespace ISD
 {
 Telescope::Telescope(GDInterface *iPtr) : DeviceDecorator(iPtr)
@@ -547,8 +549,7 @@ bool Telescope::sendCoords(SkyPoint *ScopeTarget)
         DecEle->value = ScopeTarget->dec().Degrees();
         clientManager->sendNewNumber(EqProp);
 
-        if (Options::iNDILogging())
-            qDebug() << "ISD:Telescope: Sending coords RA " << RAEle->value << " DEC " << DecEle->value;
+        qCDebug(KSTARS_INDI) << "ISD:Telescope: Sending coords RA " << RAEle->value << " DEC " << DecEle->value;
 
         RAEle->value  = currentRA;
         DecEle->value = currentDEC;
@@ -602,8 +603,7 @@ bool Telescope::Slew(SkyPoint *ScopeTarget)
         slewSW->s = ISS_ON;
         clientManager->sendNewSwitch(motionSP);
 
-        if (Options::iNDILogging())
-            qDebug() << "ISD:Telescope: " << slewSW->name;
+        qCDebug(KSTARS_INDI) << "ISD:Telescope: " << slewSW->name;
     }
 
     return sendCoords(ScopeTarget);
@@ -637,8 +637,7 @@ bool Telescope::Sync(SkyPoint *ScopeTarget)
         syncSW->s = ISS_ON;
         clientManager->sendNewSwitch(motionSP);
 
-        if (Options::iNDILogging())
-            qDebug() << "ISD:Telescope: Syncing...";
+        qCDebug(KSTARS_INDI) << "ISD:Telescope: Syncing...";
     }
 
     return sendCoords(ScopeTarget);
@@ -656,8 +655,7 @@ bool Telescope::Abort()
     if (abortSW == nullptr)
         return false;
 
-    if (Options::iNDILogging())
-        qDebug() << "ISD:Telescope: Aborted." << endl;
+    qCDebug(KSTARS_INDI) << "ISD:Telescope: Aborted." << endl;
 
     abortSW->s = ISS_ON;
     clientManager->sendNewSwitch(motionSP);
@@ -677,8 +675,7 @@ bool Telescope::Park()
     if (parkSW == nullptr)
         return false;
 
-    if (Options::iNDILogging())
-        qDebug() << "ISD:Telescope: Parking..." << endl;
+    qCDebug(KSTARS_INDI) << "ISD:Telescope: Parking..." << endl;
 
     IUResetSwitch(parkSP);
     parkSW->s = ISS_ON;
@@ -699,8 +696,7 @@ bool Telescope::UnPark()
     if (parkSW == nullptr)
         return false;
 
-    if (Options::iNDILogging())
-        qDebug() << "ISD:Telescope: UnParking..." << endl;
+    qCDebug(KSTARS_INDI) << "ISD:Telescope: UnParking..." << endl;
 
     IUResetSwitch(parkSP);
     parkSW->s = ISS_ON;
diff --git a/kstars/indi/servermanager.cpp b/kstars/indi/servermanager.cpp
index 516e5ec06..7a487dc86 100644
--- a/kstars/indi/servermanager.cpp
+++ b/kstars/indi/servermanager.cpp
@@ -18,11 +18,12 @@
 #include <indidevapi.h>
 
 #include <KMessageBox>
-
 #include <QUuid>
 
 #include <sys/stat.h>
 
+#include <indi_debug.h>
+
 ServerManager::ServerManager(const QString& inHost, uint inPort)
 {
     host          = inHost;
@@ -101,7 +102,7 @@ bool ServerManager::start()
 
     if (!indiFIFO.open(QIODevice::ReadWrite | QIODevice::Text))
     {
-        qDebug() << "Unable to create INDI FIFO file: " << fifoFile << endl;
+        qCCritical(KSTARS_INDI) << "Unable to create INDI FIFO file: " << fifoFile << endl;
         return false;
     }
 
@@ -281,7 +282,7 @@ void ServerManager::processStandardError()
     if (Options::iNDILogging())
     {
         for (auto &msg : stderr.split('\n'))
-            qDebug() << "INDI Server: " << msg;
+            qCDebug(KSTARS_INDI) << "INDI Server: " << msg;
     }
 
     if (driverCrashed == false && (serverBuffer.contains("stdin EOF") || serverBuffer.contains("stderr EOF")))
diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index 7d1c25706..359c98a14 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -52,6 +52,8 @@
 #include <QStatusBar>
 #include <QMenu>
 
+#include <kstars_debug.h>
+
 KStars *KStars::pinstance = nullptr;
 bool KStars::Closing = false;
 
@@ -75,8 +77,10 @@ KStars::KStars(bool doSplash, bool clockrun, const QString &startdate)
     else
         KSUtils::Logging::UseDefault();
 
-    qDebug() << "Welcome to KStars" << KSTARS_VERSION;
-    qDebug() << "Build: " << KSTARS_BUILD_TS;
+    KSUtils::Logging::SyncFilterRules();
+
+    qCInfo(KSTARS) << "Welcome to KStars" << KSTARS_VERSION;
+    qCInfo(KSTARS) << "Build: " << KSTARS_BUILD_TS;
 
     new KstarsAdaptor(
         this); // NOTE the weird case convention, which cannot be changed as the file is generated by the moc.
diff --git a/kstars/kstarsdata.cpp b/kstars/kstarsdata.cpp
index 74b71dac6..1eac29b42 100644
--- a/kstars/kstarsdata.cpp
+++ b/kstars/kstarsdata.cpp
@@ -39,6 +39,8 @@
 #include <QSqlQuery>
 #include <QtConcurrent>
 
+#include "kstars_debug.h"
+
 namespace
 {
 // Report fatal error during data loading to user
@@ -667,7 +669,7 @@ bool KStarsData::readURLData(const QString &urlfile, int type, bool deepOnly)
 
             if (!o)
             {
-                qWarning() << i18n("Object named %1 not found", name);
+                qCWarning(KSTARS) << i18n("Object named %1 not found", name);
             }
             else
             {
diff --git a/kstars/kstarsdbus.cpp b/kstars/kstarsdbus.cpp
index 1113d96c7..b983dae10 100644
--- a/kstars/kstarsdbus.cpp
+++ b/kstars/kstarsdbus.cpp
@@ -46,6 +46,8 @@
 #include <QPrintDialog>
 #include <QPrinter>
 
+#include "kstars_debug.h"
+
 void KStars::setRaDec(double ra, double dec)
 {
     SkyPoint p(ra, dec);
@@ -830,7 +832,7 @@ void KStars::renderEyepieceView(const QString &objectName, const QString &destPa
     const SkyObject *obj = data()->objectNamed(objectName);
     if (!obj)
     {
-        qWarning() << "Object named " << objectName << " was not found!";
+        qCWarning(KSTARS) << "Object named " << objectName << " was not found!";
         return;
     }
     SkyObject *target          = obj->clone();
diff --git a/kstars/main.cpp b/kstars/main.cpp
index 04dd41539..ab5b27909 100644
--- a/kstars/main.cpp
+++ b/kstars/main.cpp
@@ -87,12 +87,12 @@ int main(int argc, char *argv[])
                         "http://www.indilib.org");
 
     // Active developers
-    aboutData.addAuthor(i18n("Akarsh Simha"), QString(), "akarsh at kde.org", "http://www.ph.utexas.edu/~asimha");
-    aboutData.addAuthor(i18n("Artem Fedoskin"), i18n("KStars Lite"), "afedoskin3 at gmail.com");
+    aboutData.addAuthor(i18n("Akarsh Simha"), QString(), "akarsh at kde.org", "http://www.ph.utexas.edu/~asimha");    
     aboutData.addAuthor(i18n("Robert Lancaster"), i18n("FITSViewer Improvements. KStars OSX Port"),
                         "rlancaste at gmail.com");
 
     // Inactive developers
+    aboutData.addAuthor(i18n("Artem Fedoskin"), i18n("KStars Lite"), "afedoskin3 at gmail.com");
     aboutData.addAuthor(i18n("James Bowlin"), QString(), "bowlin at mindspring.com");
     aboutData.addAuthor(i18n("Pablo de Vicente"), QString(), "pvicentea at wanadoo.es");
     aboutData.addAuthor(i18n("Thomas Kabelmann"), QString(), "tk78 at gmx.de");
diff --git a/kstars/options/opsadvanced.cpp b/kstars/options/opsadvanced.cpp
index f665d3435..941329dd9 100644
--- a/kstars/options/opsadvanced.cpp
+++ b/kstars/options/opsadvanced.cpp
@@ -23,6 +23,8 @@
 #include "Options.h"
 #include "widgets/timespinbox.h"
 
+#include <KConfigDialog>
+
 #include <QCheckBox>
 #include <QDesktopServices>
 #include <QLabel>
@@ -48,6 +50,11 @@ OpsAdvanced::OpsAdvanced() : QFrame(KStars::Instance())
     connect(kcfg_ObsListDemoteHole, &QCheckBox::toggled,
             [this](bool state) { kcfg_ObsListHoleSize->setEnabled(state); });
 
+    //Get a pointer to the KConfigDialog
+    KConfigDialog *m_ConfigDialog = KConfigDialog::exists("settings");
+    connect(m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slotApply()));
+    connect(m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(slotApply()));
+
     for (auto &b : modulesGroup->buttons())
         b->setEnabled(kcfg_VerboseLogging->isChecked());
 }
@@ -98,3 +105,8 @@ void OpsAdvanced::slotShowLogFiles()
 
     QDesktopServices::openUrl(path);
 }
+
+void OpsAdvanced::slotApply()
+{
+    KSUtils::Logging::SyncFilterRules();
+}
diff --git a/kstars/options/opsadvanced.h b/kstars/options/opsadvanced.h
index 6fa02efa0..9ed6f0551 100644
--- a/kstars/options/opsadvanced.h
+++ b/kstars/options/opsadvanced.h
@@ -47,4 +47,5 @@ class OpsAdvanced : public QFrame, public Ui::OpsAdvanced
     void slotToggleVerbosityOptions();
     void slotToggleOutputOptions();
     void slotShowLogFiles();
+    void slotApply();
 };
diff --git a/kstars/skycomponents/constellationlines.cpp b/kstars/skycomponents/constellationlines.cpp
index 871e07093..736d16e79 100644
--- a/kstars/skycomponents/constellationlines.cpp
+++ b/kstars/skycomponents/constellationlines.cpp
@@ -29,6 +29,8 @@
 #include "skycomponents/culturelist.h"
 #include "skycomponents/starcomponent.h"
 
+#include "kstars_debug.h"
+
 ConstellationLines::ConstellationLines(SkyComposite *parent, CultureList *cultures)
     : LineListIndex(parent, i18n("Constellation Lines")), m_reindexNum(J2000)
 {
@@ -107,7 +109,7 @@ ConstellationLines::ConstellationLines(SkyComposite *parent, CultureList *cultur
                 lineList->append(std::move(star));
             }
             else if (!star.get())
-                qWarning() << i18n("Star HD%1 not found.", HDnum);
+                qCWarning(KSTARS) << i18n("Star HD%1 not found.", HDnum);
         }
     }
     //Add the last clc component
diff --git a/kstars/skycomponents/deepstarcomponent.cpp b/kstars/skycomponents/deepstarcomponent.cpp
index a24ed4cf2..55a04385d 100644
--- a/kstars/skycomponents/deepstarcomponent.cpp
+++ b/kstars/skycomponents/deepstarcomponent.cpp
@@ -33,6 +33,8 @@
 #include <qplatformdefs.h>
 #include <QtConcurrent>
 
+#include <kstars_debug.h>
+
 #ifdef _WIN32
 #include <windows.h>
 #endif
@@ -456,7 +458,7 @@ bool DeepStarComponent::openDataFile()
         {
             if (!(m_skyMesh = SkyMesh::Create(htm_level)))
             {
-                qDebug() << "Could not create HTMesh of level " << htm_level << " for catalog " << dataFileName
+                qCWarning(KSTARS) << "Could not create HTMesh of level " << htm_level << " for catalog " << dataFileName
                          << ". Skipping it.";
                 return false;
             }
@@ -465,14 +467,14 @@ bool DeepStarComponent::openDataFile()
         if (starReader.getByteSwap())
             MSpT = bswap_16(MSpT);
         fileOpened = true;
-        qDebug() << "  Sky Mesh Size: " << m_skyMesh->size();
+        qCDebug(KSTARS) << "  Sky Mesh Size: " << m_skyMesh->size();
         for (long int i = 0; i < m_skyMesh->size(); i++)
         {
             std::shared_ptr<StarBlockList> sbl(new StarBlockList(i, this));
 
             if (!sbl.get())
             {
-                qDebug() << "nullptr starBlockList. Expect trouble!";
+                qCWarning(KSTARS) << "nullptr starBlockList. Expect trouble!";
             }
             m_starBlockList.append(sbl);
         }
diff --git a/kstars/time/simclock.cpp b/kstars/time/simclock.cpp
index 0672ae629..e983fd112 100644
--- a/kstars/time/simclock.cpp
+++ b/kstars/time/simclock.cpp
@@ -22,7 +22,7 @@
 #include "simclockadaptor.h"
 #endif
 
-#include <QDebug>
+#include <kstars_debug.h>
 
 int SimClock::TimerInterval = 100; //msec
 
@@ -121,7 +121,7 @@ void SimClock::stop()
 
     if (!ManualMode && tmr.isActive())
     {
-        qDebug() << "Stopping the timer";
+        qCDebug(KSTARS) << "Stopping the timer";
         tmr.stop();
         emit clockToggled(true);
     }
@@ -141,7 +141,7 @@ void SimClock::start()
     }
     else if (!ManualMode && !tmr.isActive())
     {
-        qDebug() << "Starting the timer";
+        qCDebug(KSTARS) << "Starting the timer";
         sysmark.start();
         julianmark  = UTC.djd();
         lastelapsed = 0;
@@ -166,13 +166,13 @@ void SimClock::setUTC(const KStarsDateTime &newtime)
             lastelapsed = 0;
         }
 
-        qDebug() << QString("Setting clock:  UTC: %1  JD: %2")
+        qCInfo(KSTARS) << QString("Setting clock:  UTC: %1  JD: %2")
                         .arg(UTC.toString(), QLocale().toString((double)UTC.djd(), 'f', 2));
         emit timeChanged();
     }
     else
     {
-        qDebug() << "Cannot set SimClock:  Invalid Date/Time.";
+        qCWarning(KSTARS) << "Cannot set SimClock:  Invalid Date/Time.";
     }
 }
 
@@ -180,7 +180,7 @@ void SimClock::setClockScale(float s)
 {
     if (Scale != s)
     {
-        qDebug() << "New clock scale: " << s << " sec";
+        qCInfo(KSTARS) << "New clock scale: " << s << " sec";
         Scale = s;
         if (tmr.isActive())
         {


More information about the Kstars-devel mailing list