summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-07-17 10:47:56 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-07-17 10:47:56 (GMT)
commit718630cd9d1554ef52fbab471343d48a200ac092 (patch)
treee45b88bc4da270122d307a1c859ef41a8f796aa3
parent16d0f262531f5c369f25b61adaaf94406dce6409 (diff)
Make logs organized by date and time
-rw-r--r--kstars/auxiliary/ksutils.cpp25
-rw-r--r--kstars/auxiliary/ksutils.h2
-rw-r--r--kstars/kstars.cpp4
-rw-r--r--kstars/kstars.kcfg6
-rw-r--r--kstars/options/opsadvanced.cpp15
-rw-r--r--kstars/options/opsadvanced.ui60
6 files changed, 46 insertions, 66 deletions
diff --git a/kstars/auxiliary/ksutils.cpp b/kstars/auxiliary/ksutils.cpp
index f909f79..44301cd 100644
--- a/kstars/auxiliary/ksutils.cpp
+++ b/kstars/auxiliary/ksutils.cpp
@@ -535,16 +535,23 @@ QString constGenetiveToAbbrev( const QString &genetive_ ) {
QString Logging::_filename;
- void Logging::UseFile(const QString &filename)
+ void Logging::UseFile()
{
- _filename = filename;
-
- // Clear file contents
- QFile file(filename);
- file.open(QFile::WriteOnly);
- file.close();
-
- qInstallMessageHandler(File);
+ if (_filename.isEmpty())
+ {
+ QDir dir;
+ QString path = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "logs/" + QDateTime::currentDateTime().toString("yyyy-MM-dd");
+ dir.mkpath(path);
+ QString name = "log_" + QDateTime::currentDateTime().toString("HH:mm:ss") + ".txt";
+ _filename = path + QStringLiteral("/") + name;
+ }
+
+ // Clear file contents
+ QFile file(_filename);
+ file.open(QFile::WriteOnly);
+ file.close();
+
+ qInstallMessageHandler(File);
}
void Logging::File(QtMsgType type, const QMessageLogContext &, const QString &msg)
diff --git a/kstars/auxiliary/ksutils.h b/kstars/auxiliary/ksutils.h
index 0bdddb8..f27a967 100644
--- a/kstars/auxiliary/ksutils.h
+++ b/kstars/auxiliary/ksutils.h
@@ -176,7 +176,7 @@ namespace KSUtils {
* Store all logs into the specified file
* @param filename the file in which to store logs
*/
- static void UseFile(const QString &filename);
+ static void UseFile();
/**
* Output logs to stdout
diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index 10c66c2..ef027f9 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -72,8 +72,8 @@ KStars::KStars( bool doSplash, bool clockrun, const QString &startdate )
// Initialize logging settings
if (Options::disableLogging())
KSUtils::Logging::Disable();
- else if (Options::logToFile() && Options::verboseLogFile().isEmpty() == false)
- KSUtils::Logging::UseFile(Options::verboseLogFile());
+ else if (Options::logToFile())
+ KSUtils::Logging::UseFile();
else
KSUtils::Logging::UseDefault();
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index 5f2350c..4ed7f21 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -1209,11 +1209,7 @@
<label>Log debug message to a log file</label>
<whatsthis>Checking this option causes KStars log debug messages to a log file as specified.</whatsthis>
<default>false</default>
- </entry>
- <entry name="VerboseLogFile" type="String">
- <label>Verbose Log File</label>
- <whatsthis>Verbose log file to save all of KStars generated debug messages to.</whatsthis>
- </entry>
+ </entry>
<entry name="FITSLogging" type="Bool">
<whatsthis>Log FITS Data activity.</whatsthis>
<default>false</default>
diff --git a/kstars/options/opsadvanced.cpp b/kstars/options/opsadvanced.cpp
index 606bebb..98a1397 100644
--- a/kstars/options/opsadvanced.cpp
+++ b/kstars/options/opsadvanced.cpp
@@ -80,21 +80,12 @@ void OpsAdvanced::slotToggleVerbosityOptions()
void OpsAdvanced::slotToggleOutputOptions()
{
if (kcfg_LogToDefault->isChecked())
- {
- kcfg_VerboseLogFile->setEnabled(false);
+ {
if (kcfg_DisableLogging->isChecked() == false)
KSUtils::Logging::UseDefault();
}
- else
- {
- kcfg_VerboseLogFile->setEnabled(true);
-
- if (kcfg_VerboseLogFile->text().isEmpty())
- kcfg_VerboseLogFile->setText(KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "kstars.log");
-
- if (kcfg_DisableLogging->isChecked() == false)
- KSUtils::Logging::UseFile(kcfg_VerboseLogFile->text());
- }
+ else
+ KSUtils::Logging::UseFile();
}
diff --git a/kstars/options/opsadvanced.ui b/kstars/options/opsadvanced.ui
index 6683621..ce6cb0e 100644
--- a/kstars/options/opsadvanced.ui
+++ b/kstars/options/opsadvanced.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>584</width>
- <height>446</height>
+ <height>473</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -244,6 +244,22 @@
<string>Logging Output</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="3">
+ <widget class="QRadioButton" name="kcfg_DisableLogging">
+ <property name="toolTip">
+ <string>Disable all logging output</string>
+ </property>
+ <property name="text">
+ <string>Disable</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">verbosityButtonGroup</string>
+ </attribute>
+ </widget>
+ </item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -280,19 +296,16 @@
</attribute>
</widget>
</item>
- <item row="0" column="3">
- <widget class="QRadioButton" name="kcfg_DisableLogging">
+ <item row="2" column="3">
+ <widget class="QCheckBox" name="kcfg_CaptureLogging">
<property name="toolTip">
- <string>Disable all logging output</string>
+ <string>Log Ekos Capture module activity</string>
</property>
<property name="text">
- <string>Disable</string>
- </property>
- <property name="checked">
- <bool>false</bool>
+ <string>Capture</string>
</property>
<attribute name="buttonGroup">
- <string notr="true">verbosityButtonGroup</string>
+ <string notr="true">modulesGroup</string>
</attribute>
</widget>
</item>
@@ -365,19 +378,6 @@
</attribute>
</widget>
</item>
- <item row="2" column="3">
- <widget class="QCheckBox" name="kcfg_CaptureLogging">
- <property name="toolTip">
- <string>Log Ekos Capture module activity</string>
- </property>
- <property name="text">
- <string>Capture</string>
- </property>
- <attribute name="buttonGroup">
- <string notr="true">modulesGroup</string>
- </attribute>
- </widget>
- </item>
<item row="2" column="4">
<widget class="QCheckBox" name="kcfg_FocusLogging">
<property name="toolTip">
@@ -430,20 +430,6 @@
</attribute>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Log file:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1" colspan="7">
- <widget class="QLineEdit" name="kcfg_VerboseLogFile">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
@@ -996,8 +982,8 @@
<resources/>
<connections/>
<buttongroups>
- <buttongroup name="verbosityButtonGroup"/>
<buttongroup name="logbuttonGroup"/>
+ <buttongroup name="verbosityButtonGroup"/>
<buttongroup name="modulesGroup">
<property name="exclusive">
<bool>false</bool>