ionflux.org | Impressum

Reporter.hpp

Go to the documentation of this file.
00001 #ifndef IONFLUX_TOOLS_REPORTER
00002 #define IONFLUX_TOOLS_REPORTER
00003 /* ==========================================================================
00004  * Ionflux Tools
00005  * Copyright (c) 2004 Joern P. Meier
00006  * mail@ionflux.org
00007  * --------------------------------------------------------------------------
00008  * Reporter.hpp                 Console output/logging facility.
00009  * ==========================================================================
00010  * 
00011  * This file is part of Ionflux Tools.
00012  * 
00013  * Ionflux Tools is free software; you can redistribute it and/or modify it 
00014  * under the terms of the GNU General Public License as published by the Free
00015  * Software Foundation; either version 2 of the License, or (at  your option)
00016  * any later version.
00017  * 
00018  * Ionflux Tools is distributed in the hope that it will be useful, but 
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00020  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00021  * for more details.
00022  * 
00023  * You should have received a copy of the GNU General Public License
00024  * along with Ionflux Tools; if not, write to the Free Software Foundation, 
00025  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00026  * 
00027  * ========================================================================== */
00028 
00029 #include <iostream>
00030 #include <string>
00031 #include <sstream>
00032 #include <fstream>
00033 #include <iomanip>
00034 #include <time.h>
00035 #include "ionflux/tools.hpp"
00036 #include "ionflux/ByteDump.hpp"
00037 #include "ionflux/DateTime.hpp"
00038 #include "ionflux/Node.hpp"
00039 #undef assert
00040 
00041 namespace Ionflux
00042 {
00043 
00044 namespace Tools
00045 {
00046 
00047 class Node;
00048 
00066 class Reporter
00067 {
00068     protected:
00070         int verbosityLevel;
00072         int logLevel;
00074         std::string logFilePath;
00076         std::string logFilePrefix;
00078         std::string logFileSuffix;
00080         bool consoleTimestamp[2];
00082         bool logTimestamp[2];
00084         bool addLineTerm;
00086         bool disableTimestamps;
00088         ByteDump *dump;
00090         Reporter *target;
00092         bool compressLogs;
00094         DateTime lastLogTime;
00096         std::string lastLogName;
00097         
00098     public:
00100         static const std::string DEFAULT_LOGFILE_SUFFIX;
00102         static const std::string DEFAULT_LOG_PATH;
00109         static const int VL_ASSERT; 
00111         static const int VL_NONE; 
00113         static const int VL_ERROR_CRIT;
00115         static const int VL_ERROR;
00117         static const int VL_WARNING;
00119         static const int VL_WARNING_OPT;
00121         static const int VL_INFO;
00123         static const int VL_INFO_OPT;
00125         static const int VL_DEBUG;
00127         static const int VL_DEBUG_OPT;
00129         static const int VL_DEBUG_INSANE;
00131         static const int VL_ALL;
00132         
00137         Reporter();
00138         
00151         Reporter(int initVerbosityLevel, int initLogLevel, 
00152             const std::string& initLogPath, const std::string& initLogPrefix, 
00153             const std::string& initLogSuffix, bool initConsoleTimestamp[], 
00154             bool initLogTimestamp[]);
00155         
00160         virtual ~Reporter();
00161         
00168         virtual void setConfig(Node &config);
00169         
00177         virtual void setVerbosityLevel(int level);
00178         
00188         virtual int getVerbosityLevel();
00189         
00197         virtual void setLogLevel(int level);
00198         
00208         virtual int getLogLevel();
00209         
00216         virtual void setLogFilePath(const std::string &path);
00217         
00224         virtual std::string getLogFilePath();
00225         
00235         virtual void setLogFilePrefix(const std::string &prefix);
00236         
00243         virtual std::string getLogFilePrefix();
00244         
00251         virtual void setLogFileSuffix(const std::string &suffix);
00252         
00259         virtual std::string getLogFileSuffix();
00260         
00274         virtual void setTimestamps(bool console[], bool log[]);
00275         
00286         virtual void msg(const std::string& message, int level);
00287         
00301         virtual void msg(const std::string& message, int level, bool lineTerm);
00302         
00317         virtual void msg(const std::string& message, int level, bool lineTerm, 
00318             bool timeStamp);
00319         
00331         virtual bool assert(bool assertExpr, const std::string& message);
00332         
00346         static std::string createTimestamp(bool useDate, bool useTime, 
00347             const std::string& dateSep, const std::string& dateTimeSep, 
00348             const std::string& timeSep, DateTime &dt);
00349         
00357         virtual void writeLogMessage(const std::string& fileName, 
00358             const std::string& message);
00359         
00369         virtual int getLevel(const std::string& level);
00370         
00379         virtual void setAddLineTerm(bool status);
00380         
00389         virtual void redirect(Reporter *newTarget);
00390         
00400         virtual void setDump(ByteDump *newDump);
00401         
00409         virtual void setCompressLogs(bool newCompressLogs);
00410         
00416         virtual bool getCompressLogs();
00417         
00418 };
00419 
00421 
00422 }
00423 
00424 }
00425 
00429 #endif

Generated on Tue Mar 14 20:58:29 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6