OpenPose 1.0.0rc2 OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
errorAndLog.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_UTILITIES_ERROR_AND_LOG_HPP
2 #define OPENPOSE_UTILITIES_ERROR_AND_LOG_HPP
3
4 #include <atomic>
5 #include <mutex>
6 #include <sstream> // std::stringstream
7 #include <string>
8 #include <vector>
9 #include <openpose/core/macros.hpp>
10 #include <openpose/utilities/enumClasses.hpp>
11
12 namespace op
13 {
14 template<typename T>
15 std::string tToString(const T& message)
16 {
17 // Message -> ostringstream
18 std::ostringstream oss;
19 oss << message;
20 // ostringstream -> std::string
21 return oss.str();
22 }
23
24 // Error managment - How to use:
25 // error(message, __LINE__, __FUNCTION__, __FILE__);
26 OP_API void error(const std::string& message, const int line = -1, const std::string& function = "",
27 const std::string& file = "");
28
29 template<typename T>
30 inline void error(const T& message, const int line = -1, const std::string& function = "",
31 const std::string& file = "")
32 {
33 error(tToString(message), line, function, file);
34 }
35
36 // Printing info - How to use:
37 // It will print info if desiredPriority >= sPriorityThreshold
38 // log(message, desiredPriority, __LINE__, __FUNCTION__, __FILE__);
39 OP_API void log(const std::string& message, const Priority priority = Priority::Max, const int line = -1,
40 const std::string& function = "", const std::string& file = "");
41
42 template<typename T>
43 inline void log(const T& message, const Priority priority = Priority::Max, const int line = -1,
44 const std::string& function = "", const std::string& file = "")
45 {
46 log(tToString(message), priority, line, function, file);
47 }
48
49 // If only desired on debug mode (no computational cost at all on release mode):
50 // It will print info if desiredPriority >= sPriorityThreshold
51 // dLog(message, desiredPriority, __LINE__, __FUNCTION__, __FILE__);
52 template<typename T>
53 inline void dLog(const T& message, const Priority priority = Priority::Max, const int line = -1,
54 const std::string& function = "", const std::string& file = "")
55 {
56 #ifndef NDEBUG
57 log(message, priority, line, function, file);
58 #else
59 UNUSED(message);
60 UNUSED(priority);
61 UNUSED(line);
62 UNUSED(function);
63 UNUSED(file);
64 #endif
65 }
66
67 // This class is thread-safe
68 namespace ConfigureError
69 {
70 OP_API std::vector<ErrorMode> getErrorModes();
71
72 OP_API void setErrorModes(const std::vector<ErrorMode>& errorModes);
73 }
74
75 // This class is thread-safe
76 namespace ConfigureLog
77 {
78 OP_API Priority getPriorityThreshold();
79
80 OP_API const std::vector<LogMode>& getLogModes();
81
82 OP_API void setPriorityThreshold(const Priority priorityThreshold);
83
84 OP_API void setLogModes(const std::vector<LogMode>& loggingModes);
85 }
86 }
87
88 #endif // OPENPOSE_UTILITIES_ERROR_AND_LOG_HPP
UNUSED
#define UNUSED(unusedVariable)
Definition: macros.hpp:32
enumClasses.hpp
op::error
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")
op::ConfigureLog::setLogModes
OP_API void setLogModes(const std::vector< LogMode > &loggingModes)
op::ConfigureLog::getPriorityThreshold
OP_API Priority getPriorityThreshold()
op::tToString
std::string tToString(const T &message)
Definition: errorAndLog.hpp:15
macros.hpp
op::dLog
void dLog(const T &message, const Priority priority=Priority::Max, const int line=-1, const std::string &function="", const std::string &file="")
Definition: errorAndLog.hpp:53
op::ConfigureLog::setPriorityThreshold
OP_API void setPriorityThreshold(const Priority priorityThreshold)
op::log
OP_API void log(const std::string &message, const Priority priority=Priority::Max, const int line=-1, const std::string &function="", const std::string &file="")
op::Priority
Priority
Definition: enumClasses.hpp:21
op::ConfigureError::setErrorModes
OP_API void setErrorModes(const std::vector< ErrorMode > &errorModes)
OP_API
#define OP_API
Definition: macros.hpp:19
op::Priority::Max
op::ConfigureError::getErrorModes
OP_API std::vector< ErrorMode > getErrorModes()
cl::string
std::string string
Definition: cl2.hpp:574
op::ConfigureLog::getLogModes
OP_API const std::vector< LogMode > & getLogModes()