#include <ResultLog.h>
Public Member Functions | |
ResultLog (const std::string &fileName=std::string(""), const bool html=false) | |
Constructor. | |
~ResultLog () | |
Destructor. | |
void | reportLine (const char *line,...) |
Dumps a line of result to the log. | |
void | report (const char *col1, const char *col2, const char *col3,...) |
Dumps a line of result using a 3-column table format. | |
void | startTable (const char *titles[]=NULL) |
Starts an HTML table if necessary. | |
void | endTable () |
Ends an HTML table if necessary. | |
Protected Member Functions | |
void | dumpHTMLHeaders () |
Helper method to dump HTML headers. | |
Private Member Functions | |
ResultLog & | operator= (const ResultLog &src) |
A dummy operator=. | |
Private Attributes | |
FILE * | output |
The file to which results are to be logged. | |
const bool | html |
Flag to indicate if HTML format is being used. | |
bool | insideTable |
Flag to indicate if a HTML table is currently open. |
Definition at line 40 of file ResultLog.h.
ResultLog::ResultLog | ( | const std::string & | fileName = std::string("") , |
|
const bool | html = false | |||
) |
Constructor.
The constructor establishes a ResultLog. The result outputs are written to standard output or a file in plain text or HTML format.
[in] | fileName | The output/destination file to which logs are to be cut. If this parameter is NULL then data is written to standard output. |
[in] | html | If this parameter is true then logs are written in HTML format so that they can be easily viewed in via a browser. |
Definition at line 43 of file ResultLog.cpp.
References dumpHTMLHeaders(), and output.
ResultLog::~ResultLog | ( | ) |
Destructor.
Winds up the process of generating a log. If HTML logs are being generated then it generates trailers to wind up HTML formats. If a file was opened then the destructor closes the destination file.
Definition at line 123 of file ResultLog.cpp.
References _fileno, endTable(), html, HTML_FOOTER, and output.
void ResultLog::dumpHTMLHeaders | ( | ) | [protected] |
Helper method to dump HTML headers.
This method is a helper method that is invoked from the constructor to dump HTML headers.
Definition at line 137 of file ResultLog.cpp.
References html, HTML_HEADER, and output.
Referenced by ResultLog().
void ResultLog::endTable | ( | ) |
Ends an HTML table if necessary.
This method generates HTML code to end a HTML table. This method peforms all the checks for handling HTML mode and generates headers only if it is needed. Consequently, it is safe to call this method repeatedly without much performance penalty.
Definition at line 171 of file ResultLog.cpp.
References html, insideTable, and output.
Referenced by FWAnalyzer::dumpHeader(), reportLine(), and ~ResultLog().
A dummy operator=.
The operator=() is supressed for this class as it has constant members whose value is set when the object is created. These values cannot be changed during the lifetime of this object.
[in] | src | The source object from where data is to be copied. Currently this value is ignored. |
Definition at line 184 of file ResultLog.cpp.
void ResultLog::report | ( | const char * | col1, | |
const char * | col2, | |||
const char * | col3, | |||
... | ||||
) |
Dumps a line of result using a 3-column table format.
This method provides a convenient mechanism to dump a line of output in 3-column format to the specified destination. If no destination is specified it dumps the line to standard output. This method also handles the task of including necessary html tags if HTML output is requested.
[in] | col1 | The data to be displayed in the first column. This text can take the standard format as the printf() method thereby facilitating dumping of complex output in a simple manner. |
[in] | col2 | The data to be displayed in the second column. This text can take the standard format as the printf() method thereby facilitating dumping of complex output in a simple manner. |
[in] | col3 | The data to be displayed in the third column. This text can take the standard format as the printf() method thereby facilitating dumping of complex output in a simple manner. |
ResultLog log("test.html", true); log.report("%s", "%c %d", "%ld", "test", '*', 123, 3.142);
Definition at line 94 of file ResultLog.cpp.
References html, output, startTable(), and vsnprintf_s.
Referenced by FWAnalyzer::dumpEST(), CLU::dumpEST(), and FWAnalyzer::dumpHeader().
void ResultLog::reportLine | ( | const char * | line, | |
... | ||||
) |
Dumps a line of result to the log.
This method provides a convenient mechanism to dump a line of output to the specified destination. If no destination is specified it dumps the line to standard output. This method also handles the task of including necessary html tags if HTML output is requested.
[in] | line | The line of text to be displayed. This line can take the standard format as the printf() method thereby facilitating dumping of complex output in a simple manner. |
Definition at line 74 of file ResultLog.cpp.
References endTable(), html, output, and vsnprintf_s.
Referenced by FWAnalyzer::dumpHeader().
void ResultLog::startTable | ( | const char * | titles[] = NULL |
) |
Starts an HTML table if necessary.
This method generates HTML code to start a table. This method peforms all the checks for handling HTML mode and generates headers only if it is needed. Consequently, it is safe to call this method repeatedly without much performance penalty.
[in] | titles | The titles for the rows to be used when creating the table. If this parameter is NULL, then no titles are included for the table. |
Definition at line 146 of file ResultLog.cpp.
References html, insideTable, and output.
Referenced by FWAnalyzer::dumpESTList(), and report().
const bool ResultLog::html [private] |
Flag to indicate if HTML format is being used.
This instance variable is used to determine if the logs are to be generated in HTML format or not. This value is set in the constructor and is never changed during the life time of this class.
Definition at line 168 of file ResultLog.h.
Referenced by dumpHTMLHeaders(), endTable(), report(), reportLine(), startTable(), and ~ResultLog().
bool ResultLog::insideTable [private] |
Flag to indicate if a HTML table is currently open.
This flag is initialized to false. It is set to true each time a HTML table is started. It is reset to false when the table is ended. This flag is used in the polymorphic report() methods in this class to appropriately handle HTML tables.
Definition at line 177 of file ResultLog.h.
Referenced by endTable(), and startTable().
FILE* ResultLog::output [private] |
The file to which results are to be logged.
This member object holds the file to which results are to be logged. This pointer is initialized in the constructor to either point to a result file or standard output.
Definition at line 159 of file ResultLog.h.
Referenced by dumpHTMLHeaders(), endTable(), report(), reportLine(), ResultLog(), startTable(), and ~ResultLog().