Opensim Control Panel BRIGADOON-0013
This program provides a control panel for an Open Simulator Instance
Loading...
Searching...
No Matches
Logger Class Reference

#include <logger.h>

Inheritance diagram for Logger:
[legend]
Collaboration diagram for Logger:
[legend]

Public Slots

void RemoteLog (REMOTE_LOG_ENTRY LogEntry)
 Receiver a Log Entry via a Public Slot.

Signals

void CountChanged (int counter)
 A Signal to flag a change in the Number of Log Lines.

Public Member Functions

 Logger (Ui::MainWindow *UI_Window)
 The Log Constructor.
 ~Logger ()
 The Log Destructor.
void Add (LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString LogMessage)
 Add a Line to Log (in it matches the current settings)
void SaveSeverityMask (int SeverityMask)
 Save the Log Severity Mask.
void SaveModeMask (int ModeMask)
 Save the Log Mode Mask.
void SetMaxLines (int MaxLogLines)
 Set the maximum number of lines the log will retain.

Private Slots

void UpdateMaxLogLines (int Value)
void LogSelectItem (QListWidgetItem *Item)
void SaveLog (void)
 Save the Log Lines to a File.
void ClearLog (void)
 Clear the lines from the Log.
void LogItemsUnhide (void)
void ReadSeverityMask (bool Unused)
 Set the Severity Mask, based on window buttons.
void ReadModeMask (bool Unused)
 Set the Mode Mask, based on window buttons.
void LogModeAll (void)
 Turn All Modes On.
void LogModeNone (void)
 Turn All Modes Off.
void LogSeverityAll (void)
 Turn All Severities On.
void LogSeverityNone (void)
 Turn All Severities Off.

Private Member Functions

void SaveLogSettings (void)
void LoadLogSettings (void)
void PresetLogSeverity (bool OnOff)
 Preset all of the Log Severity Levels.
void PresetLogMode (bool OnOff)
 Preset all of the Modes.

Private Attributes

Ui::MainWindow * ui
 Pointer the Main Program Window.
QStringList severity_name_list
 This list holds the names of the valid severity levels.
QStringList mode_name_list
 This list holds the names of the valid modes.
QStringList icon_name_list
 This list holds the names of the severity level icons.
int current_severity_mask
 Mask holding currently active severity levels.
int current_mode_mask
 Mask holding currently active modes.
int maximum_log_lines
 The maximum number of lines the log will retain.

Detailed Description

Definition at line 74 of file logger.h.

Constructor & Destructor Documentation

◆ Logger()

Logger::Logger ( Ui::MainWindow * UI_Window)
explicit

The Log Constructor.

Parameters
UI_WindowThe Program's main Window

Definition at line 3 of file logger.cpp.

4{
5 // Keep a Pointer to the Main Window
6 ui = UI_Window;
7
8 // Register Custom Meta Types for the "QObject::connect" Definitions
9 qRegisterMetaType<REMOTE_LOG_ENTRY>("REMOTE_LOG_ENTRY");
10
11 // Setup Severity Names
12 severity_name_list << "EMERGENCY" << "ALERT" << "CRITICAL" << "ERROR"
13 << "WARNING" << "NOTICE" << "INFO" << "DEBUG";
14
15 // Setup Severity Icon List
16 icon_name_list << ":/Resources/Emergency.png" << ":/Resources/Alert.png" << ":/Resources/Critical.png" << ":/Resources/Error.png"
17 << ":/Resources/Warning.png" << ":/Resources/Notice.png" << ":/Resources/Info.png" << ":/Resources/Debug.png";
18
19 // Setup Mode Names
20 mode_name_list << "SIG_PROC" << "QT" << "GENERAL" << "THREAD" << "CONFIG" << "TIMING" << "SECURITY" << "GRAPHICS"
21 << "MEMORY" << "MATHS" << "FILE" << "NETWORK" << "OPERATOR" << "DATABASE" << "EXCEPTION" << "SENSOR";
22
23 current_severity_mask = ( 1 << (LOG_DEBUG + 1 ) ) - 1;
24 current_mode_mask = ( 1 << (MODE_SENSOR + 1 ) ) - 1;
26
28}
Ui::MainWindow * ui
Pointer the Main Program Window.
Definition logger.h:183
int maximum_log_lines
The maximum number of lines the log will retain.
Definition logger.h:226
int current_severity_mask
Mask holding currently active severity levels.
Definition logger.h:212
int current_mode_mask
Mask holding currently active modes.
Definition logger.h:220
void LoadLogSettings(void)
Definition logger.cpp:166
QStringList severity_name_list
This list holds the names of the valid severity levels.
Definition logger.h:189
QStringList mode_name_list
This list holds the names of the valid modes.
Definition logger.h:195
QStringList icon_name_list
This list holds the names of the severity level icons.
Definition logger.h:204
#define DEFAULT_MAXIMUM_LOG_LINES
The maximum number of log lines kept.
Definition logger.h:72
@ LOG_DEBUG
Definition logger.h:56
@ MODE_SENSOR
Definition logger.h:37

