Belle II Software  release-05-02-19
LogFile.h
1 #ifndef _Belle2_LogFile_h
2 #define _Belle2_LogFile_h
3 
4 #include <daq/slc/system/Mutex.h>
5 
6 #include <daq/slc/base/Date.h>
7 
8 #include <string>
9 #include <fstream>
10 #include <stdarg.h>
11 
12 namespace Belle2 {
18  struct LogFile {
19 
20  public:
21  enum Priority {
22  UNKNOWN = 0, DEBUG, INFO, NOTICE, WARNING, ERROR, FATAL
23  };
24 
25  public:
26  static Priority getPriority(const std::string& str);
27 
28  private:
29  LogFile() {}
30  ~LogFile() {}
31 
32  private:
33  static bool g_stderr;
34  static bool g_opened;
35  static std::string g_filepath;
36  static std::string g_linkpath;
37  static std::ofstream g_stream;
38  static unsigned int g_filesize;
39  static Mutex g_mutex;
40  static Priority g_threshold;
41  static std::string g_filename;
42  static Date g_date;
43 
44  // member functions
45  public:
46  static void open(const std::string& filename,
47  Priority priority = UNKNOWN);
48  static void open();
49  static void close();
50  static void debug(const std::string& msg, ...);
51  static void info(const std::string& msg, ...);
52  static void notice(const std::string& msg, ...);
53  static void warning(const std::string& msg, ...);
54  static void error(const std::string& msg, ...);
55  static void fatal(const std::string& msg, ...);
56  static void put(Priority priority, const std::string& msg, ...);
57  static void setStdErr(bool stderr)
58  {
59  g_stderr = stderr;
60  }
61 
62  private:
63  static int put_impl(const std::string& msg, Priority priority, va_list ap);
64 
65  };
66 
68 };
69 
70 #endif
Belle2::Mutex
Definition: Mutex.h:12
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogFile
Definition: LogFile.h:18
Belle2::Date
Definition: Date.h:12