Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

log.hpp

Go to the documentation of this file.
00001 // PTF - Psychological Test Framework 00002 // http://ptf.sourceforge.net 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Library General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 #ifndef __LOG__ 00019 #define __LOG__ 00020 00021 #define WARNING(msg) "\e[33;1mWARNING\e[0m: " msg 00022 #define MESSAGE(msg) "\e[32;1mMESSAGE\e[0m: " msg 00023 #define ERROR(msg) "\e[31;1mERROR \e[0m: " msg 00024 00025 #include <cc++/thread.h> 00026 #include <ptf/environment/clock.hpp> 00027 #include <string> 00028 #include <sstream> 00029 00030 using ost::Mutex; 00031 using std::stringstream; 00032 using std::string; 00033 00037 class Log { 00038 public: 00039 Log(); 00040 Log(bool); 00041 ~Log(); 00042 bool getSilent(); 00043 void setSilent(bool); 00044 Log& operator<<(const string&); 00045 Log& operator<<(const char*); 00046 Log& operator<<(const int&); 00047 Log& operator<<(const float&); 00048 Log& operator<<(const double&); 00049 Log& operator<<(const timespec&); 00050 void saveToFile(const char*); 00051 protected: 00052 Mutex mutex; 00053 stringstream sstream; 00054 bool silent; 00055 }; 00056 00057 #endif

Generated on Fri Dec 17 14:54:23 2004 for Psychological Test Framework by doxygen 1.3.8