23 #include "../utils/satellite-env-variables.h"
26 #include <ns3/singleton.h>
27 #include <ns3/string.h>
35 NS_LOG_COMPONENT_DEFINE(
"SatLog");
40 NS_OBJECT_ENSURE_REGISTERED(SatLog);
45 static TypeId tid = TypeId(
"ns3::SatLog").SetParent<Object>().AddConstructor<SatLog>();
52 NS_LOG_FUNCTION(
this);
59 NS_LOG_FUNCTION(
this);
61 ObjectBase::ConstructSelf(AttributeConstructionList());
66 NS_LOG_FUNCTION(
this);
74 NS_LOG_FUNCTION(
this);
82 NS_LOG_FUNCTION(
this);
92 Ptr<SatOutputFileStreamStringContainer>
95 NS_LOG_FUNCTION(
this);
97 std::stringstream filename;
98 std::string dataPath = Singleton<SatEnvVariables>::Get()->GetOutputPath();
100 filename << dataPath <<
"/log" << fileTag;
102 key_t key = std::make_pair(logType, fileTag);
104 std::pair<container_t::iterator, bool> result =
m_container.insert(std::make_pair(
106 CreateObject<SatOutputFileStreamStringContainer>(filename.str().c_str(), std::ios::out)));
108 if (result.second ==
false)
110 NS_FATAL_ERROR(
"SatLog::CreateLog failed");
113 NS_LOG_INFO(
"Created type " << logType <<
" log with file tag " << fileTag);
115 return result.first->second;
118 Ptr<SatOutputFileStreamStringContainer>
121 NS_LOG_FUNCTION(
this);
123 key_t key = std::make_pair(logType, fileTag);
125 container_t::iterator iter =
m_container.find(key);
138 NS_LOG_FUNCTION(
this);
140 container_t::iterator iter;
144 iter->second->WriteContainerToFile();
151 NS_LOG_FUNCTION(
this);
158 Ptr<SatOutputFileStreamStringContainer> log =
FindLog(logType, fileTag);
160 NS_LOG_INFO(
"Type: " << logType <<
", file tag: " << fileTag <<
", message: " << message);
164 log->AddToContainer(message);
171 std::string fileTag =
"";
184 fileTag =
"_warning";
192 NS_FATAL_ERROR(
"SatLog::GetFileTag - This function should not be called for custom logs");
196 NS_FATAL_ERROR(
"SatLog::GetFileTag - Invalid log type");
void DoDispose()
Do needed dispose actions.
void WriteToFile()
Write the contents of a container matching to the key into a file.
Ptr< SatOutputFileStreamStringContainer > CreateLog(LogType_t logType, std::string fileTag)
Function for creating a log.
std::pair< LogType_t, std::string > key_t
typedef for container key
std::string GetFileTag(LogType_t logType)
Function for getting the file tag for predefined log types.
void Reset()
Function for resetting the variables.
Ptr< SatOutputFileStreamStringContainer > FindLog(LogType_t logType, std::string fileTag)
Function for finding a log based on the key.
void AddToLog(LogType_t logType, std::string fileTag, std::string message)
Function for adding a line to a specific log.
container_t m_container
Map for containers.
static TypeId GetTypeId(void)
NS-3 type id function.
TypeId GetInstanceTypeId(void) const
NS-3 instance type id function.
LogType_t
Enum for log types.
@ LOG_WARNING
LOG_WARNING.
@ LOG_GENERIC
LOG_GENERIC.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.