#include <TraceLog.h>
Messages are stored during runtime and written to the file when the GLIMSView application exits. Disabling this functionality is done simply by commenting out the code in this class that opens the file and stores messages for writing to the file. The TraceLog object, glimslog, is instantiated near main in the maintoolbar.cpp file. To use this object, include the TraceLog.h file, declare extern TraceLog glimslog in the function that will send it messages, and use glimslog.log(char * msg) or glimslog.log(string msg) to add a new message to the queue.
example of usage to print some information plus the of x to the log:
extern TraceLog glimslog ; std::stringstream logstream ; logstream << "Message text " << x << endl ; glimslog.log( logstream.str() ) ; logstream.str("") ;
Definition at line 53 of file TraceLog.h.
Public Member Functions | |
TraceLog () | |
virtual | ~TraceLog () |
void | log (char *msg) |
Add a message to the list of messages to be written to the log file when the application exits. | |
void | log (string msg) |
Add a message to the list of messages to be written to the log file when the application exits. | |
void | writeLog () |
Write the messages to the file and close the file. | |
void | writeLogNow () |
Write the latest messages to the file. | |
void | writeLogRightNow (string msg) |
Write the messages to the file without saving history in memory. | |
Protected Attributes | |
fstream | logFile |
std::vector< string > | messages |
int | lastPrint |
time_t | lasttime |
bool | timing |
TraceLog::TraceLog | ( | ) | [inline] |
virtual TraceLog::~TraceLog | ( | ) | [inline, virtual] |
Definition at line 75 of file TraceLog.h.
References writeLog().
void TraceLog::log | ( | char * | msg | ) | [inline] |
Add a message to the list of messages to be written to the log file when the application exits.
Definition at line 83 of file TraceLog.h.
References lasttime, logFile, timing, and writeLogRightNow().
void TraceLog::log | ( | string | msg | ) | [inline] |
Add a message to the list of messages to be written to the log file when the application exits.
Definition at line 109 of file TraceLog.h.
References lasttime, logFile, timing, and writeLogRightNow().
void TraceLog::writeLog | ( | ) | [inline] |
Write the messages to the file and close the file.
Definition at line 134 of file TraceLog.h.
References logFile, and messages.
Referenced by ~TraceLog().
void TraceLog::writeLogNow | ( | ) | [inline] |
void TraceLog::writeLogRightNow | ( | string | msg | ) | [inline] |
Write the messages to the file without saving history in memory.
Definition at line 162 of file TraceLog.h.
References logFile.
Referenced by log().
fstream TraceLog::logFile [protected] |
Definition at line 55 of file TraceLog.h.
Referenced by log(), writeLog(), writeLogNow(), and writeLogRightNow().
std::vector<string> TraceLog::messages [protected] |
int TraceLog::lastPrint [protected] |
time_t TraceLog::lasttime [protected] |
bool TraceLog::timing [protected] |
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |