gpucalc::Log Class Reference

Class provides writing information to log file and standart error output. More...

#include <log.h>

Inheritance diagram for gpucalc::Log:

Inheritance graph

List of all members.

Public Member Functions

void addListener (LogListener *listener)
 Register a listener to this log.
const std::string & getClassName () const
 Returns name of class of our object.
LoggingLevel getLogDetail () const
 Gets the level of the log detail.
LoggingLevel getLogDetail ()
const std::string & getObjectName () const
 Returns name of our object.
void getSpecificParameter (const std::string &ParameterName, void *ParameterValue)
 Method for obtaining some specific parameters, such as texture specific params, and so on.
bool isDebugOutputEnabled () const
 Get whether debug output is enabled for this log.
bool isFileOutputSuppressed () const
 Get whether file output is suppressed for this log.
bool isLocked () const
 returns state of object.
 Log (const std::string &LogName, unsigned int LogClassNameAlignment=15, unsigned int LogObjectNameAlignment=20, bool DebugOutput=true, bool SuppressFileOutput=false, bool SuppressObjectInfo=false)
void logMessage (const Object *object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false)
void logMessage (const Object &object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false)
 Log a message to the debugger and to log file (the default is "<code>gpucalc.log</code>").
void removeListener (LogListener *listener)
 Unregister a listener from this log.
void setDebugOutputEnabled (bool debugOutput)
 Enable or disable outputting log messages to the debugger.
void setLogDetail (LoggingLevel ll)
 Sets the level of the log detail.
void setTimeOutputEnabled (bool TimeOutput)
 ~Log ()

Protected Member Functions

void addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size)
void lock ()
void unlock ()

Private Types

typedef std::list< LogListener * > mtLogListener

Private Member Functions

void logMessage (const std::string &message, LogMessageLevel lml=LML_Normal, bool maskDebug=false)

Private Attributes

bool mDebugOutput
std::ofstream mfpLog
mtLogListener mListeners
unsigned int mLogClassNameAlignment
LoggingLevel mLogLevel
unsigned int mLogObjectNameAlignment
bool mSuppressFile
bool mSuppressObjectInfo
bool mTimeOutput


Detailed Description

Class provides writing information to log file and standart error output.

Definition at line 104 of file log.h.


Member Typedef Documentation

typedef std::list<LogListener *> gpucalc::Log::mtLogListener [private]

Definition at line 206 of file log.h.


Constructor & Destructor Documentation

gpucalc::Log::Log ( const std::string &  LogName,
unsigned int  LogClassNameAlignment = 15,
unsigned int  LogObjectNameAlignment = 20,
bool  DebugOutput = true,
bool  SuppressFileOutput = false,
bool  SuppressObjectInfo = false 
)

Definition at line 42 of file log.cpp.

00043                                                                      :
00044   Object(_LogClassName, LogName), mLogLevel(LL_Normal), mDebugOutput(DebugOutput), mSuppressFile(SuppressFileOutput),
00045   mSuppressObjectInfo(SuppressObjectInfo), mTimeOutput(true), mLogClassNameAlignment(LogClassNameAlignment), mLogObjectNameAlignment(LogObjectNameAlignment)
00046  {
00047   if (!mSuppressFile)
00048   {
00049    mfpLog.open(LogName.c_str());
00050   }
00051  }

gpucalc::Log::~Log (  ) 

Definition at line 54 of file log.cpp.

00055  {
00056   if (!mSuppressFile)
00057   {
00058    mfpLog.close();
00059   }
00060  }


Member Function Documentation

void gpucalc::Log::addListener ( LogListener listener  ) 

Register a listener to this log.

Parameters:
listener - A valid listener derived class.

Definition at line 123 of file log.cpp.

00124  {
00125   mListeners.push_back(listener);
00126  }

void gpucalc::Object::addSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue,
size_t  Size 
) [inline, protected, inherited]

Definition at line 254 of file object.h.

00255    {
00256     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00257     if (i != mSpecificParameters.end())
00258     {
00259      mSpecificParameters.erase(i);
00260     }
00261     mSpecificParameters[ParameterName] = Any(ParameterValue, Size);
00262    }

const std::string& gpucalc::Object::getClassName (  )  const [inline, inherited]

Returns name of class of our object.

Definition at line 92 of file object.h.

00093    {
00094     return mClassName;
00095    }

LoggingLevel gpucalc::Log::getLogDetail (  )  const [inline]

Gets the level of the log detail.

Definition at line 176 of file log.h.

00177    {
00178     return mLogLevel;
00179    }

LoggingLevel gpucalc::Log::getLogDetail (  )  [inline]

Definition at line 167 of file log.h.

00168    {
00169     return mLogLevel;
00170    }

const std::string& gpucalc::Object::getObjectName (  )  const [inline, inherited]

Returns name of our object.

Definition at line 101 of file object.h.

00102    {
00103     return mObjectName;
00104    }

void gpucalc::Object::getSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue 
) [inline, inherited]

Method for obtaining some specific parameters, such as texture specific params, and so on.

Parameters:
ParameterName - name of parameter, usually it similar to specific method of some object (for example, GLTextureID)
ParameterValue - contain value of named parameter, it must be allocated and have sufficient size.
Todo:
Think for better realization.

Definition at line 128 of file object.h.

