23 #ifndef __ccxx_Log_hxx 24 #define __ccxx_Log_hxx 44 bool nodebug =
false);
47 void operator()(
const char *fmt, ...);
48 void operator()(
LogLevel level,
const char *fmt, ...);
67 friend class LogFunctor;
76 static void setFileLogFormat(
const String& format);
83 static void setConsoleLogFormat(
const String& format);
92 { _useConsoleLog = flag; }
103 {
return(_fileLog); }
115 {
return(_consoleLog); }
124 { _useFileLog = flag; }
132 static void setLogFile(
const String& dir,
const String& name);
139 static void setLogFileMaxSize(
size_t maxLogSize);
148 static void setLogFileRotateCount(
uint_t rotateCount);
151 static void vlogFile(
LogLevel level,
const char* file,
int line,
152 const char* message, va_list args);
155 static void vlogConsole(
LogLevel level,
const char* file,
int line,
156 const char* message, va_list args);
166 static void log(
LogLevel level,
const char* file,
int line,
167 const char* message, ...)
___PRINTF(4, 5);
173 static bool assert_(
const char* file,
int line,
const char* expr);
176 static void disableCleanup();
185 static bool _useConsoleLog;
186 static bool _useFileLog;
193 #define Log_assert(EXPR) \ 194 (void)((EXPR)|| ccxx::Log::assert_(__FILE__, __LINE__, #EXPR)) 196 #if (defined CCXX_OS_WINDOWS) && (defined _MSC_VER) && (_MSC_VER < 1400) 200 #if (defined DEBUG) || (defined DEBUG_LOG_MESSAGES) 207 ccxx::LogFunctor(__FILE__, __LINE__, ccxx::LogDebug) 209 #else // ! (DEBUG || DEBUG_LOG_MESSAGES) 212 ccxx::LogFunctor(__FILE__, __LINE__, ccxx::LogDebug, true) 214 #endif // DEBUG || DEBUG_LOG_MESSAGES 218 ccxx::LogFunctor(__FILE__, __LINE__, ccxx::LogInfo) 221 #define Log_warning \ 222 ccxx::LogFunctor(__FILE__, __LINE__, ccxx::LogWarning) 226 ccxx::LogFunctor(__FILE__, __LINE__, ccxx::LogError) 228 #elif (defined __GNUC__) 232 #if (defined DEBUG) || (defined DEBUG_LOG_MESSAGES) 238 #define Log_debug(M, args...) \ 239 ccxx::Log::log(ccxx::LogDebug, __FILE__, __LINE__, M, ## args) 241 #else // ! (DEBUG || DEBUG_LOG_MESSAGES) 243 #define Log_debug(M, args...) 245 #endif // DEBUG || DEBUG_LOG_MESSAGES 248 #define Log_info(M, args...) \ 249 ccxx::Log::log(ccxx::LogInfo, __FILE__, __LINE__, M, ## args) 252 #define Log_warning(M, args...) \ 253 ccxx::Log::log(ccxx::LogWarning, __FILE__, __LINE__, M, ## args) 256 #define Log_error(M, args...) \ 257 ccxx::Log::log(ccxx::LogError, __FILE__, __LINE__, M, ## args) 259 #else // assume ANSI compiler with support for C99 variadic macros 261 #if (defined DEBUG) || defined(DEBUG_LOG_MESSAGES) 267 #define Log_debug(M, ...) \ 268 ccxx::Log::log(ccxx::LogDebug, __FILE__, __LINE__, M, __VA_ARGS__) 270 #else // ! (DEBUG || DEBUG_LOG_MESSAGES) 272 #define Log_debug(M, ...) 274 #endif // DEBUG || DEBUG_LOG_MESSAGES 277 #define Log_info(M, ...) \ 278 ccxx::Log::log(ccxx::LogInfo, __FILE__, __LINE__, M, __VA_ARGS__) 281 #define Log_warning(M, ...) \ 282 ccxx::Log::log(ccxx::LogWarning, __FILE__, __LINE__, M, __VA_ARGS__) 285 #define Log_error(M, ...) \ 286 ccxx::Log::log(ccxx::LogError, __FILE__, __LINE__, M, __VA_ARGS__) 288 #endif // variadic checks 292 #endif // __ccxx_Log_hxx static FileLogger * getFileLogger()
Get the FileLogger currently in use for logging to a file.
Definition: Log.h++:102
A logger that writes to a file, and can optionally perform log rotation.
Definition: FileLogger.h++:40
A critical section, a synchronization primitive that is typically more efficient than but roughly sem...
Definition: CriticalSection.h++:51
Logging routines.
Definition: Log.h++:65
static void setUseConsoleLog(bool flag)
Enable or disable logging to the console.
Definition: Log.h++:91
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
LogLevel
Logging levels.
Definition: LogFormat.h++:44
A logger that writes to the console (the standard error stream).
Definition: ConsoleLogger.h++:37
static ConsoleLogger * getConsoleLogger()
Get the ConsoleLogger currently in use for logging to the console.
Definition: Log.h++:114
static void setUseFileLog(bool flag)
Enable or disable logging to a file.
Definition: Log.h++:123
Debugging messages.
Definition: LogFormat.h++:46
#define COMMONCPP_API
Definition: Common.h++:126
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
#define ___PRINTF(M, N)
Definition: Common.h++:182
#define CCXX_COPY_DECLS(CLASS)
Inlines declarations of a copy constructor and assignment operator for the class CLASS.
Definition: Common.h++:295
Definition: AllocationMap.c++:25