52 lines
952 B
C++
52 lines
952 B
C++
/*
|
|
* DebugManager.cpp
|
|
*
|
|
* Created on: Mar 20, 2014
|
|
* Author: jonny
|
|
*/
|
|
|
|
#include "DebugManager.h"
|
|
using namespace std;
|
|
|
|
void DebugManager::printDebugMessage(string sender, string message)
|
|
{
|
|
#ifndef NDEBUG
|
|
if (whiteList.count(sender))
|
|
{
|
|
if (writeToConsole)
|
|
cout << " at " << sc_time_stamp() << "\t in " << sender << "\t: " << message << endl;
|
|
|
|
if (writeToFile && debugFile)
|
|
debugFile << " at " << sc_time_stamp() << " in " << sender << "\t: " << message << "\n";
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void DebugManager::addToWhiteList(string sender)
|
|
{
|
|
whiteList.insert(sender);
|
|
}
|
|
|
|
void DebugManager::addToWhiteList(vector<string> senders)
|
|
{
|
|
for (string sender : senders)
|
|
addToWhiteList(sender);
|
|
}
|
|
|
|
DebugManager::DebugManager() :
|
|
writeToConsole(true), writeToFile(true)
|
|
{
|
|
}
|
|
|
|
void DebugManager::setDebugFile(std::string filename)
|
|
{
|
|
if(debugFile)
|
|
debugFile.close();
|
|
debugFile.open(filename);
|
|
}
|
|
|
|
DebugManager::~DebugManager()
|
|
{
|
|
debugFile.close();
|
|
}
|