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
4c3c6da4
Commit
4c3c6da4
authored
8 years ago
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3399 from DonLakeFlyer/ConsoleLogFilter
Settings/Console log filter support
parents
a6e25ea9
70953c46
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
249 additions
and
194 deletions
+249
-194
QGCApplication.cc
src/QGCApplication.cc
+2
-66
QGCLoggingCategory.cc
src/QGCLoggingCategory.cc
+66
-0
QGCLoggingCategory.h
src/QGCLoggingCategory.h
+22
-4
AppMessages.qml
src/QmlControls/AppMessages.qml
+146
-95
QGroundControlQmlGlobal.h
src/QmlControls/QGroundControlQmlGlobal.h
+13
-0
MainWindowLeftPanel.qml
src/ui/MainWindowLeftPanel.qml
+0
-29
No files found.
src/QGCApplication.cc
View file @
4c3c6da4
...
...
@@ -268,72 +268,8 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
ParseCmdLineOptions
(
argc
,
argv
,
rgCmdLineOptions
,
sizeof
(
rgCmdLineOptions
)
/
sizeof
(
rgCmdLineOptions
[
0
]),
false
);
#ifdef __mobile__
QLoggingCategory
::
setFilterRules
(
QStringLiteral
(
"*Log.debug=false"
));
#else
QString
filterRules
;
// Turn off bogus ssl warning
filterRules
+=
"qt.network.ssl.warning=false
\n
"
;
if
(
logging
)
{
QStringList
logList
=
loggingOptions
.
split
(
","
);
if
(
logList
[
0
]
==
"full"
)
{
filterRules
+=
"*Log.debug=true
\n
"
;
for
(
int
i
=
1
;
i
<
logList
.
count
();
i
++
)
{
filterRules
+=
logList
[
i
];
filterRules
+=
".debug=false
\n
"
;
}
}
else
{
foreach
(
const
QString
&
rule
,
logList
)
{
filterRules
+=
rule
;
filterRules
+=
".debug=true
\n
"
;
}
}
}
else
{
// First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy
// it to the correct location. This way default debug builds will have logging turned off.
static
const
char
*
qtProjectDir
=
"QtProject"
;
static
const
char
*
qtLoggingFile
=
"qtlogging.ini"
;
bool
loggingDirectoryOk
=
false
;
QDir
iniFileLocation
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericConfigLocation
));
if
(
!
iniFileLocation
.
cd
(
qtProjectDir
))
{
if
(
!
iniFileLocation
.
mkdir
(
qtProjectDir
))
{
qDebug
()
<<
"Unable to create qtlogging.ini directory"
<<
iniFileLocation
.
filePath
(
qtProjectDir
);
}
else
{
if
(
!
iniFileLocation
.
cd
(
qtProjectDir
))
{
qDebug
()
<<
"Unable to access qtlogging.ini directory"
<<
iniFileLocation
.
filePath
(
qtProjectDir
);;
}
loggingDirectoryOk
=
true
;
}
}
else
{
loggingDirectoryOk
=
true
;
}
if
(
loggingDirectoryOk
)
{
qDebug
()
<<
"Logging ini file directory"
<<
iniFileLocation
.
absolutePath
();
if
(
!
iniFileLocation
.
exists
(
qtLoggingFile
))
{
QFile
loggingFile
(
iniFileLocation
.
filePath
(
qtLoggingFile
));
if
(
loggingFile
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
QTextStream
out
(
&
loggingFile
);
out
<<
"[Rules]
\n
"
;
out
<<
"*Log.debug=false
\n
"
;
foreach
(
const
QString
&
category
,
QGCLoggingCategoryRegister
::
instance
()
->
registeredCategories
())
{
out
<<
category
<<
".debug=false
\n
"
;
}
}
else
{
qDebug
()
<<
"Unable to create logging file"
<<
QString
(
qtLoggingFile
)
<<
"in"
<<
iniFileLocation
;
}
}
}
}
qDebug
()
<<
"Filter rules"
<<
filterRules
;
QLoggingCategory
::
setFilterRules
(
filterRules
);
#endif
// Set up our logging filters
QGCLoggingCategoryRegister
::
instance
()
->
setFilterRulesFromSettings
(
loggingOptions
);
// Set up timer for delayed missing fact display
_missingParamsDelayedDisplayTimer
.
setSingleShot
(
true
);
...
...
This diff is collapsed.
Click to expand it.
src/QGCLoggingCategory.cc
View file @
4c3c6da4
...
...
@@ -26,6 +26,8 @@
#include "QGCLoggingCategory.h"
#include <QSettings>
// Add Global logging categories (not class specific) here using QGC_LOGGING_CATEGORY
QGC_LOGGING_CATEGORY
(
FirmwareUpgradeLog
,
"FirmwareUpgradeLog"
)
QGC_LOGGING_CATEGORY
(
FirmwareUpgradeVerboseLog
,
"FirmwareUpgradeVerboseLog"
)
...
...
@@ -34,6 +36,7 @@ QGC_LOGGING_CATEGORY(MissionItemLog, "MissionItemLog")
QGC_LOGGING_CATEGORY
(
ParameterLoaderLog
,
"ParameterLoaderLog"
)
QGCLoggingCategoryRegister
*
_instance
=
NULL
;
const
char
*
QGCLoggingCategoryRegister
::
_filterRulesSettingsGroup
=
"LoggingFilters"
;
QGCLoggingCategoryRegister
*
QGCLoggingCategoryRegister
::
instance
(
void
)
{
...
...
@@ -44,3 +47,66 @@ QGCLoggingCategoryRegister* QGCLoggingCategoryRegister::instance(void)
return
_instance
;
}
QStringList
QGCLoggingCategoryRegister
::
registeredCategories
(
void
)
{
_registeredCategories
.
sort
();
return
_registeredCategories
;
}
void
QGCLoggingCategoryRegister
::
setCategoryLoggingOn
(
const
QString
&
category
,
bool
enable
)
{
QSettings
settings
;
settings
.
beginGroup
(
_filterRulesSettingsGroup
);
settings
.
setValue
(
category
,
enable
);
}
bool
QGCLoggingCategoryRegister
::
categoryLoggingOn
(
const
QString
&
category
)
{
QSettings
settings
;
settings
.
beginGroup
(
_filterRulesSettingsGroup
);
return
settings
.
value
(
category
,
false
).
toBool
();
}
void
QGCLoggingCategoryRegister
::
setFilterRulesFromSettings
(
const
QString
&
commandLineLoggingOptions
)
{
if
(
!
commandLineLoggingOptions
.
isEmpty
())
{
_commandLineLoggingOptions
=
commandLineLoggingOptions
;
}
QString
filterRules
;
// Turn off bogus ssl warning
filterRules
+=
"qt.network.ssl.warning=false
\n
"
;
filterRules
+=
"*Log.debug=false
\n
"
;
// Set up filters defined in settings
foreach
(
QString
category
,
_registeredCategories
)
{
if
(
categoryLoggingOn
(
category
))
{
filterRules
+=
category
;
filterRules
+=
".debug=true
\n
"
;
}
}
// Command line rules take precedence, so they go last in the list
if
(
!
_commandLineLoggingOptions
.
isEmpty
())
{
QStringList
logList
=
_commandLineLoggingOptions
.
split
(
","
);
if
(
logList
[
0
]
==
"full"
)
{
filterRules
+=
"*Log.debug=true
\n
"
;
for
(
int
i
=
1
;
i
<
logList
.
count
();
i
++
)
{
filterRules
+=
logList
[
i
];
filterRules
+=
".debug=false
\n
"
;
}
}
else
{
foreach
(
const
QString
&
rule
,
logList
)
{
filterRules
+=
rule
;
filterRules
+=
".debug=true
\n
"
;
}
}
}
qDebug
()
<<
"Filter rules"
<<
filterRules
;
QLoggingCategory
::
setFilterRules
(
filterRules
);
}
This diff is collapsed.
Click to expand it.
src/QGCLoggingCategory.h
View file @
4c3c6da4
...
...
@@ -44,18 +44,36 @@ Q_DECLARE_LOGGING_CATEGORY(ParameterLoaderLog)
static QGCLoggingCategory qgcCategory ## name (__VA_ARGS__); \
Q_LOGGING_CATEGORY(name, __VA_ARGS__)
class
QGCLoggingCategoryRegister
class
QGCLoggingCategoryRegister
:
public
QObject
{
Q_OBJECT
public:
static
QGCLoggingCategoryRegister
*
instance
(
void
);
/// Registers the specified logging category to the system.
void
registerCategory
(
const
char
*
category
)
{
_registeredCategories
<<
category
;
}
const
QStringList
&
registeredCategories
(
void
)
{
return
_registeredCategories
;
}
/// Returns the list of available logging category names.
Q_INVOKABLE
QStringList
registeredCategories
(
void
);
/// Turns on/off logging for the specified category. State is saved in app settings.
Q_INVOKABLE
void
setCategoryLoggingOn
(
const
QString
&
category
,
bool
enable
);
/// Returns true if logging is turned on for the specified category.
Q_INVOKABLE
bool
categoryLoggingOn
(
const
QString
&
category
);
/// Sets the logging filters rules from saved settings.
/// @param commandLineLogggingOptions Logging options which were specified on the command line
void
setFilterRulesFromSettings
(
const
QString
&
commandLineLoggingOptions
);
private:
QGCLoggingCategoryRegister
(
void
)
{
}
QStringList
_registeredCategories
;
QString
_commandLineLoggingOptions
;
static
const
char
*
_filterRulesSettingsGroup
;
};
class
QGCLoggingCategory
...
...
This diff is collapsed.
Click to expand it.
src/QmlControls/AppMessages.qml
View file @
4c3c6da4
...
...
@@ -26,115 +26,166 @@ import QtQuick.Controls 1.2
import
QtQuick
.
Controls
.
Styles
1.2
import
QtQuick
.
Dialogs
1.2
import
QGroundControl
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
Controllers
1.0
import
QGroundControl
.
ScreenTools
1.0
Rectangle
{
id
:
logwindow
anchors.fill
:
parent
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
color
:
qgcPal
.
window
QGCView
{
id
:
qgcView
viewPanel
:
panel
property
bool
loaded
:
false
QGCPalette
{
id
:
qgcPal
}
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
panel
.
enabled
}
Connections
{
target
:
debugMessageModel
onDataChanged
:
{
// Keep the view in sync if the button is checked
if
(
loaded
)
{
if
(
followTail
.
checked
)
{
listview
.
positionViewAtEnd
();
Component
{
id
:
filtersDialogComponent
QGCViewDialog
{
QGCFlickable
{
anchors.fill
:
parent
contentHeight
:
categoryColumn
.
height
clip
:
true
Column
{
id
:
categoryColumn
spacing
:
ScreenTools
.
defaultFontPixelHeight
/
2
Repeater
{
model
:
QGroundControl
.
loggingCategories
()
QGCCheckBox
{
text
:
modelData
checked
:
QGroundControl
.
categoryLoggingOn
(
modelData
)
onClicked
:
{
QGroundControl
.
setCategoryLoggingOn
(
modelData
,
checked
)
QGroundControl
.
updateLoggingFilterRules
()
}
}
}
}
}
}
}
}
// QGCViewDialog
}
// Component - filtersDialogComponent
QGCViewPanel
{
id
:
panel
anchors.fill
:
parent
Component
{
id
:
delegateItem
Rectangle
{
color
:
index
%
2
==
0
?
qgcPal
.
window
:
qgcPal
.
windowShade
height
:
Math
.
round
(
ScreenTools
.
defaultFontPixelHeight
*
0.5
+
field
.
height
)
width
:
listview
.
width
Text
{
id
:
field
text
:
display
color
:
qgcPal
.
text
width
:
parent
.
width
wrapMode
:
Text
.
Wrap
font.family
:
ScreenTools
.
normalFontFamily
anchors.verticalCenter
:
parent
.
verticalCenter
id
:
logwindow
anchors.fill
:
parent
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
color
:
qgcPal
.
window
Connections
{
target
:
debugMessageModel
onDataChanged
:
{
// Keep the view in sync if the button is checked
if
(
loaded
)
{
if
(
followTail
.
checked
)
{
listview
.
positionViewAtEnd
();
}
}
}
}
}
}
ListView
{
Component.onCompleted
:
{
loaded
=
true
}
anchors.top
:
parent
.
top
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.bottom
:
followTail
.
top
anchors.bottomMargin
:
ScreenTools
.
defaultFontPixelWidth
clip
:
true
id
:
listview
model
:
debugMessageModel
delegate
:
delegateItem
}
FileDialog
{
id
:
writeDialog
folder
:
shortcuts
.
home
nameFilters
:
[
"
Log files (*.txt)
"
,
"
All Files (*)
"
]
selectExisting
:
false
title
:
"
Select log save file
"
onAccepted
:
{
debugMessageModel
.
writeMessages
(
fileUrl
);
visible
=
false
;
}
onRejected
:
visible
=
false
}
Connections
{
target
:
debugMessageModel
onWriteStarted
:
writeButton
.
enabled
=
false
;
onWriteFinished
:
writeButton
.
enabled
=
true
;
}
QGCButton
{
id
:
writeButton
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
onClicked
:
writeDialog
.
visible
=
true
text
:
"
Save App Log
"
}
BusyIndicator
{
id
:
writeBusy
anchors.bottom
:
writeButton
.
bottom
anchors.left
:
writeButton
.
right
height
:
writeButton
.
height
visible
:
!
writeButton
.
enabled
}
QGCButton
{
id
:
followTail
anchors.bottom
:
parent
.
bottom
anchors.right
:
parent
.
right
text
:
"
Show Latest
"
checkable
:
true
checked
:
true
onCheckedChanged
:
{
if
(
checked
&&
loaded
)
{
listview
.
positionViewAtEnd
();
Component
{
id
:
delegateItem
Rectangle
{
color
:
index
%
2
==
0
?
qgcPal
.
window
:
qgcPal
.
windowShade
height
:
Math
.
round
(
ScreenTools
.
defaultFontPixelHeight
*
0.5
+
field
.
height
)
width
:
listview
.
width
Text
{
id
:
field
text
:
display
color
:
qgcPal
.
text
width
:
parent
.
width
wrapMode
:
Text
.
Wrap
font.family
:
ScreenTools
.
normalFontFamily
anchors.verticalCenter
:
parent
.
verticalCenter
}
}
}
ListView
{
Component.onCompleted
:
{
loaded
=
true
}
anchors.top
:
parent
.
top
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.bottom
:
followTail
.
top
anchors.bottomMargin
:
ScreenTools
.
defaultFontPixelWidth
clip
:
true
id
:
listview
model
:
debugMessageModel
delegate
:
delegateItem
}
FileDialog
{
id
:
writeDialog
folder
:
shortcuts
.
home
nameFilters
:
[
qsTr
(
"
Log files (*.txt)
"
),
qsTr
(
"
All Files (*)
"
)]
selectExisting
:
false
title
:
qsTr
(
"
Select log save file
"
)
onAccepted
:
{
debugMessageModel
.
writeMessages
(
fileUrl
);
visible
=
false
;
}
onRejected
:
visible
=
false
}
Connections
{
target
:
debugMessageModel
onWriteStarted
:
writeButton
.
enabled
=
false
;
onWriteFinished
:
writeButton
.
enabled
=
true
;
}
QGCButton
{
id
:
writeButton
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
onClicked
:
writeDialog
.
visible
=
true
text
:
qsTr
(
"
Save App Log
"
)
}
BusyIndicator
{
id
:
writeBusy
anchors.bottom
:
writeButton
.
bottom
anchors.left
:
writeButton
.
right
height
:
writeButton
.
height
visible
:
!
writeButton
.
enabled
}
QGCButton
{
id
:
followTail
anchors.right
:
filterButton
.
left
anchors.rightMargin
:
ScreenTools
.
defaultFontPixelWidth
anchors.bottom
:
parent
.
bottom
text
:
qsTr
(
"
Show Latest
"
)
checkable
:
true
checked
:
true
onCheckedChanged
:
{
if
(
checked
&&
loaded
)
{
listview
.
positionViewAtEnd
();
}
}
}
QGCButton
{
id
:
filterButton
anchors.bottom
:
parent
.
bottom
anchors.right
:
parent
.
right
text
:
qsTr
(
"
Set logging
"
)
onClicked
:
showDialog
(
filtersDialogComponent
,
qsTr
(
"
Turn on logging categories
"
),
qgcView
.
showDialogDefaultWidth
,
StandardButton
.
Close
)
}
}
}
}
}
// QGCViewPanel
}
// QGCView
This diff is collapsed.
Click to expand it.
src/QmlControls/QGroundControlQmlGlobal.h
View file @
4c3c6da4
...
...
@@ -36,6 +36,7 @@
#include "SettingsFact.h"
#include "FactMetaData.h"
#include "SimulatedPosition.h"
#include "QGCLoggingCategory.h"
#ifdef QT_DEBUG
#include "MockLink.h"
...
...
@@ -133,6 +134,18 @@ public:
QString
appSettingsDistanceUnitsString
(
void
)
const
{
return
FactMetaData
::
appSettingsDistanceUnitsString
();
}
/// Returns the list of available logging category names.
Q_INVOKABLE
QStringList
loggingCategories
(
void
)
const
{
return
QGCLoggingCategoryRegister
::
instance
()
->
registeredCategories
();
}
/// Turns on/off logging for the specified category. State is saved in app settings.
Q_INVOKABLE
void
setCategoryLoggingOn
(
const
QString
&
category
,
bool
enable
)
{
QGCLoggingCategoryRegister
::
instance
()
->
setCategoryLoggingOn
(
category
,
enable
);
};
/// Returns true if logging is turned on for the specified category.
Q_INVOKABLE
bool
categoryLoggingOn
(
const
QString
&
category
)
{
return
QGCLoggingCategoryRegister
::
instance
()
->
categoryLoggingOn
(
category
);
};
/// Updates the logging filter rules after settings have changed
Q_INVOKABLE
void
updateLoggingFilterRules
(
void
)
{
QGCLoggingCategoryRegister
::
instance
()
->
setFilterRulesFromSettings
(
QString
());
}
// Property accesors
FlightMapSettings
*
flightMapSettings
()
{
return
_flightMapSettings
;
}
...
...
This diff is collapsed.
Click to expand it.
src/ui/MainWindowLeftPanel.qml
View file @
4c3c6da4
...
...
@@ -302,34 +302,5 @@ Item {
id
:
__rightPanel
anchors.fill
:
parent
}
//-- Dismiss it all
Item
{
id
:
closeButton
width
:
__closeButtonSize
height
:
__closeButtonSize
anchors.right
:
parent
.
right
anchors.top
:
parent
.
top
anchors.margins
:
ScreenTools
.
defaultFontPixelHeight
*
0.5
QGCColoredImage
{
source
:
"
/res/XDelete.svg
"
mipmap
:
true
fillMode
:
Image
.
PreserveAspectFit
color
:
qgcPal
.
text
width
:
parent
.
width
*
0.75
height
:
parent
.
height
*
0.75
sourceSize.height
:
height
anchors.centerIn
:
parent
}
MouseArea
{
anchors.fill
:
parent
onClicked
:
{
if
(
!
__animateShowDialog
.
running
)
{
__rightPanel
.
source
=
""
mainWindow
.
hideLeftMenu
()
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
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