LogViewer.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package ArmarX::
17* @author Mirko Waechter ( mirko.waechter at kit dot edu)
18* @date 2012
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
25#include <atomic>
26#include <mutex>
27
28#include <QPointer>
29#include <QToolBar>
30
32
33#include <ArmarXGui/gui-plugins/LoggingPlugin/ui_LogViewer.h>
35
36#include "LogMarkerRegistry.h"
37#include "LogTable.h"
38
39class QTimer;
40
41namespace armarx
42{
43
44 class LogTableModel;
45
46 /*!
47 \page ArmarXGui-GuiPlugins-LogViewer LogViewer
48 \brief The log viewer allows you to filter and view log messages from
49 all running ArmarX applications.
50 \image html LogViewer.png
51 ArmarXGui Documentation \ref LogViewer
52 \see LoggingPlugin
53 */
54 /*!
55 \class LogViewer
56 \see LoggingPlugin
57 */
60 public Log
61 {
62 Q_OBJECT
63 public:
64 LogViewer();
65 ~LogViewer() override;
66 //inherited from ArmarXMdiWidget
67
68 void loadSettings(QSettings* settings) override;
69 void saveSettings(QSettings* settings) override;
70
71 static QString
73 {
74 return "Meta.LogViewer";
75 }
76
77 static QIcon
79 {
80 return QIcon("://icons/papyrus.svg");
81 }
82
83 static QIcon
85 {
86 return QIcon("://icons/papyrus.svg");
87 }
88
89 QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
90
91 // inherited from Component
92 void onInitComponent() override;
93 void onConnectComponent() override;
94 void onExitComponent() override;
95
96 // inherited from Log
97 void write(const std::string& who,
98 Ice::Long time,
99 const std::string& tag,
100 MessageType severity,
101 const std::string& message,
102 const std::string& file,
103 Ice::Int line,
104 const std::string& function,
105 const Ice::Current& = Ice::emptyCurrent);
106 void writeLog(const LogMessage& msg, const Ice::Current& = Ice::emptyCurrent) override;
107
108
109 LogTable* addEmptyFilter();
110 LogTable* addFilter(QString filterId,
111 QString filterName,
112 QString loggingGroup,
113 QString componentFilter,
114 QString tagFilter,
115 MessageType minimumVerbosity,
116 QString messageFilter,
117 QString fileFilter,
118 QString functionFilter);
119 //! This function checks, if there are new components in the log and if so, it creates new filters for these components
120 bool checkAndAddNewFilter(const QString& loggingGroupName, const QString& componentName);
121
122
123 public slots:
124 void performLiveFilter(QString searchStr, int startRow = 0);
125 void performLiveSearch(QString searchStr);
126 void clearSelectedLog();
127 void clearAllLogs();
128 void pauseLogging(bool pause = false);
129 void addFilter();
130 void editFilter(QTreeWidgetItem* item, int column);
131 void removeSelectedFilter();
132 void removeFilter(QTreeWidgetItem* item);
133 void filterSelectionChanged(QTreeWidgetItem* item, QTreeWidgetItem* previous);
134 void insertPendingEntries();
135 void searchTypeChanged(int index);
136 void selectNextSearchResult();
137 void selectPreviousSearchResult();
138 void updateFilterList();
139 void OpenConfigureDialog();
140 //! Rebuild the Labels panel from the pin registry.
141 void refreshLabelsPanel();
142 //! Focus the clicked label's line in the currently shown message view.
143 void labelClicked(QListWidgetItem* item);
144 //! Recolor / remove menu for the Labels panel.
145 void showLabelsContextMenu(const QPoint& pos);
146 //! Remove the pin currently selected in the Labels panel.
147 void removeSelectedLabel();
148 signals:
151
152 protected:
153 bool onClose() override;
154
155 Ui_LogViewer ui;
157
158 private:
159 QString loggingGroupNameToFilterName(const QString& loggingGroupName) const;
160
161 //! Common wiring for every freshly created LogTable: share the pin registry with its
162 //! model (so pins created anywhere show up in this filter too).
163 void setupLogTable(LogTable* logTable);
164
165 //! Drop pins whose source line is no longer a native row in any filter (i.e. it has
166 //! been cleared or trimmed everywhere), so pins stay bound to the live log.
167 void expireOrphanedMarkers();
168
169 //! Session-only registry of pinned ("labeled") log lines, shared with every model.
170 LogMarkerRegistry markerRegistry;
171
172 // Accessed from Ice dispatch threads (writeLog) as well as the GUI thread.
173 std::atomic<bool> loggingPaused;
174 // Mirror of ui.cbVerbosityLevel->currentIndex(), kept in sync from the GUI thread
175 // so the Ice-thread writeLog does not have to touch the (GUI-only) QComboBox.
176 std::atomic<int> verbosityLevel;
177 LogPrx logProxy;
178 IceUtil::Time lastLiveSearchEditChangeTime;
179 std::map<QString, LogTable*> filterMap;
180
181 std::vector<LogMessage> pendingEntries;
182
183 mutable std::mutex pendingEntriesMutex;
184 QTimer* pendingEntriesTimer;
185 QToolBar* customToolbar;
186 };
187} // namespace armarx
uint8_t index
#define ARMARXCOMPONENT_IMPORT_EXPORT
Shared, session-only store of pinned ("labeled") log lines.
LogTable * logTable
Definition LogViewer.h:156
void componentConnected()
bool onClose() override
If you overwrite this method, make sure to call this implementation at the end of your implementation...
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
void updateFilterListSignal()
Ui_LogViewer ui
Definition LogViewer.h:155
static QIcon GetWidgetCategoryIcon()
Definition LogViewer.h:84
static QString GetWidgetName()
Definition LogViewer.h:72
static QIcon GetWidgetIcon()
Definition LogViewer.h:78
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::Log > LogPrx
Definition LogSender.h:58