Skip to content
Snippets Groups Projects
Commit 9b076da0 authored by Ruud Overeem's avatar Ruud Overeem
Browse files

BugID: 1000

Added optional third argument to init function of GCFTask allowing us to pass
the name of the log file we want to use.
parent 40018b1b
No related branches found
No related tags found
No related merge requests found
...@@ -85,7 +85,7 @@ class GCFDummyPort : public GCFPortInterface ...@@ -85,7 +85,7 @@ class GCFDummyPort : public GCFPortInterface
int cancelAllTimers () int cancelAllTimers ()
{ return (0); } { return (0); }
double timeLeft(long timerID) double timeLeft(long /*timerID*/)
{ return (0); } { return (0); }
private: private:
......
...@@ -68,7 +68,7 @@ class GCFTask : public GCFFsm ...@@ -68,7 +68,7 @@ class GCFTask : public GCFFsm
* - lofar logger("mac.log_prop") * - lofar logger("mac.log_prop")
* - parameterset(argv[0] + ".conf") * - parameterset(argv[0] + ".conf")
*/ */
static void init (int argc, char** argv); static void init (int argc, char** argv, const string& logfile = "");
/** /**
* The static run method. This starts the event processing loop. * The static run method. This starts the event processing loop.
...@@ -112,8 +112,7 @@ class GCFTask : public GCFFsm ...@@ -112,8 +112,7 @@ class GCFTask : public GCFFsm
void setName (string& name) {_name = name;} void setName (string& name) {_name = name;}
/// returns the "define" of a signal ID as a string /// returns the "define" of a signal ID as a string
const char* evtstr(const GCFEvent& e) const; string evtstr(const GCFEvent& e) const;
string eventstr(const GCFEvent& e) const;
protected: protected:
/** /**
......
...@@ -72,7 +72,7 @@ GCFTask::~GCFTask() ...@@ -72,7 +72,7 @@ GCFTask::~GCFTask()
{ {
} }
void GCFTask::init(int argc, char** argv) void GCFTask::init(int argc, char** argv, const string& logfile)
{ {
_argc = argc; _argc = argc;
_argv = argv; _argv = argv;
...@@ -87,8 +87,15 @@ void GCFTask::init(int argc, char** argv) ...@@ -87,8 +87,15 @@ void GCFTask::init(int argc, char** argv)
// locator could not find it try defaultname // locator could not find it try defaultname
logPropFile = "mac.log_prop"; logPropFile = "mac.log_prop";
} }
INIT_LOGGER(aCL.locate(logPropFile).c_str()); if (logfile.empty()) {
LOG_DEBUG_STR ("Initialized logsystem with: " << aCL.locate(logPropFile)); INIT_LOGGER(aCL.locate(logPropFile).c_str());
LOG_DEBUG_STR ("Initialized logsystem with: " << aCL.locate(logPropFile));
}
else {
INIT_VAR_LOGGER(aCL.locate(logPropFile).c_str(), logfile);
LOG_DEBUG_STR ("Initialized logsystem with: " << aCL.locate(logPropFile) <<
"," << logfile);
}
// Read in the ParameterSet of the task (<task>.conf) // Read in the ParameterSet of the task (<task>.conf)
ParameterSet* pParamSet = ACC::APS::globalParameterSet(); ParameterSet* pParamSet = ACC::APS::globalParameterSet();
...@@ -194,22 +201,10 @@ void GCFTask::registerProtocol(unsigned short protocolID, ...@@ -194,22 +201,10 @@ void GCFTask::registerProtocol(unsigned short protocolID,
_protocols[protocolID] = signal_names; _protocols[protocolID] = signal_names;
} }
const char* GCFTask::evtstr(const GCFEvent& e) const
{
static const char* unknown = "unknown signal";
const char* signame(0);
TProtocols::const_iterator iter = _protocols.find(F_EVT_PROTOCOL(e));
if (iter != _protocols.end())
{
signame = (iter->second)[F_EVT_SIGNAL(e)];
}
return (signame?signame:unknown);
}
// //
// eventstr(event&) // evtstr(event&)
// //
string GCFTask::eventstr(const GCFEvent& e) const string GCFTask::evtstr(const GCFEvent& e) const
{ {
TProtocols::const_iterator iter = _protocols.find(F_EVT_PROTOCOL(e)); TProtocols::const_iterator iter = _protocols.find(F_EVT_PROTOCOL(e));
if (iter != _protocols.end()) { if (iter != _protocols.end()) {
......
...@@ -105,7 +105,7 @@ GCFEvent::TResult GCFRawPort::dispatch(GCFEvent& event) ...@@ -105,7 +105,7 @@ GCFEvent::TResult GCFRawPort::dispatch(GCFEvent& event)
(F_EVT_PROTOCOL(event) != F_PORT_PROTOCOL)) { (F_EVT_PROTOCOL(event) != F_PORT_PROTOCOL)) {
// Inform about the fact of an incomming message // Inform about the fact of an incomming message
LOG_DEBUG(formatString ("%s was received on port '%s' in task '%s'", LOG_DEBUG(formatString ("%s was received on port '%s' in task '%s'",
_pTask->evtstr(event), _pTask->evtstr(event).c_str(),
getRealName().c_str(), getRealName().c_str(),
_pTask->getName().c_str())); _pTask->getName().c_str()));
} }
...@@ -347,7 +347,7 @@ GCFEvent::TResult GCFRawPort::recvEvent() ...@@ -347,7 +347,7 @@ GCFEvent::TResult GCFRawPort::recvEvent()
ASSERT(getTask()); ASSERT(getTask());
LOG_DEBUG(formatString ( LOG_DEBUG(formatString (
"'%s' for port '%s' in task '%s' not handled or an error occured", "'%s' for port '%s' in task '%s' not handled or an error occured",
getTask()->evtstr(e), getRealName().c_str(), getTask()->evtstr(e).c_str(), getRealName().c_str(),
getTask()->getName().c_str())); getTask()->getName().c_str()));
} }
......
...@@ -163,7 +163,7 @@ ssize_t GCFDevicePort::send(GCFEvent& e) ...@@ -163,7 +163,7 @@ ssize_t GCFDevicePort::send(GCFEvent& e)
LOG_DEBUG(formatString ( LOG_DEBUG(formatString (
"Sending event '%s' for task '%s' on port '%s'", "Sending event '%s' for task '%s' on port '%s'",
getTask()->evtstr(e), getTask()->evtstr(e).c_str(),
getTask()->getName().c_str(), getTask()->getName().c_str(),
getRealName().c_str())); getRealName().c_str()));
......
...@@ -193,7 +193,7 @@ ssize_t GCFETHRawPort::send(GCFEvent& e) ...@@ -193,7 +193,7 @@ ssize_t GCFETHRawPort::send(GCFEvent& e)
LOG_DEBUG(formatString ( LOG_DEBUG(formatString (
"Sending event '%s' for task '%s' on port '%s'", "Sending event '%s' for task '%s' on port '%s'",
getTask()->evtstr(e), getTask()->evtstr(e).c_str(),
getTask()->getName().c_str(), getTask()->getName().c_str(),
getRealName().c_str())); getRealName().c_str()));
......
...@@ -316,7 +316,7 @@ ssize_t GCFTCPPort::send(GCFEvent& e) ...@@ -316,7 +316,7 @@ ssize_t GCFTCPPort::send(GCFEvent& e)
LOG_TRACE_STAT(formatString ( LOG_TRACE_STAT(formatString (
"Sending event '%s' for task '%s' on port '%s'", "Sending event '%s' for task '%s' on port '%s'",
getTask()->evtstr(e), getTask()->getName().c_str(), getTask()->evtstr(e).c_str(), getTask()->getName().c_str(),
getRealName().c_str())); getRealName().c_str()));
if ((written = _pSocket->send(buf, packsize)) != (ssize_t) packsize) { if ((written = _pSocket->send(buf, packsize)) != (ssize_t) packsize) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment