Major Update:

- Implemented global var DebugLevel
- Update LogCore to check DebugLevel
- Added many log messages and standadised all log messages
- Further improved validation checks on all methods
- Updated SelectCore, only remove SelectHandle from list during Test()
- Close Handles in SelectableCore destructor
Bug fixes:
- Non-blocking Client Socket Connection now working correctly
- Remove FD from Select lists at the correct time
This commit is contained in:
Charl Wentzel
2016-05-26 15:03:13 +02:00
parent 9ace97c1a3
commit c01c8f5e9b
8 changed files with 532 additions and 235 deletions

View File

@@ -17,16 +17,22 @@
//---------------------------------------------------------------------------
// Global vars
char ProcessName[20] = "Connect";
EDebugLevel DebugLevel = dlLow;
char LogStr[1000]; // Temporary var to create log messages, globally available to save on memory operations
//---------------------------------------------------------------------------
bool LogMessage( const char * Heading, const char *Message )
bool LogMessage( const char * Heading, EDebugLevel Level, const char *Message )
{
// Validate values
if (!Message)
return false;
// Check debug level
if (Level > DebugLevel) {
return true;
}
// Show normal output
if (!Heading) {
printf( "%s\n", Message );
@@ -38,7 +44,7 @@ bool LogMessage( const char * Heading, const char *Message )
}
//---------------------------------------------------------------------------
bool ShowOutput( const char * Heading, const short Show, const char * Buffer, int Len )
bool ShowOutput( const char * Heading, EDebugLevel Level, const short Show, const char * Buffer, int Len )
{
// Validate values
if (!Buffer)
@@ -46,6 +52,11 @@ bool ShowOutput( const char * Heading, const short Show, const char * Buffer, in
if (Len == -1)
Len = strlen( Buffer );
// Check debug level
if (Level > DebugLevel) {
return true;
}
// Show Hex output
if (Show & OUT_HEX) {
printf( "%s [%d]: ", Heading, Len );