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 | |
| typedef std::pair< LogType_t, std::string > | key_t |
| typedef for container key | |
| 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. | |
| ~SatLog () | |
| Destructor. | |
| void | AddToLog (LogType_t logType, std::string fileTag, std::string message) |
| Function for adding a line to a specific log. | |
| void | DoDispose () |
| Do needed dispose actions. | |
| void | Reset () |
| Function for resetting the variables. | |
Static Public Member Functions | |
| static TypeId | GetTypeId (void) |
| NS-3 type id function. | |
Private Member Functions | |
| Ptr< SatOutputFileStreamStringContainer > | CreateLog (LogType_t logType, std::string fileTag) |
| Function for creating a log. | |
| Ptr< SatOutputFileStreamStringContainer > | FindLog (LogType_t logType, std::string fileTag) |
| Function for finding a log based on the key. | |
| std::string | GetFileTag (LogType_t logType) |
| Function for getting the file tag for predefined log types. | |
| void | WriteToFile () |
| Write the contents of a container matching to the key into a file. | |
Private Attributes | |
| container_t | m_container |
| Map for containers. | |
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 49 of file satellite-log.cc.
| ns3::SatLog::~SatLog | ( | ) |
Destructor.
Definition at line 54 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 139 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 83 of file satellite-log.cc.
References ns3::SatEnvVariables::GetInstance(), and m_container.
Referenced by FindLog().
| void ns3::SatLog::DoDispose | ( | ) |
Do needed dispose actions.
Definition at line 62 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 109 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 159 of file satellite-log.cc.
References LOG_CUSTOM, LOG_ERROR, LOG_GENERIC, LOG_INFO, and LOG_WARNING.
Referenced by AddToLog().
|
static |
| void ns3::SatLog::Reset | ( | ) |
Function for resetting the variables.
Definition at line 70 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 126 of file satellite-log.cc.
References m_container.
Referenced by Reset().
|
private |
Map for containers.
Definition at line 147 of file satellite-log.h.
Referenced by CreateLog(), FindLog(), Reset(), and WriteToFile().