References current_mode_mask, current_severity_mask, DEFAULT_MAXIMUM_LOG_LINES, icon_name_list, LoadLogSettings(), LOG_DEBUG, maximum_log_lines, mode_name_list, MODE_SENSOR, severity_name_list, and ui.

Here is the call graph for this function:

◆ ~Logger()

Logger::~Logger ( )

The Log Destructor.

Definition at line 30 of file logger.cpp.

31{
32 if (ui->LogSavOnExit->isChecked()) SaveLogSettings();
33 severity_name_list.clear();
34 icon_name_list.clear();
35 mode_name_list.clear();
36}
void SaveLogSettings(void)
Definition logger.cpp:514

References icon_name_list, mode_name_list, SaveLogSettings(), severity_name_list, and ui.

Here is the call graph for this function:

Member Function Documentation

◆ Add()

void Logger::Add ( LOGGING_SEVERITY Severity,
LOGGING_MODE Mode,
const QString LogMessage )

Add a Line to Log (in it matches the current settings)

Parameters
SeverityThe Severtiry Level of the event being reported
ModeThe Logging Mode (event type) of the event being reported
LogMessageText message describing the event

If the Severity and Mode match the enable severity and mode in the log, this will be added to the log with a time stamp. If it does not meet these criteria, the line will be quietly ignored.

Definition at line 136 of file logger.cpp.

137{
138 // Check if the Log message will be added to the Log record based onthe Severity and Mode
139 if ( ( ( current_severity_mask & (1 << Severity ) ) != 0 ) && ( ( current_mode_mask & (1 << Mode ) ) != 0 ) )
140 {
141 // Get the name of the severity icon, the name of the severity level, the name of the mode and the datetime of the entry
142 // and place it into a ListWidget Item for inclusion in the Log
143 QString icon_name = icon_name_list.at( Severity );
144 QString severity_name = severity_name_list.at( Severity );
145 QString mode_name = mode_name_list.at( Mode );
146 QString entry_date = QDateTime::currentDateTime().toString();
147 QString log_entry = "<" + entry_date + ">[" + severity_name + " : " + mode_name + " ] " +LogMessage;
148 QListWidgetItem *item = new QListWidgetItem;
149
150 // Put the Icon and Text into the Log Item and add to the Log
151 item->setIcon( QIcon( icon_name ) );
152 item->setText( log_entry );
153 ui->LogView->addItem( item );
154
155 // Remove Oldest Item While the Line Count Is Being Exceeded
156 while ( ui->LogView->count() > maximum_log_lines )
157 {
158 ui->LogView->takeItem( 0 );
159 }
160 }
161
162 // Flag the number of Entries in the Log to the Number of Log Lines Display
163 emit CountChanged( ui->LogView->count() );
164}
void CountChanged(int counter)
A Signal to flag a change in the Number of Log Lines.

References CountChanged(), current_mode_mask, current_severity_mask, icon_name_list, maximum_log_lines, mode_name_list, severity_name_list, and ui.

Referenced by PresetLogMode(), PresetLogSeverity(), and RemoteLog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearLog

void Logger::ClearLog ( void )
privateslot

Clear the lines from the Log.

This routine will delete all of the lines that the log current holds.

Definition at line 53 of file logger.cpp.

54{
55 ui->LogView->clear();
56 emit CountChanged( ui->LogView->count() );
57}

References CountChanged(), and ui.

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CountChanged

void Logger::CountChanged ( int counter)
signal

A Signal to flag a change in the Number of Log Lines.

Parameters
counterThe new Number of Log Lines

When the number of log lones is increased (or decreased), this signal is fired so that the number of log lines display can be updated.

Referenced by Add(), ClearLog(), LoadLogSettings(), and SaveLog().

Here is the caller graph for this function:

◆ LoadLogSettings()

void Logger::LoadLogSettings ( void )
private

Definition at line 166 of file logger.cpp.

