Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
c4478240
Unverified
Commit
c4478240
authored
Apr 10, 2018
by
Don Gagne
Committed by
GitHub
Apr 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6336 from DonLakeFlyer/LogOutput
Allow logging console output to file from command line
parents
928ad194
8e83e199
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
25 deletions
+51
-25
QGCApplication.cc
src/QGCApplication.cc
+15
-23
QGCApplication.h
src/QGCApplication.h
+5
-1
AppMessages.cc
src/QmlControls/AppMessages.cc
+27
-1
AppMessages.h
src/QmlControls/AppMessages.h
+4
-0
No files found.
src/QGCApplication.cc
View file @
c4478240
...
...
@@ -138,31 +138,22 @@ static QObject* qgroundcontrolQmlGlobalSingletonFactory(QQmlEngine*, QJSEngine*)
return
qmlGlobal
;
}
/**
* @brief Constructor for the main application.
*
* This constructor initializes and starts the whole application. It takes standard
* command-line parameters
*
* @param argc The number of command-line parameters
* @param argv The string array of parameters
**/
QGCApplication
::
QGCApplication
(
int
&
argc
,
char
*
argv
[],
bool
unitTesting
)
#ifdef __mobile__
:
QGuiApplication
(
argc
,
argv
)
,
_qmlAppEngine
(
NULL
)
#else
:
QApplication
(
argc
,
argv
)
#endif
,
_runningUnitTests
(
unitTesting
)
,
_fakeMobile
(
false
)
,
_settingsUpgraded
(
false
)
#ifdef QT_DEBUG
,
_testHighDPI
(
false
)
#endif
,
_toolbox
(
NULL
)
,
_bluetoothAvailable
(
false
)
:
QGuiApplication
(
argc
,
argv
)
,
_qmlAppEngine
(
NULL
)
#else
:
QApplication
(
argc
,
argv
)
#endif
,
_runningUnitTests
(
unitTesting
)
,
_logOutput
(
false
)
,
_fakeMobile
(
false
)
,
_settingsUpgraded
(
false
)
#ifdef QT_DEBUG
,
_testHighDPI
(
false
)
#endif
,
_toolbox
(
NULL
)
,
_bluetoothAvailable
(
false
)
{
_app
=
this
;
...
...
@@ -225,6 +216,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
{
"--clear-settings"
,
&
fClearSettingsOptions
,
NULL
},
{
"--logging"
,
&
logging
,
&
loggingOptions
},
{
"--fake-mobile"
,
&
_fakeMobile
,
NULL
},
{
"--log-output"
,
&
_logOutput
,
NULL
},
#ifdef QT_DEBUG
{
"--test-high-dpi"
,
&
_testHighDPI
,
NULL
},
#endif
...
...
src/QGCApplication.h
View file @
c4478240
...
...
@@ -69,9 +69,12 @@ public:
/// @brief Clears the persistent flag to delete all settings the next time QGroundControl is started.
void
clearDeleteAllSettingsNextBoot
(
void
);
/// @brief Returns true
e if unit test
are being run
/// @brief Returns true
if unit tests
are being run
bool
runningUnitTests
(
void
)
{
return
_runningUnitTests
;
}
/// @brief Returns true if Qt debug output should be logged to a file
bool
logOutput
(
void
)
{
return
_logOutput
;
}
/// Used to report a missing Parameter. Warning will be displayed to user. Method may be called
/// multiple times.
void
reportMissingParameter
(
int
componentId
,
const
QString
&
name
);
...
...
@@ -158,6 +161,7 @@ private:
#endif
bool
_runningUnitTests
;
///< true: running unit tests, false: normal app
bool
_logOutput
;
///< true: Log Qt debug output to file
static
const
char
*
_darkStyleFile
;
static
const
char
*
_lightStyleFile
;
...
...
src/QmlControls/AppMessages.cc
View file @
c4478240
...
...
@@ -11,8 +11,12 @@
// Allows QGlobalStatic to work on this translation unit
#define _LOG_CTOR_ACCESS_ public
#include "AppMessages.h"
#include <QFile>
#include "QGCApplication.h"
#include "SettingsManager.h"
#include "AppSettings.h"
#include <QStringListModel>
#include <QtConcurrent>
#include <QTextStream>
...
...
@@ -87,4 +91,26 @@ void AppLogModel::threadsafeLog(const QString message)
const
int
line
=
rowCount
();
insertRows
(
line
,
1
);
setData
(
index
(
line
),
message
,
Qt
::
DisplayRole
);
if
(
qgcApp
()
->
logOutput
())
{
if
(
_logFile
.
fileName
().
isEmpty
())
{
QGCToolbox
*
toolbox
=
qgcApp
()
->
toolbox
();
// Be careful of toolbox not being open yet
if
(
toolbox
)
{
QString
saveDirPath
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
crashSavePath
();
QDir
saveDir
(
saveDirPath
);
QString
saveFilePath
=
saveDir
.
absoluteFilePath
(
QStringLiteral
(
"QGCConsole.log"
));
_logFile
.
setFileName
(
saveFilePath
);
if
(
!
_logFile
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
qgcApp
()
->
showMessage
(
tr
(
"Open console log output file failed %1 : %2"
).
arg
(
_logFile
.
fileName
()).
arg
(
_logFile
.
errorString
()));
}
}
}
if
(
_logFile
.
isOpen
())
{
QTextStream
out
(
&
_logFile
);
out
<<
message
<<
"
\n
"
;
}
}
}
src/QmlControls/AppMessages.h
View file @
c4478240
...
...
@@ -13,6 +13,7 @@
#include <QObject>
#include <QStringListModel>
#include <QUrl>
#include <QFile>
// Hackish way to force only this translation unit to have public ctor access
#ifndef _LOG_CTOR_ACCESS_
...
...
@@ -34,6 +35,9 @@ signals:
private
slots
:
void
threadsafeLog
(
const
QString
message
);
private:
QFile
_logFile
;
_LOG_CTOR_ACCESS_:
AppLogModel
();
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment