log.h
Go to the documentation of this file.
1 
19 #ifndef __LOGFILE
20 
21 #define __LOGFILE
22 
23 #include <string.h>
24 
25 #define LOG_MSG_NO_ERROR_VERBOSE 5
26 #define LOG_MSG_ERROR_VERBOSE 1
27 #define LOG_MSG_ERROR_SEVERE 0
28 
29 
30 #define LOG(format, ...) { char buffer[1024]; snprintf(buffer, 1024, format, ## __VA_ARGS__); std::string str = buffer; globalLog.writeLine(str); printf(format, ## __VA_ARGS__); }
31 
32 #define LOG_MSG(index, format, ...) { if (index <= globalLog.debugLevel) { char buffer[1024]; snprintf(buffer, 1024, format, ## __VA_ARGS__); std::string str = buffer; globalLog.writeLine(str); printf(format, ## __VA_ARGS__); } }
33 
34 #define LOG_VERBOSE(format, ...) { if (LOG_MSG_NO_ERROR_VERBOSE <= globalLog.debugLevel) { char buffer[1024]; snprintf(buffer, 1024, format, ## __VA_ARGS__); std::string str = buffer; globalLog.writeLine(str); printf(format, ## __VA_ARGS__); } }
35 
36 #define LOG_ERROR(format, ...) { if (LOG_MSG_ERROR_VERBOSE <= globalLog.debugLevel) { char buffer[1024]; snprintf(buffer, 1024, format, ## __VA_ARGS__); std::string str = buffer; globalLog.writeLine(str); printf(format, ## __VA_ARGS__); } }
37 
38 #define LOG_ERROR_SEVERE(format, ...) { if (LOG_MSG_ERROR_SEVERE <= globalLog.debugLevel) { char buffer[1024]; snprintf(buffer, 1024, format, ## __VA_ARGS__); std::string str = buffer; globalLog.writeLine(str); printf(format, ## __VA_ARGS__); } }
39 
40 
41 #define LOG_MSG_LEVEL(index) (index <= globalLog.debugLevel)
42 #define LOG_INPUT_LEVEL(index) (index <= globalLog.inputLevel)
43 
44 class CLog
45 {
46  private:
47  std::string filename, path;
48  public:
51  static std::string getTimeAsStr();
52 
53  CLog();
54  static std::string generateLogname(std::string path);
55  void setFilename(std::string filename);
56  void writeLine(std::string line, bool append = true);
57 
58  void setDebugLevel(int debugLevel);
59  void setInputLevel(int inputLevel);
60 };
61 
62 
63 extern CLog globalLog;
64 
65 #endif
CLog()
Definition: log.cpp:30
static std::string getTimeAsStr()
Definition: log.cpp:55
CLog globalLog
Definition: log.cpp:28
void setDebugLevel(int debugLevel)
Definition: log.cpp:40
int inputLevel
Definition: log.h:50
void setInputLevel(int inputLevel)
Definition: log.cpp:35
std::string filename
Definition: log.h:47
int debugLevel
Definition: log.h:49
void setFilename(std::string filename)
Definition: log.cpp:75
Definition: log.h:44
void writeLine(std::string line, bool append=true)
Definition: log.cpp:45
static std::string generateLogname(std::string path)
Definition: log.cpp:67
std::string path
Definition: log.h:47


asr_kinematic_chain_optimizer
Author(s): Aumann Florian, Heller Florian, Jäkel Rainer, Wittenbeck Valerij
autogenerated on Mon Jun 10 2019 12:35:36