BCLog.h

Go to the documentation of this file.
00001 #ifndef __BCLOG__H
00002 #define __BCLOG__H
00003 
00015 /*
00016  * Copyright (C) 2008, Daniel Kollar and Kevin Kroeninger.
00017  * All rights reserved.
00018  *
00019  * For the licensing terms see doc/COPYING.
00020  */
00021 
00022 // ---------------------------------------------------------
00023 
00024 #include <iostream>
00025 
00026 // ---------------------------------------------------------
00027 
00028 class BCLog
00029 {
00030    public:
00031 
00032       // definition of log level
00033 
00044       enum LogLevel {debug, detail, summary, warning, error, nothing};
00045 
00046       // constructor and destructor
00047 
00050       BCLog();
00051 
00054       ~BCLog();
00055 
00056       // methods (get)
00057 
00061       static BCLog::LogLevel GetLogLevelFile()
00062          { return fMinimumLogLevelFile; };
00063 
00067       static BCLog::LogLevel GetLogLevelScreen()
00068          { return fMinimumLogLevelScreen; };
00069 
00070       // method (set)
00071 
00075       static void SetLogLevelFile(BCLog::LogLevel loglevel)
00076          { BCLog::fMinimumLogLevelFile = loglevel; };
00077 
00081       static void SetLogLevelScreen(BCLog::LogLevel loglevel)
00082          { BCLog::fMinimumLogLevelScreen = loglevel; };
00083 
00087       static void SetLogLevel(BCLog::LogLevel loglevel)
00088          { BCLog::fMinimumLogLevelFile = loglevel; BCLog::fMinimumLogLevelScreen = loglevel; };
00089 
00090       // methods
00091 
00097       static void OpenLog(const char * filename, BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen);
00098 
00099       static void OpenLog(const char * filename);
00100 
00101       static void OpenLog();
00102 
00105       static bool IsOpen();
00106 
00109       static void CloseLog();
00110 
00111       /*
00112        * Writes string to the file and screen log if the log level is equal or greater than the minimum
00113        * @param loglevelfile loglevel for the current message
00114        * @param loglevelscreen loglevel for the current message
00115        * @param message string to write to the file and screen log */
00116       static void Out(BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen, const char * message);
00117 
00118       static void Out(const char * message);
00119 
00120       static void Out(BCLog::LogLevel loglevel, const char * message)
00121          { Out(loglevel,loglevel,message); };
00122 
00123       static void OutError(const char * message)
00124          { Out(error,message); };
00125 
00126       static void OutWarning(const char * message)
00127          { Out(warning,message); };
00128 
00129       static void OutSummary(const char * message)
00130          { Out(summary,message); };
00131 
00132       static void OutDetail(const char * message)
00133          { Out(detail,message); };
00134 
00135       static void OutDebug(const char * message)
00136          { Out(debug,message); };
00137 
00140       static void StartupInfo();
00141 
00144       static const char * GetVersion()
00145          { return fVersion; };
00146 
00149       static int GetHIndex()
00150          { return BCLog::fHindex++; };
00151 
00152    private:
00153 
00156       static const char * fVersion;
00157 
00160       static BCLog::LogLevel fMinimumLogLevelFile;
00161 
00164       static BCLog::LogLevel fMinimumLogLevelScreen;
00165 
00168       static std::ofstream fOutputStream;
00169 
00172       static bool fFirstOutputDone;
00173 
00176       static const char * ToString(BCLog::LogLevel);
00177 
00180       static int fHindex;
00181 };
00182 
00183 // ---------------------------------------------------------
00184 
00185 #endif

Generated on Thu Feb 11 11:29:30 2010 for BayesianAnalysisToolkit by  doxygen 1.5.1