coral
A C++ library for distributed co-simulation
log.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_LOG_HPP
11 #define CORAL_LOG_HPP
12 
13 #include <string>
14 #include <boost/format.hpp>
15 #include <coral/config.h>
16 
17 
18 namespace coral
19 {
21 namespace log
22 {
23 
24 
26 enum Level
27 {
28  trace,
29  debug,
30  info,
31  warning,
32  error
33 };
34 
36 void Log(Level level, const char* message) CORAL_NOEXCEPT;
37 
39 void Log(Level level, const std::string& message) CORAL_NOEXCEPT;
40 
42 void Log(Level level, const boost::format& message) CORAL_NOEXCEPT;
43 
44 
45 namespace detail
46 {
47  // These are intended for use in the macros below
48  void LogLoc(Level level, const char* file, int line, const char* message) CORAL_NOEXCEPT;
49  void LogLoc(Level level, const char* file, int line, const std::string& message) CORAL_NOEXCEPT;
50  void LogLoc(Level level, const char* file, int line, const boost::format& message) CORAL_NOEXCEPT;
51 }
52 
53 
60 #ifdef CORAL_LOG_TRACE_ENABLED
61 # define CORAL_LOG_TRACE(...) coral::log::detail::LogLoc(coral::log::trace, __FILE__, __LINE__, __VA_ARGS__)
62 #else
63 # define CORAL_LOG_TRACE(...) ((void)0)
64 #endif
65 
72 #if defined(CORAL_LOG_DEBUG_ENABLED) || defined(CORAL_LOG_TRACE_ENABLED)
73 # define CORAL_LOG_DEBUG(...) coral::log::detail::LogLoc(coral::log::debug, __FILE__, __LINE__, __VA_ARGS__)
74 #else
75 # define CORAL_LOG_DEBUG(...) ((void)0)
76 #endif
77 
79 void SetLevel(Level level) CORAL_NOEXCEPT;
80 
81 }} // namespace
82 #endif // header guard
STL class.
void SetLevel(Level level) CORAL_NOEXCEPT
Sets the global log level, i.e., which log messages get written.
Definition: variable_io.hpp:28
void Log(Level level, const char *message) CORAL_NOEXCEPT
Writes a plain C string to the global logger.
Level
Log levels.
Definition: log.hpp:26