My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
gcp::util::LogFile Class Reference

Public Member Functions

 LogFile ()
 
virtual ~LogFile ()
 
void setDirectory (const std::string &dir)
 
void setPrefix (const std::string &prefix)
 
void setDatePrefix ()
 
void open ()
 
void close ()
 
void flush ()
 
bool fileExists (std::string fileName)
 
std::string newFileName ()
 
void prepend (std::string message)
 
void append (std::string message, bool fullTime=false)
 
LogFilelogFile ()
 

Constructor & Destructor Documentation

LogFile::LogFile ( )

Constructor.

....................................................................... Constructor.

LogFile::~LogFile ( )
virtual

Destructor.

....................................................................... Destructor.

Member Function Documentation

void LogFile::append ( std::string  message,
bool  fullTime = false 
)

Public method to write a string to our log file

....................................................................... Write to a log file

A subtlety here is that we want to write timestamps for every line, but don't necessarily want to write a time stamp every time characters get written to the file. For instance, if the data originate from a terminal interface, a serial interface may return a prompt, and a newline will only be delivered when the user hits newline after typing something.

This routine fills a char buffer intended for writing to the logfile, but only writes it when a newline is encountered, OR when the buffer would otherwise overflow. Thus, a timestamp will in general correspond to when a newline was delivered, and only in exceptional cases, to when a buffer overflow occurred.

void LogFile::close ( )

Close a logfile

....................................................................... Close a logfile

bool LogFile::fileExists ( std::string  fileName)

Return true if a file exists

....................................................................... Return true if a file exists

void LogFile::flush ( )

....................................................................... Flush a logfile

LogFile& gcp::util::LogFile::logFile ( )

Return a reference to our logFile object

std::string LogFile::newFileName ( )

....................................................................... Create a unique file name based on the prefix and files already in the log directory

void LogFile::open ( )

Open a logfile

....................................................................... Open a logfile

void LogFile::prepend ( std::string  message)

Public method to write a string to our log file

void LogFile::setDatePrefix ( )

Create a date_based name for this file

....................................................................... Tell this class to create names based on the date

void LogFile::setDirectory ( const std::string &  directory)

Set the destination directory for logfiles created by this object.

....................................................................... Set the destination directory for logfiles created by this object.

void LogFile::setPrefix ( const std::string &  prefix)

Set the prefix for logfiles created by this object.

....................................................................... Set the prefix for logfiles created by this object.


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