Major update:

- Logging
  - Created LogCore Class
  - Updated LogCore to use file descriptors instead of stdout
  - Add Log object reference to constructors for:
    FunctionCore, SelectCore
  - Use extern Log() object in SignalCore
- SelectableCore
  - Added new connection type: ForkedPipe
    Create pipe, fork process, connect pipe out to child stdin, exec
This commit is contained in:
Charl Wentzel
2016-08-22 12:14:53 +02:00
parent eaace97ec9
commit 5ea05d119e
10 changed files with 366 additions and 125 deletions

View File

@@ -22,7 +22,7 @@ extern char ProcessName[];
//---------------------------------------------------------------------------
// Life cycle
CFunctionCore::CFunctionCore( const char * FunctionName, EDebugLevel pDebugLevel, int pOuputDisplay )
CFunctionCore::CFunctionCore( const char * FunctionName, CLogCore * pLog, EDebugLevel pDebugLevel, int pOuputDisplay )
{
// Set name
if (FunctionName) {
@@ -37,11 +37,12 @@ CFunctionCore::CFunctionCore( const char * FunctionName, EDebugLevel pDebugLevel
FirstIO = NULL;
// Output
Log = pLog;
OutputDisplay = pOuputDisplay;
DebugLevel = pDebugLevel;
// Report status
LogMessage( DebugLevel, dlLow, "%s: Function '%s' - Created", ProcessName, FunctionName );
if (Log) Log->Message( DebugLevel, dlLow, "%s: Function '%s' - Created", ProcessName, FunctionName );
}
//---------------------------------------------------------------------------
@@ -86,7 +87,7 @@ CFunctionCore::~CFunctionCore()
}
// Report status
LogMessage( DebugLevel, dlLow, "%s: Function '%s' - Destroyed", ProcessName, Name );
if (Log) Log->Message( DebugLevel, dlLow, "%s: Function '%s' - Destroyed", ProcessName, Name );
// Destroy Name
if (Name) {
@@ -122,7 +123,7 @@ TLocalIO * CFunctionCore::AddLocalIO( const char * IOName )
strcpy( (*LocalIO)->Name, IOName );
// Log Event
LogMessage( DebugLevel, dlLow, "%s: Local IO '%s' - Created", Name, IOName );
if (Log) Log->Message( DebugLevel, dlLow, "%s: Local IO '%s' - Created", Name, IOName );
}
return *LocalIO;
@@ -159,7 +160,7 @@ bool CFunctionCore::AddInput( const char * IOName, CFunctionCore * OutFunction,
strcpy( (*LinkedIO)->IOName, OutputName );
// Log Event
LogMessage( DebugLevel, dlLow, "%s: Input Linked - '%s'/'%s' <-- '%s'/'%s'", Name, Name, IOName, OutFunction->GetName(), OutputName );
if (Log) Log->Message( DebugLevel, dlLow, "%s: Input Linked - '%s'/'%s' <-- '%s'/'%s'", Name, Name, IOName, OutFunction->GetName(), OutputName );
}
// Link Return direction as well
@@ -200,7 +201,7 @@ bool CFunctionCore::AddOutput( const char * IOName, CFunctionCore * InFunction,
strcpy( (*LinkedIO)->IOName, InputName );
// Log Event
LogMessage( DebugLevel, dlLow, "%s: Output Linked - '%s'/'%s' --> '%s'/'%s'", Name, Name, IOName, InFunction->GetName(), InputName );
if (Log) Log->Message( DebugLevel, dlLow, "%s: Output Linked - '%s'/'%s' --> '%s'/'%s'", Name, Name, IOName, InFunction->GetName(), InputName );
}
// Link return direction as well
@@ -229,12 +230,12 @@ int CFunctionCore::Input( const char * IOName, const char * Data, int MaxLen )
if (!(LocalIO = GetLocalIO( IOName )))
{
// Log event
LogMessage( DebugLevel, dlHigh, "%s: Local IO '%s' - Input rejected, Local IO not found", Name, IOName );
if (Log) Log->Message( DebugLevel, dlHigh, "%s: Local IO '%s' - Input rejected, Local IO not found", Name, IOName );
return 0;
}
// Log event
ShowOutput( DebugLevel, dlHigh, OutputDisplay, Data, MaxLen, "%s: Local IO '%s' - IN:", Name, IOName );
if (Log) Log->Output( DebugLevel, dlHigh, OutputDisplay, Data, MaxLen, "%s: Local IO '%s' - IN:", Name, IOName );
// Return processed bytes
return MaxLen;
@@ -256,7 +257,7 @@ int CFunctionCore::Output( const char * IOName, const char * Data, int Len )
if (!(LocalIO = GetLocalIO( IOName )))
{
// Log Event
LogMessage( DebugLevel, dlHigh, "%s: Local IO '%s' - Output rejected, Local IO not found", Name, IOName );
if (Log) Log->Message( DebugLevel, dlHigh, "%s: Local IO '%s' - Output rejected, Local IO not found", Name, IOName );
return 0;
}
@@ -277,7 +278,7 @@ int CFunctionCore::Output( const TLocalIO * LocalIO, const char * Data, int Len
}
// Log event
ShowOutput( DebugLevel, dlHigh, OutputDisplay, Data, Len, "%s: Local IO '%s' - OUT:", Name, LocalIO->Name );
if (Log) Log->Output( DebugLevel, dlHigh, OutputDisplay, Data, Len, "%s: Local IO '%s' - OUT:", Name, LocalIO->Name );
// Pass output to all linked inputs
Output = LocalIO->FirstOutput;