/*! \file log.h This is the class Log definition. \author Jon A. Lambert \date 05/02/2003 \version 0.30 \warning I'm not sure if all streams are threadsafe, therefore it would be prudent not to set up separate Logs for each subsystem. */ #ifndef LOG_H #define LOG_H /*! The Log class implements a simple logging mechanism to either a file stream, or to the cout console stream depending on whether constructed with a valid filename or empty filename (cout). Logging can be turned on and off by calling IsActive. \warning I'm not sure if all streams are threadsafe, therefore it would be prudent not to set up separate Logs for each subsystem. \todo Add different levels of logging, e.g. debug, trace, error, warning, info. Quite possibly performance instrumentation could belong in this class. */ class Log { public: Log(string& r_fname); Log(const char * fname); ~Log(); void Write(const string& r_msg); void Write(const char *fmt, ...); void SetActive(bool b); bool IsActive(); private: Log(Log&); Log& operator=(Log&); void SetTime(); string mFileName; //!< log's filename or empty if cout (console) ofstream * mpFile; //!< file stream or null if cout (console) bool mActive; //!< flag indicating if logging is on or off char mTimeStamp[40]; //!< current timestamp formatted \see SetTime CRITICAL_SECTION mMutex; //!< To enforce mutual exclusion. }; #endif // LOG_H