MarkLogic Connect
MarkLogic Connect Client API Collection
logging.hpp
Go to the documentation of this file.
1 
9 #ifndef INCLUDE_MLCLIENT_LOGGING_HPP_
10 #define INCLUDE_MLCLIENT_LOGGING_HPP_
11 
12 #include <mlclient/mlclient.hpp>
13 
14 #include <ostream>
15 #include <sstream>
16 #include <string>
17 
18 #ifndef _WIN32
19 
20 #include <glog/logging.h>
21 
22 // BEGIN LOGGING IMPL
23 // THIS SECTION DEFINES THE ACTUAL LOGGING IMPLEMENTATION AND SETTINGS
24 
25 // END LOGGING IMPL
26 
27 // BEGIN IMPL OVERRIDES
28 // SOMETIMES IMPLEMENTATIONS DONT SUPPORT MLCLIENT LOGGING FEATURES - OVERRIDES EXIST HERE TO WORK AROUND THOSE
29 
30 // END IMPL OVERRIDES
31 
32 
33 // BEGIN LOGGING MACROS
34 // THE ACTUAL HIGH LEVEL LOGGING FUNCTIONALITY
35 // TODO enact Debug verbose levels too and link to google vlog(0) to vlog(3)
36 #undef LOG
37 #undef LOG_DEBUG
38 #undef LOG_INFO
39 #undef LOG_ERROR
40 #undef LOG_WARN
41 #define LOG_DEBUG COMPACT_GOOGLE_LOG_ ## INFO.stream()
42 #define LOG_INFO COMPACT_GOOGLE_LOG_ ## INFO.stream()
43 #define LOG_ERROR COMPACT_GOOGLE_LOG_ ## ERROR.stream()
44 #define LOG_WARN COMPACT_GOOGLE_LOG_ ## WARN.stream()
45 #define LOG(lvl) COMPACT_GOOGLE_LOG_ ## INFO.stream()
46 
47 #else
48 // Windows sucks at supporting Google Log
49 template<typename Ch, typename Traits = std::char_traits<Ch> >
50 struct basic_nullbuf : std::basic_streambuf<Ch, Traits> {
51  typedef std::basic_streambuf<Ch, Traits> base_type;
52  typedef typename base_type::int_type int_type;
53  typedef typename base_type::traits_type traits_type;
54 
55  virtual int_type overflow(int_type c) {
56  return traits_type::not_eof(c);
57  }
58 };
59 
60 // convenient typedefs
61 MLCLIENT_API typedef basic_nullbuf<char> nullbuf;
62 MLCLIENT_API typedef basic_nullbuf<wchar_t> wnullbuf;
63 
64 //MLCLIENT_API typedef std::ostream MLLOGSTREAM;
65 
66 // buffers and streams
67 // in some .h
68 MLCLIENT_API extern std::ostream cnull;
69 //extern std::wostream wcnull;
70 
71 #define LOG(lvl) cnull
72 
73 #endif
74 
75 
76 // The following redefined a low-level non formatted log function, as per easylogging++.h
77 #define CLOG(lvl) LOG(lvl)
78 
79 #define TIMED_FUNC(id) //
80 #define TIMED_SCOPE(id,scopename) //
81 #define ENTRANCE_LOG(a,b,c,d) //
82 #define DEBUG_ENTRANCE_LOG(a,b,c,d) //
83 
84 // END LOGGING MACROS
85 
86 // BEGIN LOGGING INIT
87 // DEFINED THE INITIALISATION OF THE LOGGING
88 
89 // END LOGGING INIT
90 
91 namespace mlclient {
92 
100  std::string folder = "";
101 
103  std::string level = "INFO";
104 
106  bool toerr = false;
107 };
108 
109 /*
110  * \brief Initialises logging, once, globally, for this library only.
111  *
112  * \note Normally called once via a global function in mlclient.cpp.
113  *
114  * \since 8.0.2
115  */
116 void libraryLoggingInit();
117 
127 MLCLIENT_API void reconfigureLogging(int argc,const char * argv[]);
128 
134 MLCLIENT_API void reconfigureLoggingSettings(const LoggingConfiguration& config);
135 
136 } // end namespace mlclient
137 
138 #endif /* INCLUDE_MLCLIENT_LOGGING_HPP_ */
LoggingConfiguration to use.
Definition: logging.hpp:98
bool toerr
Definition: logging.hpp:106
std::string level
The level. INFO or DEBUG strings.
Definition: logging.hpp:103
MLCLIENT_API void reconfigureLogging(int argc, const char *argv[])
Reconfigure logging from command line args.
MLCLIENT_API void reconfigureLoggingSettings(const LoggingConfiguration &config)
Reconfigures logging from a LoggingConfiguration struct.
std::string folder
The folder to log to.
Definition: logging.hpp:100
the namespace which wraps all Core Public C++ API classes.
Definition: Connection.hpp:36