GLIMSView Source Code Documentation

TraceLog Class Reference

#include <TraceLog.h>

List of all members.


Detailed Description

TraceLog is a simple debugging tool which allows the programmer to write messages to glimsview_log.txt.

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("") ;

Author:
Deborah Lee Soltesz
History:
2005-05-13 Created new TraceLog class
History:
2005-07-14 New function for storing strings
History:
2005-07-14 Added new functions for printing log as messages come in, with or without storing messages in memory

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

Constructor & Destructor Documentation

TraceLog::TraceLog (  )  [inline]

Definition at line 62 of file TraceLog.h.

References lastPrint, lasttime, and timing.

virtual TraceLog::~TraceLog (  )  [inline, virtual]

Definition at line 75 of file TraceLog.h.

References writeLog().

Here is the call graph for this function:


Member Function Documentation

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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]

Write the latest messages to the file.

Definition at line 148 of file TraceLog.h.

References lastPrint, logFile, and messages.

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().


Member Data Documentation

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]

Definition at line 56 of file TraceLog.h.

Referenced by writeLog(), and writeLogNow().

int TraceLog::lastPrint [protected]

Definition at line 57 of file TraceLog.h.

Referenced by TraceLog(), and writeLogNow().

time_t TraceLog::lasttime [protected]

Definition at line 58 of file TraceLog.h.

Referenced by log(), and TraceLog().

bool TraceLog::timing [protected]

Definition at line 59 of file TraceLog.h.

Referenced by log(), and TraceLog().


The documentation for this class was generated from the following file:

Home | Search | Disclaimers & Privacy | Contact Us
GLIMSView Maintainer: dsoltesz@usgs.gov