Important Update:
- LogCore:
- Implement ReadLogLevel() & ReadLogOutput() methods
Standardised handling of logging parameters
- Split Log/Output in config to: Log/Output & Log/Options
- LogOutput (Show) param: first nibble = format, second nibble = options
- Replace Format constants (OUT_XXX) with enum ELogOutput
- Add loRaw format - raw untouched output
- Replace OUT_CRLF with OUT_NOCRLF - Replace \r\n with "."
- Improved Binary output method
- Simplified Log->Output() method
- FunctionCore, ApplicationCore:
- Replace reading of LogConfig with new methods in LogCore
This commit is contained in:
@@ -33,7 +33,7 @@ CApplication::CApplication( EDebugLevel pLogLevel )
|
||||
// Create output logger
|
||||
Log = new CLogCore( stdout );
|
||||
LogLevel = pLogLevel;
|
||||
LogOutput = OUT_NORMAL;
|
||||
LogOutput = loNormal;
|
||||
|
||||
// Create Configuration
|
||||
DataTree = new CDataMember();
|
||||
@@ -206,52 +206,18 @@ bool CApplication::SetLogParam( EDebugLevel pDebugLevel, int pOutputDisplay )
|
||||
bool CApplication::InitApplication()
|
||||
{
|
||||
CDataMember * CoreConfig;
|
||||
CDataMember * ItemConfig;
|
||||
CDataMember * LogConfig;
|
||||
CDataMember * SelectConfig;
|
||||
EDebugLevel pLogLevel;
|
||||
int pLogOutput;
|
||||
char * TempStr;
|
||||
|
||||
// Get Core definition
|
||||
CoreConfig = Definition->GetChild( "Core", true );
|
||||
|
||||
// Get debug level
|
||||
pLogLevel = dlNone;
|
||||
TempStr = (char*)CoreConfig->GetChStr( "Log/Level", "Medium", true );
|
||||
if (TempStr)
|
||||
{
|
||||
if (!strcasecmp( TempStr, "Low" ))
|
||||
pLogLevel = dlLow;
|
||||
else if (!strcasecmp( TempStr, "Medium" ))
|
||||
pLogLevel = dlMedium;
|
||||
else if (!strcasecmp( TempStr, "High" ))
|
||||
pLogLevel = dlHigh;
|
||||
}
|
||||
|
||||
// Set debug output
|
||||
pLogOutput = 0;
|
||||
ItemConfig = CoreConfig->GetChild( "Log/Output[0]", true ); // Create first element if not exist
|
||||
while (ItemConfig)
|
||||
{
|
||||
if ((TempStr = (char*)ItemConfig->GetStr( "Normal" ))) // Set default value "Normal" if not set
|
||||
{
|
||||
if (!strcasecmp( TempStr, "Normal")) // Normal ASCII -> Unless "AsIs", print special chars as "."
|
||||
pLogOutput |= OUT_NORMAL;
|
||||
else if (!strcasecmp( TempStr, "Bin")) // Print as Binary value ('1' and '0')
|
||||
pLogOutput |= OUT_BIN;
|
||||
else if (!strcasecmp( TempStr, "Hex")) // Print as Hexadecimal value (0-9,A-F)
|
||||
pLogOutput |= OUT_HEX;
|
||||
else if (!strcasecmp( TempStr, "Count")) // Print number of characters
|
||||
pLogOutput |= OUT_COUNT;
|
||||
else if (!strcasecmp( TempStr, "AsIs")) // Use with "Normal" -> Do not print special chars as "."
|
||||
pLogOutput |= OUT_ASIS;
|
||||
else if (!strcasecmp( TempStr, "CRLF")) // Add \r\n at end of line if not present
|
||||
pLogOutput |= OUT_CRLF;
|
||||
else
|
||||
pLogOutput |= OUT_NORMAL;
|
||||
}
|
||||
ItemConfig = ItemConfig->GetNextPeer();
|
||||
}
|
||||
// Configure Logging/Debugging
|
||||
LogConfig = CoreConfig->GetChild( "Log", true );
|
||||
pLogLevel = Log->ReadLogLevel( LogConfig );
|
||||
pLogOutput = Log->ReadLogOutput( LogConfig );
|
||||
SetLogParam( pLogLevel, pLogOutput );
|
||||
|
||||
// Configure Selector
|
||||
|
||||
Reference in New Issue
Block a user