16 #ifndef _MADARA_LOG_MACROS_H_ 17 #define _MADARA_LOG_MACROS_H_ 20 #include "ace/Log_Msg.h" 22 #ifdef _MADARA_ANDROID_ 23 #include <android/log.h> 27 # define DLINFO ACE_TEXT("(%P|%t) [%M] - %T - ") 36 #define MADARA_LOG_EMERGENCY 0 37 #define MADARA_LOG_TERMINAL_ERROR 1 41 #define MADARA_LOG_NONFATAL_ERROR 2 44 #define MADARA_LOG_ERROR 3 46 #define MADARA_LOG_WARNING 4 49 #define MADARA_LOG_MAJOR_EVENT 5 51 #define MADARA_LOG_MINOR_EVENT 6 53 #define MADARA_LOG_EVENT_TRACE 7 56 #define MADARA_LOG_MAJOR_DEBUG_INFO 8 59 #define MADARA_LOG_TRACE 9 65 #define MADARA_LOG_DETAILED_TRACE 10 68 #if !defined (MADARA_NTRACE) 69 # define MADARA_NTRACE 1 72 #if (MADARA_NTRACE == 1) 73 # if !defined (ACE_NTRACE) 74 # define MADARA_TRACE(X) do {} while (0) 75 # define MADARA_ENABLE_TRACE() do {} while (0) 76 # define MADARA_DISABLE_TRACE() do {} while (0) 78 # if (ACE_NTRACE == 0) 79 # error MADARA_TRACE cannot be disabled if ACE_TRACE is enabled 81 # define MADARA_TRACE(X) do {} while (0) 82 # define MADARA_ENABLE_TRACE() do {} while (0) 83 # define MADARA_DISABLE_TRACE() do {} while (0) 87 # if !defined (ACE_HAS_TRACE) 88 # define ACE_HAS_TRACE 90 # define MADARA_TRACE(X) ACE_TRACE_IMPL (X) 91 # define MADARA_ENABLE_TRACE() ACE_Trace::start_tracing () 92 # define MADARA_DISABLE_TRACE() ACE_Trace::stop_tracing () 93 # undef DLINFO // Make log messages indent with tracing. 94 # define DLINFO ACE_TEXT("%I(%P|%t) [%M] - %T - ") 95 # include "ace/Trace.h" 98 #if defined (MADARA_NLOGGING) 99 # define MADARA_ERROR(L, X) do {} while (0) 100 # define MADARA_DEBUG(L, X) do {} while (0) 101 #define MADARA_ERROR_RETURN(L, X, Y) return (Y) 102 #define MADARA_ERROR_BREAK(L, X) { break; } 104 #if !defined (MADARA_ERROR) 114 #define MADARA_ERROR(L, X) \ 116 if (MADARA_debug_level >= L) \ 118 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ 119 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 120 ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \ 127 # if !defined (MADARA_DEBUG) 137 # define MADARA_DEBUG(L, X) \ 139 if (MADARA_debug_level >= L) \ 141 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ 142 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 143 ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ 149 # if !defined (MADARA_LOG_TRACE) 150 # define MADARA_LOG_TRACE(L, X) \ 152 if (MADARA_debug_level >= L) \ 154 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ 155 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 156 ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ 161 # if !defined (MADARA_ERROR_RETURN) 162 # define MADARA_ERROR_RETURN(L, X, Y) \ 164 if (MADARA_debug_level >= L) \ 166 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ 167 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 168 ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \ 174 # if !defined (MADARA_ERROR_BREAK) 175 # define MADARA_ERROR_BREAK(L, X) { MADARA_ERROR (L, X); break; } 224 inline void log (
int level,
const char * message)
231 #endif // _MADARA_LOG_MACROS_H_ #define MADARA_Logger_Export
ACE_Proper_Import_Flag int MADARA_debug_level
void set_log_level(int level)
Sets the log level.
int get_log_level(void)
Gets the log level.
#define MADARA_DEBUG(L, X)
Provides utility functions and classes for common tasks and needs.
LogLevels
Logging levels available for MADARA library.
Copyright (c) 2015 Carnegie Mellon University.
void log(int level, const char *message)
Logs a simple string message.