00001 00012 /* 00013 * Copyright (C) 2008, Daniel Kollar and Kevin Kroeninger. 00014 * All rights reserved. 00015 * 00016 * For the licensing terms see doc/COPYING. 00017 */ 00018 00019 // --------------------------------------------------------- 00020 00021 #ifndef __BCLOG__H 00022 #define __BCLOG__H 00023 00024 #include <iostream> 00025 #include <fstream> 00026 00027 #include <TROOT.h> 00028 #include <TError.h> 00029 00030 #include "BCReleaseVersion.h" 00031 00032 // --------------------------------------------------------- 00033 00034 class BCLog 00035 { 00036 00037 public: 00038 00039 // definition of log level 00040 00050 enum LogLevel {debug, detail, summary, warning, nothing}; 00051 00052 // constructor and destructor 00053 00057 BCLog(); 00058 00062 ~BCLog(); 00063 00064 // methods (get) 00065 00070 static BCLog::LogLevel GetMinimumLogLevelFile() 00071 { return fMinimumLogLevelFile; }; 00072 00077 static BCLog::LogLevel GetMinimumLogLevelScreen() 00078 { return fMinimumLogLevelScreen; }; 00079 00080 // method (set) 00081 00086 static void SetMinimumLogLevelFile(BCLog::LogLevel loglevel) 00087 { BCLog::fMinimumLogLevelFile = loglevel; }; 00088 00093 static void SetMinimumLogLevelScreen(BCLog::LogLevel loglevel) 00094 { BCLog::fMinimumLogLevelScreen = loglevel; }; 00095 00096 // methods 00097 00104 static void OpenLog(const char * filename, BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen); 00105 00106 static void OpenLog(const char * filename); 00107 00108 static void OpenLog(); 00109 00113 static void CloseLog(); 00114 00115 /* 00116 * Writes string to the file and screen log if the log level is equal or greater than the minimum 00117 * @param loglevelfile The loglevel for the current message 00118 * @param loglevelscreen The loglevel for the current message 00119 * @param message The string to write to the file and screen log 00120 */ 00121 static void Out(BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen, const char * message); 00122 00123 static void Out(const char * message); 00124 00128 static void StartupInfo(); 00129 00133 static const char * GetVersion() 00134 { return fVersion; }; 00135 00139 static int GetHIndex() 00140 { return BCLog::fHindex++; }; 00141 00142 private: 00143 00147 static const char * fVersion; 00148 00152 static BCLog::LogLevel fMinimumLogLevelFile; 00153 00157 static BCLog::LogLevel fMinimumLogLevelScreen; 00158 00162 static std::ofstream fOutputStream; 00163 00167 static const char * ToString(BCLog::LogLevel); 00168 00172 static int fHindex; 00173 00174 }; 00175 00176 // --------------------------------------------------------- 00177 00178 #endif