167{
168 QSettings settings;
169
170 ui->MaxLogLines->setValue( settings.value( "Log_Setup/Allowed_lines", 500 ).toInt() );
171 ui->MaxLogLines->setMinimum( settings.value( "Log_Setup/Minimum_lines", 20 ).toInt() );
172 ui->MaxLogLines->setMaximum( settings.value( "Log_Setup/Maximum_lines", 20000 ).toInt() );
173
174 // Set the Connections
175 QObject::connect( ui->ModeSelectAll, SIGNAL( pressed( void ) ), this, SLOT( LogModeAll( void ) ) );
176 QObject::connect( ui->ModeClearAll, SIGNAL( pressed( void ) ), this, SLOT( LogModeNone( void ) ) );
177 QObject::connect( ui->SeveritySelectAll, SIGNAL( pressed( void ) ), this, SLOT( LogSeverityAll( void ) ) );
178 QObject::connect( ui->SeverityClearAll, SIGNAL( pressed( void ) ), this, SLOT( LogSeverityNone( void ) ) );
179 QObject::connect( ui->SaveLog, SIGNAL( pressed( void ) ), this, SLOT( SaveLog( void ) ) );
180 QObject::connect( ui->ClearLog, SIGNAL( pressed( void ) ), this, SLOT( ClearLog( void ) ) );
181 QObject::connect( ui->EmergencySelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
182 QObject::connect( ui->AlertSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
183 QObject::connect( ui->CriticalSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
184 QObject::connect( ui->ErrorSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
185 QObject::connect( ui->WarningSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
186 QObject::connect( ui->NoticeSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
187 QObject::connect( ui->InfoSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
188 QObject::connect( ui->DebugSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadSeverityMask( bool ) ) );
189 QObject::connect( ui->SigProcessSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
190 QObject::connect( ui->QtSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
191 QObject::connect( ui->GeneralSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
192 QObject::connect( ui->ThreadSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
193 QObject::connect( ui->ConfigSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
194 QObject::connect( ui->TimingSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
195 QObject::connect( ui->SecuritySelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
196 QObject::connect( ui->GraphicsSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
197 QObject::connect( ui->MemorySelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
198 QObject::connect( ui->MathsSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
199 QObject::connect( ui->FileOpsSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
200 QObject::connect( ui->NetworkCommsSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
201 QObject::connect( ui->OperatorSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
202 QObject::connect( ui->DatabaseSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
203 QObject::connect( ui->ExceptionsSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
204 QObject::connect( ui->SensorsSelect, SIGNAL( clicked( bool ) ), this, SLOT( ReadModeMask( bool ) ) );
205 QObject::connect( this, SIGNAL( CountChanged( int ) ), ui->LogLineCounter, SLOT( display( int ) ) );
206 QObject::connect( ui->LogView, SIGNAL( itemClicked( QListWidgetItem * ) ), this, SLOT( LogSelectItem( QListWidgetItem * ) ) );
207 QObject::connect( ui->AllUnhideLog, SIGNAL( pressed( void) ), this, SLOT( LogItemsUnhide( void ) ) );
208 QObject::connect( ui->MaxLogLines, SIGNAL( valueChanged( int) ), this, SLOT( UpdateMaxLogLines( int ) ) );
209
210 ui->EmergencySelect->setChecked( settings.value( "Log_Severity/Emergency", true ).toBool() );
211 ui->AlertSelect->setChecked( settings.value( "Log_Severity/Alert", true ).toBool() );
212 ui->CriticalSelect->setChecked( settings.value( "Log_Severity/Critical", true ).toBool() );
213 ui->ErrorSelect->setChecked( settings.value( "Log_Severity/Error", true ).toBool() );
214 ui->WarningSelect->setChecked( settings.value( "Log_Severity/Warning", true ).toBool() );
215 ui->NoticeSelect->setChecked( settings.value( "Log_Severity/Notice", true ).toBool() );
216 ui->InfoSelect->setChecked( settings.value( "Log_Severity/Info", true ).toBool() );
217 ui->DebugSelect->setChecked( settings.value( "Log_Severity/Debug", true ).toBool() );
218 ReadSeverityMask( true );
219
220 // Load the Mode Settings
221 ui->SigProcessSelect->setChecked( settings.value( "Log_Mode/SigProc", true ).toBool() );
222 ui->QtSelect->setChecked( settings.value( "Log_Mode/Qt", true ).toBool() );
223 ui->GeneralSelect->setChecked( settings.value( "Log_Mode/General", true ).toBool() );
224 ui->ThreadSelect->setChecked( settings.value( "Log_Mode/Thread", true ).toBool() );
225 ui->ConfigSelect->setChecked( settings.value( "Log_Mode/Configuration", true ).toBool() );
226 ui->TimingSelect->setChecked( settings.value( "Log_Mode/Timing", true ).toBool() );
227 ui->SecuritySelect->setChecked( settings.value( "Log_Mode/Security", true ).toBool() );
228 ui->GraphicsSelect->setChecked( settings.value( "Log_Mode/Graphics", true ).toBool() );
229 ui->MemorySelect->setChecked( settings.value( "Log_Mode/Memory", true ).toBool() );
230 ui->MathsSelect->setChecked( settings.value( "Log_Mode/Maths", true ).toBool() );
231 ui->FileOpsSelect->setChecked( settings.value( "Log_Mode/File", true ).toBool() );
232 ui->NetworkCommsSelect->setChecked( settings.value( "Log_Mode/Network", true ).toBool() );
233 ui->OperatorSelect->setChecked( settings.value( "Log_Mode/Operator", true ).toBool() );
234 ui->DatabaseSelect->setChecked( settings.value( "Log_Mode/Database", true ).toBool() );
235 ui->ExceptionsSelect->setChecked( settings.value( "Log_Mode/Exception", true ).toBool() );
236 ui->SensorsSelect->setChecked( settings.value( "Log_Mode/Sensors", true ).toBool() );
237 ReadModeMask( true );
238}
void UpdateMaxLogLines(int Value)
Definition logger.cpp:509
void ClearLog(void)
Clear the lines from the Log.
Definition logger.cpp:53
void LogModeNone(void)
Turn All Modes Off.
Definition logger.cpp:482
void ReadSeverityMask(bool Unused)
Set the Severity Mask, based on window buttons.
Definition logger.cpp:241
void LogModeAll(void)
Turn All Modes On.
Definition logger.cpp:477
void ReadModeMask(bool Unused)
Set the Mode Mask, based on window buttons.
Definition logger.cpp:319
void LogItemsUnhide(void)
Definition logger.cpp:497
void LogSeverityNone(void)
Turn All Severities Off.
Definition logger.cpp:492
void LogSeverityAll(void)
Turn All Severities On.
Definition logger.cpp:487
void SaveLog(void)
Save the Log Lines to a File.
Definition logger.cpp:59
void LogSelectItem(QListWidgetItem *Item)
Definition logger.cpp:468

References ClearLog(), CountChanged(), LogItemsUnhide(), LogModeAll(), LogModeNone(), LogSelectItem(), LogSeverityAll(), LogSeverityNone(), ReadModeMask(), ReadSeverityMask(), SaveLog(), ui, and UpdateMaxLogLines().

Referenced by Logger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogItemsUnhide

void Logger::LogItemsUnhide ( void )
privateslot

Definition at line 497 of file logger.cpp.

498{
499 for ( int row = 0; row < ui->LogView->count(); ++row )
500 {
501 QListWidgetItem *item = ui->LogView->item( row );
502 if ( item != nullptr )
503 {
504 item->setHidden( false );
505 }
506 }
507}

References ui.

Referenced by LoadLogSettings().

Here is the caller graph for this function:

◆ LogModeAll

void Logger::LogModeAll ( void )
privateslot

Turn All Modes On.

This routine turns all Modes on to make it easy to set the active modes without checking a lot of check boxes.

Definition at line 477 of file logger.cpp.

478{
479 PresetLogMode( true );
480}
void PresetLogMode(bool OnOff)
Preset all of the Modes.
Definition logger.cpp:106

References PresetLogMode().

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogModeNone

void Logger::LogModeNone ( void )
privateslot

Turn All Modes Off.

This routine turns all Modes off to make it easy to reset the active modes without checking a lot of check boxes.

Definition at line 482 of file logger.cpp.

483{
484 PresetLogMode( false );
485}

References PresetLogMode().

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogSelectItem

void Logger::LogSelectItem ( QListWidgetItem * Item)
privateslot

Definition at line 468 of file logger.cpp.

469{
470 // If Hidden Selected, Hide the Log Line
471 if ( ui->HideSelectedLog->isChecked() )
472 {
473 Item->setHidden( true );
474 }
475}

References ui.

Referenced by LoadLogSettings().

Here is the caller graph for this function:

◆ LogSeverityAll

void Logger::LogSeverityAll ( void )
privateslot

Turn All Severities On.

This routine turns all Severities on to make it easy to set the active Severities without checking a lot of check boxes.

Definition at line 487 of file logger.cpp.

488{
489 PresetLogSeverity( true );
490}
void PresetLogSeverity(bool OnOff)
Preset all of the Log Severity Levels.
Definition logger.cpp:84

References PresetLogSeverity().

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogSeverityNone

void Logger::LogSeverityNone ( void )
privateslot

Turn All Severities Off.

This routine turns all Severities off to make it easy to reset the active Severities without checking a lot of check boxes.

Definition at line 492 of file logger.cpp.

493{
494 PresetLogSeverity( false );
495}

References PresetLogSeverity().

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PresetLogMode()

void Logger::PresetLogMode ( bool OnOff)
private

Preset all of the Modes.

Parameters
OnOff

If OnOff is On, all modes will be set, otherwise, all will be reset.

Definition at line 106 of file logger.cpp.

107{
108 ui->SigProcessSelect->setChecked( OnOff );
109 ui->QtSelect->setChecked( OnOff );
110 ui->GeneralSelect->setChecked( OnOff );
111 ui->ThreadSelect->setChecked( OnOff );
112 ui->ConfigSelect->setChecked( OnOff );
113 ui->TimingSelect->setChecked( OnOff );
114 ui->SecuritySelect->setChecked( OnOff );
115 ui->GraphicsSelect->setChecked( OnOff );
116 ui->MemorySelect->setChecked( OnOff );
117 ui->MathsSelect->setChecked( OnOff );
118 ui->FileOpsSelect ->setChecked( OnOff );
119 ui->NetworkCommsSelect->setChecked( OnOff );
120 ui->OperatorSelect->setChecked( OnOff );
121 ui->DatabaseSelect->setChecked( OnOff );
122 ui->ExceptionsSelect->setChecked( OnOff );
123 ui->SensorsSelect->setChecked( OnOff );
124 SaveModeMask( true );
125
126 if ( OnOff )
127 {
128 Add( LOG_DEBUG, MODE_OPERATOR, "All Mode Check Boxes Enabled" );
129 }
130 else
131 {
132 Add( LOG_DEBUG, MODE_OPERATOR, "All Mode Check Boxes Disabled" );
133 }
134}
void SaveModeMask(int ModeMask)
Save the Log Mode Mask.
Definition logger.cpp:43
void Add(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString LogMessage)
Add a Line to Log (in it matches the current settings)
Definition logger.cpp:136
@ MODE_OPERATOR
Definition logger.h:34

References Add(), LOG_DEBUG, MODE_OPERATOR, SaveModeMask(), and ui.

Referenced by LogModeAll(), and LogModeNone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PresetLogSeverity()

void Logger::PresetLogSeverity ( bool OnOff)
private

Preset all of the Log Severity Levels.

Parameters
OnOff

If OnOff is On, all severity levels will be set, otherwise, all will be reset.

Definition at line 84 of file logger.cpp.

85{
86 ui->EmergencySelect->setChecked( OnOff );
87 ui->AlertSelect->setChecked( OnOff );
88 ui->DebugSelect->setChecked( OnOff );
89 ui->ErrorSelect->setChecked( OnOff );
90 ui->NoticeSelect->setChecked( OnOff );
91 ui->WarningSelect->setChecked( OnOff );
92 ui->CriticalSelect->setChecked( OnOff );
93 ui->InfoSelect->setChecked( OnOff );
94 SaveSeverityMask( true );
95
96 if ( OnOff )
97 {
98 Add( LOG_DEBUG, MODE_OPERATOR, "All Severity Check Boxes Enabled" );
99 }
100 else
101 {
102 Add( LOG_DEBUG, MODE_OPERATOR, "All Severity Check Boxes Disabled" );
103 }
104}
void SaveSeverityMask(int SeverityMask)
Save the Log Severity Mask.
Definition logger.cpp:38

References Add(), LOG_DEBUG, MODE_OPERATOR, SaveSeverityMask(), and ui.

Referenced by LogSeverityAll(), and LogSeverityNone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadModeMask

void Logger::ReadModeMask ( bool Unused)
privateslot

Set the Mode Mask, based on window buttons.

Parameters
Unusedparameter for Signal, Slot parameter matching

This routine will look at the state of the Mode buttons associated with the logger and sets the bits in the serverity mask corresponding to the set buttons.

Definition at line 319 of file logger.cpp.

320{
321 int mode_mask = 0;
322
323 if ( ui->SigProcessSelect->isChecked() )
324 {
325 mode_mask |= 1 << MODE_SIG_PROC;
326 }
327 else
328 {
329 mode_mask &= ~(1 << MODE_SIG_PROC);
330 }
331 if ( ui->QtSelect->isChecked() )
332 {
333 mode_mask |= 1 << MODE_QT;
334 }
335 else
336 {
337 mode_mask &= ~(1 << MODE_QT);
338 }
339
340 if ( ui->GeneralSelect->isChecked() )
341 {
342 mode_mask |= 1 << MODE_GENERAL;
343 }
344 else
345 {
346 mode_mask &= ~(1 << MODE_GENERAL);
347 }
348
349 if ( ui->ThreadSelect->isChecked() )
350 {
351 mode_mask |= 1 << MODE_THREAD;
352 }
353 else
354 {
355 mode_mask &= ~(1 << MODE_THREAD);
356 }
357
358 if ( ui->ConfigSelect->isChecked() )
359 {
360 mode_mask |= 1 << MODE_CONFIG;
361 }
362 else
363 {
364 mode_mask &= ~(1 << MODE_CONFIG);
365 }
366
367 if ( ui->TimingSelect->isChecked() )
368 {
369 mode_mask |= 1 << MODE_TIMING;
370 }
371 else
372 {
373 mode_mask &= ~(1 << MODE_TIMING);
374 }
375
376 if ( ui->SecuritySelect->isChecked() )
377 {
378 mode_mask |= 1 << MODE_SECURITY;
379 }
380 else
381 {
382 mode_mask &= ~(1 << MODE_SECURITY);
383 }
384
385 if ( ui->GraphicsSelect->isChecked() )
386 {
387 mode_mask |= 1 << MODE_GRAPHICS;
388 }
389 else
390 {
391 mode_mask &= ~(1 << MODE_GRAPHICS);
392 }
393
394 if ( ui->MemorySelect->isChecked() )
395 {
396 mode_mask |= 1 << MODE_MEMORY;
397 }
398 else
399 {
400 mode_mask &= ~(1 << MODE_MEMORY);
401 }
402
403 if ( ui->MathsSelect->isChecked() )
404 {
405 mode_mask |= 1 << MODE_MATHS;
406 }
407 else
408 {
409 mode_mask &= ~(1 << MODE_MATHS);
410 }
411
412 if ( ui->FileOpsSelect->isChecked() )
413 {
414 mode_mask |= 1 << MODE_FILE;
415 }
416 else
417 {
418 mode_mask &= ~(1 << MODE_FILE);
419 }
420
421 if ( ui->NetworkCommsSelect->isChecked() )
422 {
423 mode_mask |= 1 << MODE_NETWORK;
424 }
425 else
426 {
427 mode_mask &= ~(1 << MODE_NETWORK);
428 }
429
430 if ( ui->OperatorSelect->isChecked() )
431 {
432 mode_mask |= 1 << MODE_OPERATOR;
433 }
434 else
435 {
436 mode_mask &= ~(1 << MODE_OPERATOR);
437 }
438
439 if ( ui->DatabaseSelect->isChecked() )
440 {
441 mode_mask |= 1 << MODE_DATABASE;
442 }
443 else
444 {
445 mode_mask &= ~(1 << MODE_DATABASE);
446 }
447
448 if ( ui->ExceptionsSelect->isChecked() )
449 {
450 mode_mask |= 1 << MODE_EXCEPTION;
451 }
452 else
453 {
454 mode_mask &= ~(1 << MODE_EXCEPTION);
455 }
456
457 if ( ui->SensorsSelect->isChecked() )
458 {
459 mode_mask |= 1 << MODE_SENSOR;
460 }
461 else
462 {
463 mode_mask &= ~(1 << MODE_SENSOR);
464 }
465 SaveModeMask( mode_mask );
466}
@ MODE_QT
Definition logger.h:23
@ MODE_FILE
Definition logger.h:32
@ MODE_SECURITY
Definition logger.h:28
@ MODE_TIMING
Definition logger.h:27
@ MODE_GRAPHICS
Definition logger.h:29
@ MODE_SIG_PROC
Definition logger.h:22
@ MODE_THREAD
Definition logger.h:25
@ MODE_CONFIG
Definition logger.h:26
@ MODE_NETWORK
Definition logger.h:33
@ MODE_MEMORY
Definition logger.h:30
@ MODE_DATABASE
Definition logger.h:35
@ MODE_MATHS
Definition logger.h:31
@ MODE_GENERAL
Definition logger.h:24
@ MODE_EXCEPTION
Definition logger.h:36

References MODE_CONFIG, MODE_DATABASE, MODE_EXCEPTION, MODE_FILE, MODE_GENERAL, MODE_GRAPHICS, MODE_MATHS, MODE_MEMORY, MODE_NETWORK, MODE_OPERATOR, MODE_QT, MODE_SECURITY, MODE_SENSOR, MODE_SIG_PROC, MODE_THREAD, MODE_TIMING, SaveModeMask(), and ui.

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadSeverityMask

void Logger::ReadSeverityMask ( bool Unused)
privateslot

Set the Severity Mask, based on window buttons.

Parameters
Unusedparameter for Signal, Slot parameter matching

This routine will look at the state of the Serverity buttons associated with the logger and sets the bits in the serverity mask corresponding to the set buttons.

Definition at line 241 of file logger.cpp.

242{
243 int severity_mask = 0;
244
245 if ( ui->EmergencySelect->isChecked() )
246 {
247 severity_mask |= 1 << LOG_EMERGENCY;
248 }
249 else
250 {
251 severity_mask &= ~(1 << LOG_EMERGENCY);
252 }
253
254 if ( ui->AlertSelect->isChecked() )
255 {
256 severity_mask |= 1 << LOG_ALERT;
257 }
258 else
259 {
260 severity_mask &= ~(1 << LOG_ALERT);
261 }
262
263 if ( ui->CriticalSelect->isChecked() )
264 {
265 severity_mask |= 1 << LOG_CRITICAL;
266 }
267 else
268 {
269 severity_mask &= ~(1 << LOG_CRITICAL);
270 }
271
272 if ( ui->ErrorSelect->isChecked() )
273 {
274 severity_mask |= 1 << LOG_ERROR;
275 }
276 else
277 {
278 severity_mask &= ~(1 << LOG_ERROR);
279 }
280
281 if ( ui->WarningSelect->isChecked() )
282 {
283 severity_mask |= 1 << LOG_WARNING;
284 }
285 else
286 {
287 severity_mask &= ~(1 << LOG_WARNING);
288 }
289
290 if ( ui->NoticeSelect->isChecked() )
291 {
292 severity_mask |= 1 << LOG_NOTICE;
293 }
294 else
295 {
296 severity_mask &= ~(1 << LOG_NOTICE);
297 }
298
299 if ( ui->InfoSelect->isChecked() )
300 {
301 severity_mask |= 1 << LOG_INFO;
302 }
303 else
304 {
305 severity_mask &= ~(1 << LOG_INFO);
306 }
307
308 if ( ui->DebugSelect->isChecked() )
309 {
310 severity_mask |= 1 << LOG_DEBUG;
311 }
312 else
313 {
314 severity_mask &= ~(1 << LOG_DEBUG);
315 }
316 SaveSeverityMask( severity_mask );
317}
@ LOG_CRITICAL
Definition logger.h:51
@ LOG_ERROR
Definition logger.h:52
@ LOG_INFO
Definition logger.h:55
@ LOG_EMERGENCY
Definition logger.h:49
@ LOG_ALERT
Definition logger.h:50
@ LOG_WARNING
Definition logger.h:53
@ LOG_NOTICE
Definition logger.h:54

References LOG_ALERT, LOG_CRITICAL, LOG_DEBUG, LOG_EMERGENCY, LOG_ERROR, LOG_INFO, LOG_NOTICE, LOG_WARNING, SaveSeverityMask(), and ui.

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoteLog

void Logger::RemoteLog ( REMOTE_LOG_ENTRY LogEntry)
slot

Receiver a Log Entry via a Public Slot.

Parameters
LogEntryStructure holding the Log Entry

Definition at line 553 of file logger.cpp.

554{
555 Add( LogEntry.Severity, LogEntry.Mode, LogEntry.Message );
556}
LOGGING_MODE Mode
Definition logger.h:61
QString Message
Definition logger.h:63
LOGGING_SEVERITY Severity
Definition logger.h:62

References Add(), REMOTE_LOG_ENTRY::Message, REMOTE_LOG_ENTRY::Mode, and REMOTE_LOG_ENTRY::Severity.

Here is the call graph for this function:

◆ SaveLog

void Logger::SaveLog ( void )
privateslot

Save the Log Lines to a File.

This routine takes the lines in the log and writes them to a file.

Definition at line 59 of file logger.cpp.

60{
61 // Ask the User for the Name of the File to hold the Log Entries
62 QString filename = QFileDialog::getSaveFileName( nullptr, "Save Filename", "LogFile.txt", "Files (*.txt )" );
63
64 // If A Filename was provided, write out the log lines, then clear the display.
65 if ( filename != "" )
66 {
67 // Write to the File
68 QFile file( filename );
69 if (file.open(QIODevice::WriteOnly | QIODevice::Text))
70 {
71 int row_counter = 0;
72 QTextStream out(&file);
73 while( row_counter < ui->LogView->count() )
74 {
75 out << ui->LogView->item( row_counter++ )->text() << "\n";
76 }
77 }
78 file.close();
79 ui->LogView->clear();
80 }
81 emit CountChanged( ui->LogView->count() );
82}

References CountChanged(), and ui.

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveLogSettings()

void Logger::SaveLogSettings ( void )
private

Definition at line 514 of file logger.cpp.

515{
516 QSettings settings;
517
518 // Save the Log Severity Settings
519 settings.setValue( "Log_Severity/Emergency", ui->EmergencySelect->isChecked() );
520 settings.setValue( "Log_Severity/Alert", ui->AlertSelect->isChecked() );
521 settings.setValue( "Log_Severity/Critical", ui->CriticalSelect->isChecked() );
522 settings.setValue( "Log_Severity/Error", ui->ErrorSelect->isChecked() );
523 settings.setValue( "Log_Severity/Warning", ui->WarningSelect->isChecked() );
524 settings.setValue( "Log_Severity/Notice", ui->NoticeSelect->isChecked() );
525 settings.setValue( "Log_Severity/Info", ui->InfoSelect->isChecked() );
526 settings.setValue( "Log_Severity/Debug", ui->DebugSelect->isChecked() );
527
528
529 // Save the Mode Settings
530 settings.setValue( "Log_Mode/SigProc", ui->SigProcessSelect->isChecked() );
531 settings.setValue( "Log_Mode/Qt", ui->QtSelect->isChecked() );
532 settings.setValue( "Log_Mode/General", ui->GeneralSelect->isChecked() );
533 settings.setValue( "Log_Mode/Thread", ui->ThreadSelect->isChecked() );
534 settings.setValue( "Log_Mode/Configuration", ui->ConfigSelect->isChecked() );
535 settings.setValue( "Log_Mode/Timing", ui->TimingSelect->isChecked() );
536 settings.setValue( "Log_Mode/Security", ui->SecuritySelect->isChecked() );
537 settings.setValue( "Log_Mode/Graphics", ui->GraphicsSelect->isChecked() );
538 settings.setValue( "Log_Mode/Memory", ui->MemorySelect->isChecked() );
539 settings.setValue( "Log_Mode/Maths", ui->MathsSelect->isChecked() );
540 settings.setValue( "Log_Mode/File", ui->FileOpsSelect->isChecked() );
541 settings.setValue( "Log_Mode/Network", ui->NetworkCommsSelect->isChecked() );
542 settings.setValue( "Log_Mode/Operator", ui->OperatorSelect->isChecked() );
543 settings.setValue( "Log_Mode/Database", ui->DatabaseSelect->isChecked() );
544 settings.setValue( "Log_Mode/Exception", ui->ExceptionsSelect->isChecked() );
545 settings.setValue( "Log_Mode/Sensors", ui->SensorsSelect->isChecked() );
546
547 // Save Log Parameters
548 settings.setValue( "Log_Setup/Allowed_lines", ui->MaxLogLines->value() );
549 settings.setValue( "Log_Setup/Minimum_lines", ui->MaxLogLines->minimum() );
550 settings.setValue( "Log_Setup/Maximum_lines", ui->MaxLogLines->maximum() );
551}

References ui.

Referenced by ~Logger().

Here is the caller graph for this function:

◆ SaveModeMask()

void Logger::SaveModeMask ( int ModeMask)

Save the Log Mode Mask.

Parameters
ModeMaskA mask of the active modes

The SeverityMask holds each possible mode as a bit mask. If a bit is on, then that mode is active.

Definition at line 43 of file logger.cpp.

44{
45 current_mode_mask = ModeMask;
46}

References current_mode_mask.

Referenced by PresetLogMode(), and ReadModeMask().

Here is the caller graph for this function:

◆ SaveSeverityMask()

void Logger::SaveSeverityMask ( int SeverityMask)

Save the Log Severity Mask.

Parameters
SeverityMaskA mask of the active severity levels

The SeverityMask holds each possible severity level as a bit mask. If a bit is on, then that severity level is active.

Definition at line 38 of file logger.cpp.

39{
40 current_severity_mask = SeverityMask;
41}

References current_severity_mask.

Referenced by PresetLogSeverity(), and ReadSeverityMask().

Here is the caller graph for this function:

◆ SetMaxLines()

void Logger::SetMaxLines ( int MaxLogLines)

Set the maximum number of lines the log will retain.

Parameters
MaxLogLinesMaximum log lines to retain

This function sets the maximum number of lines the log will retain before the oldest lines are delted when a new log line arrives.

Definition at line 48 of file logger.cpp.

49{
50 maximum_log_lines = MaxLogLines;
51}

References maximum_log_lines.

Referenced by UpdateMaxLogLines().

Here is the caller graph for this function:

◆ UpdateMaxLogLines

void Logger::UpdateMaxLogLines ( int Value)
privateslot

Definition at line 509 of file logger.cpp.

510{
511 SetMaxLines( Value );
512}
void SetMaxLines(int MaxLogLines)
Set the maximum number of lines the log will retain.
Definition logger.cpp:48

References SetMaxLines().

Referenced by LoadLogSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ current_mode_mask

int Logger::current_mode_mask
private

Mask holding currently active modes.

Each mode is represented by a bit in the mask. If that bit is not a 1, then a log message with that mode will be rejected.

Definition at line 220 of file logger.h.

Referenced by Add(), Logger(), and SaveModeMask().

◆ current_severity_mask

int Logger::current_severity_mask
private

Mask holding currently active severity levels.

Each severity level is represented by a bit in the mask. If that bit is not a 1, then a log message with that level will be rejected.

Definition at line 212 of file logger.h.

Referenced by Add(), Logger(), and SaveSeverityMask().

◆ icon_name_list

QStringList Logger::icon_name_list
private

This list holds the names of the severity level icons.

These icons are attached to the log lines that are placed in the log. The colour is an indication of the severity level of the log line. The icon colours range from deep green for Debug, through to deep red for a fatal error.

Definition at line 204 of file logger.h.

Referenced by Add(), Logger(), and ~Logger().

◆ maximum_log_lines

int Logger::maximum_log_lines
private

The maximum number of lines the log will retain.

Definition at line 226 of file logger.h.

Referenced by Add(), Logger(), and SetMaxLines().

◆ mode_name_list

QStringList Logger::mode_name_list
private

This list holds the names of the valid modes.

Definition at line 195 of file logger.h.

Referenced by Add(), Logger(), and ~Logger().

◆ severity_name_list

QStringList Logger::severity_name_list
private

This list holds the names of the valid severity levels.

Definition at line 189 of file logger.h.

Referenced by Add(), Logger(), and ~Logger().

◆ ui

Ui::MainWindow* Logger::ui
private

Pointer the Main Program Window.

This is used to access all the graphical objects on the display.

Definition at line 183 of file logger.h.

Referenced by Add(), ClearLog(), LoadLogSettings(), Logger(), LogItemsUnhide(), LogSelectItem(), PresetLogMode(), PresetLogSeverity(), ReadModeMask(), ReadSeverityMask(), SaveLog(), SaveLogSettings(), and ~Logger().


The documentation for this class was generated from the following files: