Project Documentation Manager BRIGADOON-0002
Project Documentation Manager
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:515

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

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 498 of file logger.cpp.

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

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 478 of file logger.cpp.

479{
480 PresetLogMode( true );
481}
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 483 of file logger.cpp.

484{
485 PresetLogMode( false );
486}

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 469 of file logger.cpp.

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

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 488 of file logger.cpp.

489{
490 PresetLogSeverity( true );
491}
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 493 of file logger.cpp.

494{
495 PresetLogSeverity( false );
496}

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 320 of file logger.cpp.

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

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

555{
556 Add( LogEntry.Severity, LogEntry.Mode, LogEntry.Message );
557}
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 515 of file logger.cpp.

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

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 510 of file logger.cpp.

511{
512 SetMaxLines( Value );
513}
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: