i3ipc++
An C++ implementaiton of the i3 IPC
 All Classes Functions Variables Enumerations Enumerator Modules
log.hpp
1 #pragma once
2 
3 #include <ostream>
4 #include <vector>
5 #include <auss.hpp>
6 
12 namespace i3ipc {
13 
17 extern std::vector<std::ostream*> g_logging_outs;
18 
22 extern std::vector<std::ostream*> g_logging_err_outs;
23 
29 template<typename T>
30 inline void log(const T& data, const bool err=false) {
31  for (auto out : (err ? g_logging_err_outs : g_logging_outs)) {
32  *out << data << std::endl;
33  }
34 }
35 
36 template<>
37 inline void log(const auss_t& data, const bool err) {
38  log(data.to_string());
39 }
40 
41 }
42 
46 #define I3IPC_LOG(T, ERR) \
47  ::i3ipc::log((T), (ERR));
48 
53 #define I3IPC_INFO(T) I3IPC_LOG(auss_t() << "i: " << T, false)
54 
59 #define I3IPC_ERR(T) I3IPC_LOG(auss_t() << "E: " << T, true)
60 
65 #define I3IPC_WARN(T) I3IPC_LOG(auss_t() << "W: " << T, true)
66 
67 #ifdef DEBUG
68 
73 #define I3IPC_DEBUG(T) I3IPC_LOG(auss_t() << "D: " << T, true)
74 
75 #else
76 
81 #define I3IPC_DEBUG(T)
82 #endif
83 
Definition: ipc-util.hpp:12