00129    {
00130     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00131     if (i != mSpecificParameters.end())
00132     {
00133      i->second.copyValue(ParameterValue);
00134     }
00135     else
00136     {
00137      Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__);
00138     }
00139    }

bool gpucalc::Log::isDebugOutputEnabled (  )  const [inline]

Get whether debug output is enabled for this log.

Definition at line 128 of file log.h.

00129    {
00130     return mDebugOutput;
00131    }

bool gpucalc::Log::isFileOutputSuppressed (  )  const [inline]

Get whether file output is suppressed for this log.

Definition at line 137 of file log.h.

00138    {
00139     return mSuppressFile;
00140    }

bool gpucalc::Object::isLocked (  )  const [inline, inherited]

returns state of object.

If object is locked then we cannot change some state of it, because object is used in computation. If object is unlocked then we can change some state of it, object is not in computation.

Definition at line 113 of file object.h.

00114    {
00115     return mIsLocked;
00116    }

void gpucalc::Object::lock (  )  [inline, protected, inherited]

Definition at line 265 of file object.h.

00266    {
00267     mIsLocked = true;
00268    }

void gpucalc::Log::logMessage ( const std::string &  message,
LogMessageLevel  lml = LML_Normal,
bool  maskDebug = false 
) [private]

Definition at line 63 of file log.cpp.

00064  {
00065   for (mtLogListener::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
00066   {
00067    (*i)->MessageLogged(message, lml, maskDebug, this->getObjectName());
00068   }
00069   if (mDebugOutput && !maskDebug)
00070   {
00071    std::cerr << message << std::endl;
00072   }
00073   if (!mSuppressFile)
00074   {
00075    struct tm *pTime;
00076    time_t ctTime;
00077    time(&ctTime);
00078    pTime = localtime(&ctTime);
00079 
00080    if (mTimeOutput)
00081    {
00082     mfpLog << std::setw(2) << std::setfill('0') << pTime->tm_hour
00083      << ":" << std::setw(2) << std::setfill('0') << pTime->tm_min
00084      << ":" << std::setw(2) << std::setfill('0') << pTime->tm_sec
00085      << ": ";
00086    }
00087    mfpLog  << message << std::endl;
00088     
00089    mfpLog.flush();
00090   }
00091  }

void gpucalc::Log::logMessage ( const Object object,
const std::string &  Message,
LogMessageLevel  lml = LML_Normal,
bool  maskDebug = false 
)

Definition at line 115 of file log.cpp.

00117  {
00118   assert(object && "Cannot log noninitialized object!!!");
00119   logMessage(*object, Message, lml, maskDebug);
00120  }

void gpucalc::Log::logMessage ( const Object object,
const std::string &  Message,
LogMessageLevel  lml = LML_Normal,
bool  maskDebug = false 
)

Log a message to the debugger and to log file (the default is "<code>gpucalc.log</code>").

Definition at line 94 of file log.cpp.

00096  {
00097   if ((mLogLevel + lml) >= Log_Threshold)
00098   {
00099    if (!mSuppressObjectInfo)
00100    {
00101     logMessage(
00102                         auxillary::StringUtil::getFixedString(object.getClassName(), mLogClassNameAlignment, "", ":") +
00103                         auxillary::StringUtil::getFixedString(object.getObjectName(), mLogObjectNameAlignment, "", ":") +
00104                         Message, lml, maskDebug
00105                           );
00106    }
00107    else
00108    {
00109     logMessage(Message, lml, maskDebug);
00110    }
00111   }
00112  }

void gpucalc::Log::removeListener ( LogListener listener  ) 

Unregister a listener from this log.

Parameters:
listener - A valid listener derived class.

Definition at line 129 of file log.cpp.

00130  {
00131   mListeners.erase(std::find(mListeners.begin(), mListeners.end(), listener));
00132  }

void gpucalc::Log::setDebugOutputEnabled ( bool  debugOutput  )  [inline]

Enable or disable outputting log messages to the debugger.

Definition at line 146 of file log.h.

00147    {
00148     mDebugOutput = debugOutput;
00149    }

void gpucalc::Log::setLogDetail ( LoggingLevel  ll  )  [inline]

Sets the level of the log detail.

Definition at line 155 of file log.h.

00156    {
00157     mLogLevel = ll;
00158    }

void gpucalc::Log::setTimeOutputEnabled ( bool  TimeOutput  )  [inline]

Definition at line 161 of file log.h.

00162    {
00163     mTimeOutput = TimeOutput;
00164    }

void gpucalc::Object::unlock (  )  [inline, protected, inherited]

Definition at line 271 of file object.h.

00272    {
00273     mIsLocked = false;
00274    }


Member Data Documentation

Definition at line 199 of file log.h.

std::ofstream gpucalc::Log::mfpLog [private]

Definition at line 197 of file log.h.

Definition at line 207 of file log.h.

unsigned int gpucalc::Log::mLogClassNameAlignment [private]

Definition at line 203 of file log.h.

Definition at line 198 of file log.h.

unsigned int gpucalc::Log::mLogObjectNameAlignment [private]

Definition at line 204 of file log.h.

Definition at line 200 of file log.h.

Definition at line 201 of file log.h.

bool gpucalc::Log::mTimeOutput [private]

Definition at line 202 of file log.h.


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

Generated on Thu Mar 5 22:36:45 2009 for gpucalc by  doxygen 1.5.6