#include <BCLog.h>
Definition at line 28 of file BCLog.h.
Public Types | |
enum | LogLevel { debug, detail, summary, warning, error, nothing } |
Public Member Functions | |
BCLog () | |
~BCLog () | |
Static Public Member Functions | |
static void | CloseLog () |
static int | GetHIndex () |
static BCLog::LogLevel | GetLogLevelFile () |
static BCLog::LogLevel | GetLogLevelScreen () |
static const char * | GetVersion () |
static bool | IsOpen () |
static void | OpenLog () |
static void | OpenLog (const char *filename) |
static void | OpenLog (const char *filename, BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen) |
static void | Out (const char *message) |
static void | Out (BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen, const char *message) |
static void | SetLogLevel (BCLog::LogLevel loglevel) |
static void | SetLogLevelFile (BCLog::LogLevel loglevel) |
static void | SetLogLevelScreen (BCLog::LogLevel loglevel) |
static void | StartupInfo () |
Static Private Member Functions | |
static const char * | ToString (BCLog::LogLevel) |
Static Private Attributes | |
static bool | fFirstOutputDone = false |
static int | fHindex = 0 |
static BCLog::LogLevel | fMinimumLogLevelFile = BCLog::debug |
static BCLog::LogLevel | fMinimumLogLevelScreen = BCLog::summary |
static std::ofstream | fOutputStream |
static const char * | fVersion = VERSION |
enum BCLog::LogLevel |
BCLog::BCLog | ( | ) |
void BCLog::CloseLog | ( | ) | [static] |
Closes the log file
Definition at line 90 of file BCLog.cxx.
00091 { 00092 BCLog::fOutputStream.close(); 00093 }
static int BCLog::GetHIndex | ( | ) | [inline, static] |
Definition at line 131 of file BCLog.h.
00132 { return BCLog::fHindex++; };
static BCLog::LogLevel BCLog::GetLogLevelFile | ( | ) | [inline, static] |
Returns the minimum log level for file output.
Definition at line 61 of file BCLog.h.
00062 { return fMinimumLogLevelFile; };
static BCLog::LogLevel BCLog::GetLogLevelScreen | ( | ) | [inline, static] |
Returns the minimum log level for screen output.
Definition at line 67 of file BCLog.h.
00068 { return fMinimumLogLevelScreen; };
static const char* BCLog::GetVersion | ( | ) | [inline, static] |
bool BCLog::IsOpen | ( | ) | [static] |
Definition at line 83 of file BCLog.cxx.
00084 { 00085 return BCLog::fOutputStream.is_open(); 00086 }
void BCLog::OpenLog | ( | ) | [static] |
Definition at line 76 of file BCLog.cxx.
00077 { 00078 BCLog::OpenLog("log.txt", BCLog::debug, BCLog::summary); 00079 }
void BCLog::OpenLog | ( | const char * | filename | ) | [static] |
Definition at line 69 of file BCLog.cxx.
00070 { 00071 BCLog::OpenLog(filename, BCLog::debug, BCLog::summary); 00072 }
void BCLog::OpenLog | ( | const char * | filename, | |
BCLog::LogLevel | loglevelfile, | |||
BCLog::LogLevel | loglevelscreen | |||
) | [static] |
Opens log file and sets minimum log levels for file and screen output.
filename | log filename | |
loglevelfile | minimum log level for file output | |
loglevelscreen | minimum log level for screen output |
Definition at line 46 of file BCLog.cxx.
00047 { 00048 // suppress the ROOT Info printouts 00049 gErrorIgnoreLevel=2000; 00050 00051 // open log file 00052 BCLog::fOutputStream.open(filename); 00053 00054 if (!BCLog::fOutputStream.is_open()) 00055 { 00056 std::cerr << " Could not open log file " << filename << ". " << std::endl; 00057 return; 00058 } 00059 00060 // set log level 00061 BCLog::SetLogLevelFile(loglevelfile); 00062 BCLog::SetLogLevelScreen(loglevelscreen); 00063 00064 BCLog::Out(BCLog::summary,BCLog::summary,Form("Opening logfile %s",filename)); 00065 }
void BCLog::Out | ( | const char * | message | ) | [static] |
Definition at line 118 of file BCLog.cxx.
00119 { 00120 BCLog::Out(BCLog::fMinimumLogLevelFile, BCLog::fMinimumLogLevelScreen, message); 00121 }
void BCLog::Out | ( | BCLog::LogLevel | loglevelfile, | |
BCLog::LogLevel | loglevelscreen, | |||
const char * | message | |||
) | [static] |
Definition at line 97 of file BCLog.cxx.
00098 { 00099 // if this is the first call to Out(), call StartupInfo() first 00100 if(!fFirstOutputDone) 00101 BCLog::StartupInfo(); 00102 00103 // open log file if not opened 00104 if (BCLog::IsOpen()) 00105 { 00106 // write message in to log file 00107 if (loglevelfile >= BCLog::fMinimumLogLevelFile) 00108 BCLog::fOutputStream << BCLog::ToString(loglevelfile) << " : " << message << std::endl; 00109 } 00110 00111 // write message to screen 00112 if (loglevelscreen >= BCLog::fMinimumLogLevelScreen) 00113 std::cout << BCLog::ToString(loglevelscreen) << " : " << message << std::endl; 00114 }
static void BCLog::SetLogLevel | ( | BCLog::LogLevel | loglevel | ) | [inline, static] |
Sets the minimum log level for file and screen output.
loglevel | log level |
Definition at line 87 of file BCLog.h.
00088 { BCLog::fMinimumLogLevelFile = loglevel; BCLog::fMinimumLogLevelScreen = loglevel; };
static void BCLog::SetLogLevelFile | ( | BCLog::LogLevel | loglevel | ) | [inline, static] |
Sets the minimum log level for file output.
loglevel | log level |
Definition at line 75 of file BCLog.h.
00076 { BCLog::fMinimumLogLevelFile = loglevel; };
static void BCLog::SetLogLevelScreen | ( | BCLog::LogLevel | loglevel | ) | [inline, static] |
Sets the minimum log level for screen output.
loglevel | log level |
Definition at line 81 of file BCLog.h.
00082 { BCLog::fMinimumLogLevelScreen = loglevel; };
void BCLog::StartupInfo | ( | ) | [static] |
Writes startup information onto screen and into a logfile
Definition at line 125 of file BCLog.cxx.
00126 { 00127 char * message = Form( 00128 " +------------------------------\n" 00129 " |\n" 00130 " | Running with BAT\n" 00131 " | Version %s\n" 00132 " |\n" 00133 " | http://www.mppmu.mpg.de/bat\n" 00134 " +------------------------------\n", 00135 BCLog::fVersion); 00136 00137 if (BCLog::IsOpen() && BCLog::fMinimumLogLevelFile<BCLog::nothing) 00138 BCLog::fOutputStream << message; 00139 00140 if (BCLog::fMinimumLogLevelScreen<BCLog::nothing) 00141 std::cout << message; 00142 00143 fFirstOutputDone = true; 00144 }
const char * BCLog::ToString | ( | BCLog::LogLevel | loglevel | ) | [static, private] |
Converts a log level to a string
Definition at line 148 of file BCLog.cxx.
00149 { 00150 00151 switch (loglevel) 00152 { 00153 case debug: 00154 return "Debug "; 00155 case detail: 00156 return "Detail "; 00157 case summary: 00158 return "Summary"; 00159 case warning: 00160 return "Warning"; 00161 case error: 00162 return "Error "; 00163 default: 00164 return ""; 00165 } 00166 00167 }
bool BCLog::fFirstOutputDone = false [static, private] |
int BCLog::fHindex = 0 [static, private] |
BCLog::LogLevel BCLog::fMinimumLogLevelFile = BCLog::debug [static, private] |
BCLog::LogLevel BCLog::fMinimumLogLevelScreen = BCLog::summary [static, private] |
std::ofstream BCLog::fOutputStream [static, private] |
const char * BCLog::fVersion = VERSION [static, private] |