26#include "ns3/singleton.h"
27#include "ns3/string.h"
35NS_LOG_COMPONENT_DEFINE(
"SatLog");
40NS_OBJECT_ENSURE_REGISTERED(
SatLog);
45 static TypeId tid = TypeId(
"ns3::SatLog").SetParent<Object>().AddConstructor<SatLog>();
51 NS_LOG_FUNCTION(
this);
56 NS_LOG_FUNCTION(
this);
64 NS_LOG_FUNCTION(
this);
72 NS_LOG_FUNCTION(
this);
82Ptr<SatOutputFileStreamStringContainer>
85 NS_LOG_FUNCTION(
this);
87 std::stringstream filename;
90 filename << dataPath <<
"/log" << fileTag;
92 key_t key = std::make_pair(logType, fileTag);
94 std::pair<container_t::iterator, bool> result =
m_container.insert(std::make_pair(
96 CreateObject<SatOutputFileStreamStringContainer>(filename.str().c_str(), std::ios::out)));
98 if (result.second ==
false)
100 NS_FATAL_ERROR(
"SatLog::CreateLog failed");
103 NS_LOG_INFO(
"Created type " << logType <<
" log with file tag " << fileTag);
105 return result.first->second;
108Ptr<SatOutputFileStreamStringContainer>
111 NS_LOG_FUNCTION(
this);
113 key_t key = std::make_pair(logType, fileTag);
115 container_t::iterator iter =
m_container.find(key);
128 NS_LOG_FUNCTION(
this);
130 container_t::iterator iter;
134 iter->second->WriteContainerToFile();
141 NS_LOG_FUNCTION(
this);
148 Ptr<SatOutputFileStreamStringContainer> log =
FindLog(logType, fileTag);
150 NS_LOG_INFO(
"Type: " << logType <<
", file tag: " << fileTag <<
", message: " << message);
154 log->AddToContainer(message);
161 std::string fileTag =
"";
174 fileTag =
"_warning";
182 NS_FATAL_ERROR(
"SatLog::GetFileTag - This function should not be called for custom logs");
186 NS_FATAL_ERROR(
"SatLog::GetFileTag - Invalid log type");
static Ptr< SatEnvVariables > GetInstance()
Class for simulator output logging such as warnings and error messages.
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.
LogType_t
Enum for log types.
@ LOG_WARNING
LOG_WARNING.
@ LOG_GENERIC
LOG_GENERIC.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.