gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Logger.h
Go to the documentation of this file.
1 #ifndef __Logger_h
2 #define __Logger_h
3 
4 
5 //******************************************************************************
6 // Include
7 //******************************************************************************
8 #include <string>
9 #include <fstream>
10 #include <iostream>
11 
12 
13 //******************************************************************************
14 // namespace
15 //******************************************************************************
16 namespace gVirtualXRay {
17 
18 
19 class Logger;
20 
21 extern Logger LOGGER;
22 
23 class Logger
24 {
25 public:
26  Logger(const char* aFileName = "gvxr.log");
27  Logger(const std::string& aFileName = "gvxr.log");
28  ~Logger();
29 
30  bool is_open() const;
31  void open(const std::string& aFileName);
32  void close();
33  void flush();
34 
35  const std::string& getFilename() const;
36  const std::string& getFname() const;
37 
38  std::ostream& logNow(const std::string& aMessage = "");
39  std::ostream& logError(const std::string& aMessage = "");
40  std::ostream& logWarning(const std::string& aMessage = "");
41 
42  void progressBar(float aPercentage, bool aNewLineFlag = false);
43 
44  void progressBar(unsigned int aProgress, unsigned int aTotal, bool aNewLineFlag = false);
45 
46 protected:
47  std::string getNow() const;
48 
49  Logger& operator=(const Logger& aLogger);
50  Logger(const Logger& aLogger);
51 
52  std::ofstream m_output;
53  std::string m_filename;
54 
56 };
57 
58 
59 }
60 
61 
62 #endif // __Logger_h
const std::string & getFname() const
bool is_open() const
std::string m_filename
Definition: Logger.h:53
const std::string & getFilename() const
std::string getNow() const
Logger(const char *aFileName="gvxr.log")
std::ostream & logWarning(const std::string &aMessage="")
int m_last_progress_as_int
Definition: Logger.h:55
std::ostream & logNow(const std::string &aMessage="")
void open(const std::string &aFileName)
void progressBar(float aPercentage, bool aNewLineFlag=false)
std::ostream & logError(const std::string &aMessage="")
Logger & operator=(const Logger &aLogger)
std::ofstream m_output
Definition: Logger.h:52