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:
17
LogCore.cpp
17
LogCore.cpp
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user