23 #include "../utils/satellite-env-variables.h"
26 #include <ns3/singleton.h>
27 #include <ns3/string.h>
29 NS_LOG_COMPONENT_DEFINE(
"SatLog");
34 NS_OBJECT_ENSURE_REGISTERED(SatLog);
39 static TypeId tid = TypeId(
"ns3::SatLog").SetParent<Object>().AddConstructor<SatLog>();
46 NS_LOG_FUNCTION(
this);
53 NS_LOG_FUNCTION(
this);
55 ObjectBase::ConstructSelf(AttributeConstructionList());
60 NS_LOG_FUNCTION(
this);
68 NS_LOG_FUNCTION(
this);
76 NS_LOG_FUNCTION(
this);
86 Ptr<SatOutputFileStreamStringContainer>
89 NS_LOG_FUNCTION(
this);
91 std::stringstream filename;
92 std::string dataPath = Singleton<SatEnvVariables>::Get()->GetOutputPath();
94 filename << dataPath <<
"/log" << fileTag;
96 key_t key = std::make_pair(logType, fileTag);
98 std::pair<container_t::iterator, bool> result =
m_container.insert(std::make_pair(
100 CreateObject<SatOutputFileStreamStringContainer>(filename.str().c_str(), std::ios::out)));
102 if (result.second ==
false)
104 NS_FATAL_ERROR(
"SatLog::CreateLog failed");
107 NS_LOG_INFO(
"Created type " << logType <<
" log with file tag " << fileTag);
109 return result.first->second;
112 Ptr<SatOutputFileStreamStringContainer>
115 NS_LOG_FUNCTION(
this);
117 key_t key = std::make_pair(logType, fileTag);
119 container_t::iterator iter =
m_container.find(key);
132 NS_LOG_FUNCTION(
this);
134 container_t::iterator iter;
138 iter->second->WriteContainerToFile();
145 NS_LOG_FUNCTION(
this);
152 Ptr<SatOutputFileStreamStringContainer> log =
FindLog(logType, fileTag);
154 NS_LOG_INFO(
"Type: " << logType <<
", file tag: " << fileTag <<
", message: " << message);
158 log->AddToContainer(message);
165 std::string fileTag =
"";
178 fileTag =
"_warning";
186 NS_FATAL_ERROR(
"SatLog::GetFileTag - This function should not be called for custom logs");
190 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.