Class for simulator output logging such as warnings and error messages. More...
#include "satellite-log.h"
Public Types | |
typedef std::map< key_t, Ptr< SatOutputFileStreamStringContainer > > | container_t |
typedef for map of containers More... | |
typedef std::pair< LogType_t, std::string > | key_t |
typedef for container key More... | |
enum | LogType_t { LOG_GENERIC = 0 , LOG_INFO = 1 , LOG_WARNING = 2 , LOG_ERROR = 3 , LOG_CUSTOM = 4 } |
Enum for log types. More... | |
Public Member Functions | |
SatLog () | |
Constructor. More... | |
~SatLog () | |
Destructor. More... | |
void | AddToLog (LogType_t logType, std::string fileTag, std::string message) |
Function for adding a line to a specific log. More... | |
void | DoDispose () |
Do needed dispose actions. More... | |
TypeId | GetInstanceTypeId (void) const |
NS-3 instance type id function. More... | |
void | Reset () |
Function for resetting the variables. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
NS-3 type id function. More... | |
Private Member Functions | |
Ptr< SatOutputFileStreamStringContainer > | CreateLog (LogType_t logType, std::string fileTag) |
Function for creating a log. More... | |
Ptr< SatOutputFileStreamStringContainer > | FindLog (LogType_t logType, std::string fileTag) |
Function for finding a log based on the key. More... | |
std::string | GetFileTag (LogType_t logType) |
Function for getting the file tag for predefined log types. More... | |
void | WriteToFile () |
Write the contents of a container matching to the key into a file. More... | |
Private Attributes | |
container_t | m_container |
Map for containers. More... | |
Class for simulator output logging such as warnings and error messages.
The format for messages is (type, custom file tag, message). Custom file tag is in effect only with LOG_CUSTOM. With other types it does not matter and can be left empty. It is also possible to define a simulation specific tag, which is useful with simulation campaigns for avoiding log file overwrite.
The class specifies the following log types: LOG_GENERIC - for all messages LOG_INFO - for info messages LOG_WARNING - for warning messages LOG_ERROR - for error messages LOG_CUSTOM - for custom messages specified by the second parameter
The output files are located in contrib/satellite/data/logs folder. The output file format is the following: log<type><custom file tag><simulation tag>
With (LOG_CUSTOM, "_exampleTag", "Example message for custom log") and simulation tag "_ut30_beam1" the file log_exampleTag_ut30_beam1 would contain the message "Example message for custom log".
Definition at line 56 of file satellite-log.h.
typedef std::map<key_t, Ptr<SatOutputFileStreamStringContainer> > ns3::SatLog::container_t |
typedef for map of containers
Definition at line 79 of file satellite-log.h.
typedef std::pair<LogType_t, std::string> ns3::SatLog::key_t |
typedef for container key
Definition at line 74 of file satellite-log.h.
Enum for log types.
Enumerator | |
---|---|
LOG_GENERIC | LOG_GENERIC. |
LOG_INFO | LOG_INFO. |
LOG_WARNING | LOG_WARNING. |
LOG_ERROR | LOG_ERROR. |
LOG_CUSTOM | LOG_CUSTOM. |
Definition at line 62 of file satellite-log.h.
ns3::SatLog::SatLog | ( | ) |
Constructor.
Definition at line 57 of file satellite-log.cc.
ns3::SatLog::~SatLog | ( | ) |
Destructor.
Definition at line 64 of file satellite-log.cc.
References Reset().
void ns3::SatLog::AddToLog | ( | LogType_t | logType, |
std::string | fileTag, | ||
std::string | message | ||
) |
Function for adding a line to a specific log.
logType | log type |
fileTag | file tag for the filename |
message | line to be added |
Definition at line 149 of file satellite-log.cc.
References FindLog(), GetFileTag(), and LOG_CUSTOM.
|
private |
Function for creating a log.
logType | log type |
fileTag | file tag for the filename |
Definition at line 93 of file satellite-log.cc.
References m_container.
Referenced by FindLog().
void ns3::SatLog::DoDispose | ( | void | ) |
Do needed dispose actions.
Definition at line 72 of file satellite-log.cc.
References Reset().
|
private |
Function for finding a log based on the key.
logType | log type |
fileTag | file tag for the filename |
Definition at line 119 of file satellite-log.cc.
References CreateLog(), and m_container.
Referenced by AddToLog().
|
private |
Function for getting the file tag for predefined log types.
logType | log type |
Definition at line 169 of file satellite-log.cc.
References LOG_CUSTOM, LOG_ERROR, LOG_GENERIC, LOG_INFO, and LOG_WARNING.
Referenced by AddToLog().
TypeId ns3::SatLog::GetInstanceTypeId | ( | void | ) | const |
NS-3 instance type id function.
Definition at line 50 of file satellite-log.cc.
References GetTypeId().
|
static |
NS-3 type id function.
Definition at line 43 of file satellite-log.cc.
Referenced by GetInstanceTypeId().
void ns3::SatLog::Reset | ( | void | ) |
Function for resetting the variables.
Definition at line 80 of file satellite-log.cc.
References m_container, and WriteToFile().
Referenced by ~SatLog(), and DoDispose().
|
private |
Write the contents of a container matching to the key into a file.
Definition at line 136 of file satellite-log.cc.
References m_container.
Referenced by Reset().
|
private |
Map for containers.
Definition at line 153 of file satellite-log.h.
Referenced by CreateLog(), FindLog(), Reset(), and WriteToFile().