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:
Charl Wentzel
2018-11-25 18:24:36 +02:00
parent bdff82f9c8
commit d770d9f6cb
5 changed files with 129 additions and 127 deletions

View File

@@ -44,7 +44,7 @@ CFunctionCore::CFunctionCore( const char * pName, const char * pType ) : Type( p
// Logging
Log = Application->Log;
LogLevel = dlNone;
LogOutput = OUT_NORMAL;
LogOutput = loNormal;
// Stored output
StoredOutput = NULL;
@@ -102,53 +102,19 @@ CFunctionCore::~CFunctionCore()
bool CFunctionCore::Init( CDataMember * FunctionConfig )
{
// Load configuration
CDataMember * ItemConfig;
CDataMember * LogConfig;
CDataMember * ChannelConfig;
EDebugLevel pLogLevel;
int pLogOutput;
char * TempStr;
// Validate
if (!FunctionConfig )
return false;
// Get debug level
pLogLevel = dlNone;
TempStr = (char*)FunctionConfig->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 = FunctionConfig->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 = FunctionConfig->GetChild( "Log", true );
pLogLevel = Log->ReadLogLevel( LogConfig );
pLogOutput = Log->ReadLogOutput( LogConfig );
SetLogParam( pLogLevel, pLogOutput );
// Load Channels