18 #ifndef EASYLOGGINGPP_H 19 #define EASYLOGGINGPP_H 21 #if __cplusplus >= 201103L 23 #endif // __cplusplus >= 201103L 24 #if (defined(__GNUC__)) 25 # define ELPP_COMPILER_GCC 1 27 # define ELPP_COMPILER_GCC 0 30 # define ELPP_GCC_VERSION (__GNUC__ * 10000 \ 31 + __GNUC_MINOR__ * 100 \ 32 + __GNUC_PATCHLEVEL__) 33 # if defined(__GXX_EXPERIMENTAL_CXX0X__) 39 # define ELPP_COMPILER_MSVC 1 41 # define ELPP_COMPILER_MSVC 0 43 #define ELPP_CRT_DBG_WARNINGS ELPP_COMPILER_MSVC 44 #if ELPP_COMPILER_MSVC 45 # if (_MSC_VER == 1600) 47 # elif(_MSC_VER >= 1700) 52 #if (defined(__clang__) && (__clang__ == 1)) 53 # define ELPP_COMPILER_CLANG 1 55 # define ELPP_COMPILER_CLANG 0 57 #if ELPP_COMPILER_CLANG 58 # if __has_include(<thread>) 60 # if !defined(__GLIBCXX__) || __GLIBCXX__ >= 20150426 61 # define ELPP_CLANG_SUPPORTS_THREAD 62 # endif // !defined(__GLIBCXX__) || __GLIBCXX__ >= 20150426 63 # endif // __has_include(<thread>) 65 #if (defined(__MINGW32__) || defined(__MINGW64__)) 70 #if (defined(__CYGWIN__) && (__CYGWIN__ == 1)) 71 # define ELPP_CYGWIN 1 73 # define ELPP_CYGWIN 0 75 #if (defined(__INTEL_COMPILER)) 76 # define ELPP_COMPILER_INTEL 1 78 # define ELPP_COMPILER_INTEL 0 82 #if (defined(_WIN32) || defined(_WIN64)) 83 # define ELPP_OS_WINDOWS 1 85 # define ELPP_OS_WINDOWS 0 88 #if (defined(__linux) || defined(__linux__)) 89 # define ELPP_OS_LINUX 1 91 # define ELPP_OS_LINUX 0 93 #if (defined(__APPLE__)) 94 # define ELPP_OS_MAC 1 96 # define ELPP_OS_MAC 0 98 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) 99 # define ELPP_OS_FREEBSD 1 101 # define ELPP_OS_FREEBSD 0 104 # define ELPP_OS_SOLARIS 1 106 # define ELPP_OS_SOLARIS 0 109 # define ELPP_OS_AIX 1 111 # define ELPP_OS_AIX 0 113 #if (defined(__NetBSD__)) 114 # define ELPP_OS_NETBSD 1 116 # define ELPP_OS_NETBSD 0 119 #if ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_NETBSD || ELPP_OS_SOLARIS || ELPP_OS_AIX) && (!ELPP_OS_WINDOWS)) 120 # define ELPP_OS_UNIX 1 122 # define ELPP_OS_UNIX 0 124 #if (defined(__ANDROID__)) 125 # define ELPP_OS_ANDROID 1 127 # define ELPP_OS_ANDROID 0 130 #if !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN 132 # undef ELPP_OS_LINUX 133 # define ELPP_OS_UNIX 1 134 # define ELPP_OS_LINUX 1 135 #endif // !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN 136 #if !defined(ELPP_INTERNAL_DEBUGGING_OUT_INFO) 137 # define ELPP_INTERNAL_DEBUGGING_OUT_INFO std::cout 138 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) 139 #if !defined(ELPP_INTERNAL_DEBUGGING_OUT_ERROR) 140 # define ELPP_INTERNAL_DEBUGGING_OUT_ERROR std::cerr 141 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) 142 #if !defined(ELPP_INTERNAL_DEBUGGING_ENDL) 143 # define ELPP_INTERNAL_DEBUGGING_ENDL std::endl 144 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) 145 #if !defined(ELPP_INTERNAL_DEBUGGING_MSG) 146 # define ELPP_INTERNAL_DEBUGGING_MSG(msg) msg 147 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) 149 #if !defined(ELPP_DISABLE_ASSERT) 150 # if (defined(ELPP_DEBUG_ASSERT_FAILURE)) 151 # define ELPP_ASSERT(expr, msg) if (!(expr)) { \ 152 std::stringstream internalInfoStream; internalInfoStream << msg; \ 153 ELPP_INTERNAL_DEBUGGING_OUT_ERROR \ 154 << "EASYLOGGING++ ASSERTION FAILED (LINE: " << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" \ 155 << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" << ELPP_INTERNAL_DEBUGGING_ENDL; base::utils::abort(1, \ 156 "ELPP Assertion failure, please define ELPP_DEBUG_ASSERT_FAILURE"); } 158 # define ELPP_ASSERT(expr, msg) if (!(expr)) { \ 159 std::stringstream internalInfoStream; internalInfoStream << msg; \ 160 ELPP_INTERNAL_DEBUGGING_OUT_ERROR\ 161 << "ASSERTION FAILURE FROM EASYLOGGING++ (LINE: " \ 162 << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" \ 163 << ELPP_INTERNAL_DEBUGGING_ENDL; } 164 # endif // (defined(ELPP_DEBUG_ASSERT_FAILURE)) 166 # define ELPP_ASSERT(x, y) 167 #endif //(!defined(ELPP_DISABLE_ASSERT) 168 #if ELPP_COMPILER_MSVC 169 # define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \ 170 { char buff[256]; strerror_s(buff, 256, errno); \ 171 ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << buff << " [" << errno << "]";} (void)0 173 # define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \ 174 ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << strerror(errno) << " [" << errno << "]"; (void)0 175 #endif // ELPP_COMPILER_MSVC 176 #if defined(ELPP_DEBUG_ERRORS) 177 # if !defined(ELPP_INTERNAL_ERROR) 178 # define ELPP_INTERNAL_ERROR(msg, pe) { \ 179 std::stringstream internalInfoStream; internalInfoStream << "<ERROR> " << msg; \ 180 ELPP_INTERNAL_DEBUGGING_OUT_ERROR \ 181 << "ERROR FROM EASYLOGGING++ (LINE: " << __LINE__ << ") " \ 182 << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << ELPP_INTERNAL_DEBUGGING_ENDL; \ 183 if (pe) { ELPP_INTERNAL_DEBUGGING_OUT_ERROR << " "; ELPP_INTERNAL_DEBUGGING_WRITE_PERROR; }} (void)0 186 # undef ELPP_INTERNAL_INFO 187 # define ELPP_INTERNAL_ERROR(msg, pe) 188 #endif // defined(ELPP_DEBUG_ERRORS) 189 #if (defined(ELPP_DEBUG_INFO)) 190 # if !(defined(ELPP_INTERNAL_INFO_LEVEL)) 191 # define ELPP_INTERNAL_INFO_LEVEL 9 192 # endif // !(defined(ELPP_INTERNAL_INFO_LEVEL)) 193 # if !defined(ELPP_INTERNAL_INFO) 194 # define ELPP_INTERNAL_INFO(lvl, msg) { if (lvl <= ELPP_INTERNAL_INFO_LEVEL) { \ 195 std::stringstream internalInfoStream; internalInfoStream << "<INFO> " << msg; \ 196 ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) \ 197 << ELPP_INTERNAL_DEBUGGING_ENDL; }} 200 # undef ELPP_INTERNAL_INFO 201 # define ELPP_INTERNAL_INFO(lvl, msg) 202 #endif // (defined(ELPP_DEBUG_INFO)) 203 #if (defined(ELPP_FEATURE_ALL)) || (defined(ELPP_FEATURE_CRASH_LOG)) 204 # if (ELPP_COMPILER_GCC && !ELPP_MINGW && !ELPP_OS_ANDROID) 205 # define ELPP_STACKTRACE 1 207 # if ELPP_COMPILER_MSVC 208 # pragma message("Stack trace not available for this compiler") 210 # warning "Stack trace not available for this compiler"; 211 # endif // ELPP_COMPILER_MSVC 212 # define ELPP_STACKTRACE 0 213 # endif // ELPP_COMPILER_GCC 215 # define ELPP_STACKTRACE 0 216 #endif // (defined(ELPP_FEATURE_ALL)) || (defined(ELPP_FEATURE_CRASH_LOG)) 218 #define ELPP_UNUSED(x) (void)x 221 # define ELPP_LOG_PERMS S_IRUSR | S_IWUSR | S_IXUSR | S_IWGRP | S_IRGRP | S_IXGRP | S_IWOTH | S_IXOTH 222 #endif // ELPP_OS_UNIX 223 #if defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC 224 # if defined(ELPP_EXPORT_SYMBOLS) 225 # define ELPP_EXPORT __declspec(dllexport) 227 # define ELPP_EXPORT __declspec(dllimport) 228 # endif // defined(ELPP_EXPORT_SYMBOLS) 231 #endif // defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC 237 #if ELPP_CRT_DBG_WARNINGS 238 # define STRTOK(a, b, c) strtok_s(a, b, c) 239 # define STRERROR(a, b, c) strerror_s(a, b, c) 240 # define STRCAT(a, b, len) strcat_s(a, len, b) 241 # define STRCPY(a, b, len) strcpy_s(a, len, b) 243 # define STRTOK(a, b, c) strtok(a, b) 244 # define STRERROR(a, b, c) strerror(c) 245 # define STRCAT(a, b, len) strcat(a, b) 246 # define STRCPY(a, b, len) strcpy(a, b) 249 #if (ELPP_MINGW && !defined(ELPP_FORCE_USE_STD_THREAD)) 250 # define ELPP_USE_STD_THREADING 0 252 # if ((ELPP_COMPILER_CLANG && defined(ELPP_CLANG_SUPPORTS_THREAD)) || \ 253 (!ELPP_COMPILER_CLANG && defined(ELPP_CXX11)) || \ 254 defined(ELPP_FORCE_USE_STD_THREAD)) 255 # define ELPP_USE_STD_THREADING 1 257 # define ELPP_USE_STD_THREADING 0 261 #if ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702) 264 # define ELPP_FINAL final 265 #endif // ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702) 266 #if defined(EASYLOGGINGPP_ASYNC) 267 # define ELPP_ASYNC_LOGGING 1 269 # define ELPP_ASYNC_LOGGING 0 270 #endif // defined(EASYLOGGINGPP_ASYNC) 271 #if defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING 272 # define ELPP_THREADING_ENABLED 1 274 # define ELPP_THREADING_ENABLED 0 275 #endif // defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING 278 #if ELPP_COMPILER_MSVC // Visual C++ 279 # define ELPP_FUNC __FUNCSIG__ 280 #elif ELPP_COMPILER_GCC // GCC 281 # define ELPP_FUNC __PRETTY_FUNCTION__ 282 #elif ELPP_COMPILER_INTEL // Intel C++ 283 # define ELPP_FUNC __PRETTY_FUNCTION__ 284 #elif ELPP_COMPILER_CLANG // Clang++ 285 # define ELPP_FUNC __PRETTY_FUNCTION__ 287 # if defined(__func__) 288 # define ELPP_FUNC __func__ 290 # define ELPP_FUNC "" 291 # endif // defined(__func__) 292 #endif // defined(_MSC_VER) 293 #undef ELPP_VARIADIC_TEMPLATES_SUPPORTED 295 #define ELPP_VARIADIC_TEMPLATES_SUPPORTED \ 296 (ELPP_COMPILER_GCC || ELPP_COMPILER_CLANG || ELPP_COMPILER_INTEL || (ELPP_COMPILER_MSVC && _MSC_VER >= 1800)) 298 #if defined(ELPP_DISABLE_LOGS) 299 #define ELPP_LOGGING_ENABLED 0 301 #define ELPP_LOGGING_ENABLED 1 303 #if (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED)) 304 # define ELPP_DEBUG_LOG 1 306 # define ELPP_DEBUG_LOG 0 307 #endif // (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED)) 308 #if (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED)) 309 # define ELPP_INFO_LOG 1 311 # define ELPP_INFO_LOG 0 312 #endif // (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED)) 313 #if (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED)) 314 # define ELPP_WARNING_LOG 1 316 # define ELPP_WARNING_LOG 0 317 #endif // (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED)) 318 #if (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED)) 319 # define ELPP_ERROR_LOG 1 321 # define ELPP_ERROR_LOG 0 322 #endif // (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED)) 323 #if (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED)) 324 # define ELPP_FATAL_LOG 1 326 # define ELPP_FATAL_LOG 0 327 #endif // (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED)) 328 #if (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED)) 329 # define ELPP_TRACE_LOG 1 331 # define ELPP_TRACE_LOG 0 332 #endif // (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED)) 333 #if (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED)) 334 # define ELPP_VERBOSE_LOG 1 336 # define ELPP_VERBOSE_LOG 0 337 #endif // (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED)) 338 #if (!(ELPP_CXX0X || ELPP_CXX11)) 339 # error "C++0x (or higher) support not detected! (Is `-std=c++11' missing?)" 340 #endif // (!(ELPP_CXX0X || ELPP_CXX11)) 342 #if defined(ELPP_SYSLOG) 344 #endif // defined(ELPP_SYSLOG) 353 #if defined(ELPP_UNICODE) 357 # endif // ELPP_OS_WINDOWS 358 #endif // defined(ELPP_UNICODE) 361 # include <execinfo.h> 362 #endif // ELPP_STACKTRACE 364 # include <sys/system_properties.h> 365 #endif // ELPP_OS_ANDROID 367 # include <sys/stat.h> 368 # include <sys/time.h> 369 #elif ELPP_OS_WINDOWS 371 # include <windows.h> 372 # if defined(WIN32_LEAN_AND_MEAN) 373 # if defined(ELPP_WINSOCK2) 374 # include <winsock2.h> 376 # include <winsock.h> 377 # endif // defined(ELPP_WINSOCK2) 378 # endif // defined(WIN32_LEAN_AND_MEAN) 379 #endif // ELPP_OS_UNIX 383 #include <unordered_map> 385 #include <functional> 391 #include <type_traits> 392 #if ELPP_THREADING_ENABLED 393 # if ELPP_USE_STD_THREADING 398 # include <pthread.h> 399 # endif // ELPP_OS_UNIX 400 # endif // ELPP_USE_STD_THREADING 401 #endif // ELPP_THREADING_ENABLED 402 #if ELPP_ASYNC_LOGGING 403 # if defined(ELPP_NO_SLEEP_FOR) 405 # endif // defined(ELPP_NO_SLEEP_FOR) 408 # include <condition_variable> 409 #endif // ELPP_ASYNC_LOGGING 410 #if defined(ELPP_STL_LOGGING) 418 # if defined(ELPP_LOG_STD_ARRAY) 420 # endif // defined(ELPP_LOG_STD_ARRAY) 421 # if defined(ELPP_LOG_UNORDERED_SET) 422 # include <unordered_set> 423 # endif // defined(ELPP_UNORDERED_SET) 424 #endif // defined(ELPP_STL_LOGGING) 425 #if defined(ELPP_QT_LOGGING) 428 # include <QByteArray> 435 # include <QLinkedList> 437 # include <QMultiHash> 439 #endif // defined(ELPP_QT_LOGGING) 440 #if defined(ELPP_BOOST_LOGGING) 442 # include <boost/container/vector.hpp> 443 # include <boost/container/stable_vector.hpp> 444 # include <boost/container/list.hpp> 445 # include <boost/container/deque.hpp> 446 # include <boost/container/map.hpp> 447 # include <boost/container/flat_map.hpp> 448 # include <boost/container/set.hpp> 449 # include <boost/container/flat_set.hpp> 450 #endif // defined(ELPP_BOOST_LOGGING) 451 #if defined(ELPP_WXWIDGETS_LOGGING) 453 # include <wx/vector.h> 454 #endif // defined(ELPP_WXWIDGETS_LOGGING) 455 #if defined(ELPP_UTC_DATETIME) 456 # define elpptime_r gmtime_r 457 # define elpptime_s gmtime_s 458 # define elpptime gmtime 460 # define elpptime_r localtime_r 461 # define elpptime_s localtime_s 462 # define elpptime localtime 463 #endif // defined(ELPP_UTC_DATETIME) 468 class PerformanceTrackingData;
478 class RegisteredLoggers;
479 class PerformanceTracker;
480 class MessageBuilder;
484 class DefaultLogBuilder;
485 class DefaultLogDispatchCallback;
486 #if ELPP_ASYNC_LOGGING 487 class AsyncLogDispatchCallback;
488 class AsyncDispatchWorker;
489 #endif // ELPP_ASYNC_LOGGING 490 class DefaultPerformanceTrackingCallback;
502 #if defined(ELPP_UNICODE) 503 # define ELPP_LITERAL(txt) L##txt 504 # define ELPP_STRLEN wcslen 505 # if defined ELPP_CUSTOM_COUT 506 # define ELPP_COUT ELPP_CUSTOM_COUT 508 # define ELPP_COUT std::wcout 509 # endif // defined ELPP_CUSTOM_COUT 516 # define ELPP_LITERAL(txt) txt 517 # define ELPP_STRLEN strlen 518 # if defined ELPP_CUSTOM_COUT 519 # define ELPP_COUT ELPP_CUSTOM_COUT 521 # define ELPP_COUT std::cout 522 # endif // defined ELPP_CUSTOM_COUT 528 #endif // defined(ELPP_UNICODE) 529 #if defined(ELPP_CUSTOM_COUT_LINE) 530 # define ELPP_COUT_LINE(logLine) ELPP_CUSTOM_COUT_LINE(logLine) 532 # define ELPP_COUT_LINE(logLine) logLine << std::flush 533 #endif // defined(ELPP_CUSTOM_COUT_LINE) 611 return static_cast<Level>(l);
615 static const char* convertToString(
Level level);
619 static Level convertFromString(
const char* levelStr);
624 static void forEachLevel(
base::type::EnumType* startIndex,
const std::function<
bool(
void)>& fn);
686 static inline void forEachConfigType(
base::type::EnumType* startIndex,
const std::function<
bool(
void)>& fn);
733 #ifdef ELPP_DEFAULT_LOGGER 736 static const char* kDefaultLoggerId =
"default";
739 #ifdef ELPP_DEFAULT_PERFORMANCE_LOGGER 742 static const char* kPerformanceLoggerId =
"performance";
745 #if defined(ELPP_SYSLOG) 746 static const char* kSysLogLoggerId =
"syslog";
747 #endif // defined(ELPP_SYSLOG) 752 static const char* kFilePathSeperator =
"/";
753 #endif // ELPP_OS_WINDOWS 778 SIGABRT,
"SIGABRT",
"Abnormal termination",
779 "Program was abnormally terminated." 782 SIGFPE,
"SIGFPE",
"Erroneous arithmetic operation",
783 "Arithemetic operation issue such as division by zero or operation resulting in overflow." 786 SIGILL,
"SIGILL",
"Illegal instruction",
787 "Generally due to a corruption in the code or to an attempt to execute data." 790 SIGSEGV,
"SIGSEGV",
"Invalid access to memory",
791 "Program is trying to read an invalid (unallocated, deleted or corrupted) or inaccessible memory." 794 SIGINT,
"SIGINT",
"Interactive attention signal",
795 "Interruption generated (generally) by user or operating system." 848 template <
typename T>
852 if (pointer ==
nullptr)
860 template <
typename Enum>
864 template <
typename Enum>
868 template <
typename Enum>
873 template <
typename Enum>
875 *flag = base::utils::bitwise::Or<Enum>(
e, *flag);
877 template <
typename Enum>
879 *flag = base::utils::bitwise::Not<Enum>(
e, *flag);
881 template <
typename Enum>
883 return base::utils::bitwise::And<Enum>(
e, flag) > 0
x0;
886 namespace threading {
887 #if ELPP_THREADING_ENABLED 888 # if !ELPP_USE_STD_THREADING 895 pthread_mutexattr_t attr;
896 pthread_mutexattr_init(&attr);
897 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
898 pthread_mutex_init(&m_underlyingMutex, &attr);
899 pthread_mutexattr_destroy(&attr);
900 # elif ELPP_OS_WINDOWS 901 InitializeCriticalSection(&m_underlyingMutex);
902 # endif // ELPP_OS_UNIX 905 virtual ~
Mutex(
void) {
907 pthread_mutex_destroy(&m_underlyingMutex);
908 # elif ELPP_OS_WINDOWS 909 DeleteCriticalSection(&m_underlyingMutex);
910 # endif // ELPP_OS_UNIX 913 inline void lock(
void) {
915 pthread_mutex_lock(&m_underlyingMutex);
916 # elif ELPP_OS_WINDOWS 917 EnterCriticalSection(&m_underlyingMutex);
918 # endif // ELPP_OS_UNIX 921 inline bool try_lock(
void) {
923 return (pthread_mutex_trylock(&m_underlyingMutex) == 0);
924 # elif ELPP_OS_WINDOWS 925 return TryEnterCriticalSection(&m_underlyingMutex);
926 # endif // ELPP_OS_UNIX 929 inline void unlock(
void) {
931 pthread_mutex_unlock(&m_underlyingMutex);
932 # elif ELPP_OS_WINDOWS 933 LeaveCriticalSection(&m_underlyingMutex);
934 # endif // ELPP_OS_UNIX 939 pthread_mutex_t m_underlyingMutex;
940 # elif ELPP_OS_WINDOWS 941 CRITICAL_SECTION m_underlyingMutex;
942 # endif // ELPP_OS_UNIX 945 template <
typename M>
962 typedef base::threading::internal::ScopedLock<base::threading::Mutex>
ScopedLock;
964 typedef std::recursive_mutex
Mutex;
965 typedef std::lock_guard<base::threading::Mutex>
ScopedLock;
966 # endif // !ELPP_USE_STD_THREADING 980 template <
typename Mutex>
993 #endif // ELPP_THREADING_ENABLED 1007 #if ELPP_THREADING_ENABLED 1008 # if !ELPP_USE_STD_THREADING 1011 std::stringstream ss;
1012 # if (ELPP_OS_WINDOWS) 1013 ss << GetCurrentThreadId();
1014 # endif // (ELPP_OS_WINDOWS) 1020 std::stringstream ss;
1024 # endif // !ELPP_USE_STD_THREADING 1029 #endif // ELPP_THREADING_ENABLED 1042 static bool pathExists(
const char*
path,
bool considerFile =
false);
1051 static void buildStrippedFilename(
const char* filename,
char buff[],
1054 static void buildBaseFilename(
const std::string& fullPath,
char buff[],
1063 return c >=
'0' && c <=
'9';
1067 static bool wildCardMatch(
const char*
str,
const char*
pattern);
1102 #if defined(ELPP_UNICODE) 1105 #endif // defined(ELPP_UNICODE) 1112 static bool cStringEq(
const char*
s1,
const char* s2);
1116 static bool cStringCaseEq(
const char* s1,
const char* s2);
1119 static bool contains(
const char* str,
char c);
1121 static char* convertAndAddToBuff(std::size_t
n,
int len,
char*
buf,
const char* bufLim,
bool zeroPadded =
true);
1122 static char* addToBuff(
const char* str,
char* buf,
const char* bufLim);
1123 static char* clearBuff(
char buff[], std::size_t lim);
1127 static char* wcharPtrToCharPtr(
const wchar_t*
line);
1133 static const char* getWindowsEnvironmentVariable(
const char* varname);
1138 #endif // ELPP_OS_WINDOWS 1145 #endif // ELPP_OS_ANDROID 1159 static std::string getEnvironmentVariable(
const char* variableName,
const char* defaultVal,
1160 const char* alternativeBashCommand =
nullptr);
1169 static bool termSupportsColor(
void);
1178 static void gettimeofday(
struct timeval* tv);
1187 static std::string timevalToString(
struct timeval tval,
const char* format,
1194 static unsigned long long getTimeDifference(
const struct timeval& endTime,
const struct timeval& startTime,
1198 static struct ::tm* buildTimeInfo(
struct timeval* currTime, struct ::tm* timeInfo);
1200 static char* parseFormat(
char*
buf, std::size_t bufSz,
const char* format,
const struct tm* tInfo,
1207 setArgs(0, static_cast<char**>(
nullptr));
1210 setArgs(argc, argv);
1213 setArgs(argc, argv);
1217 inline void setArgs(
int argc,
const char** argv) {
1218 setArgs(argc, const_cast<char**>(argv));
1221 void setArgs(
int argc,
char** argv);
1223 bool hasParamWithValue(
const char* paramKey)
const;
1226 const char* getParamValue(
const char* paramKey)
const;
1228 bool hasParam(
const char* paramKey)
const;
1230 bool empty(
void)
const;
1232 std::size_t
size(
void)
const;
1247 template <
typename T_Ptr,
typename Container>
1269 for (std::size_t
i = 0;
i < m_list.size(); ++
i) {
1270 if (m_list.at(
i) != other.
m_list.at(
i)) {
1281 for (std::size_t
i = 0;
i < m_list.size(); ++
i) {
1282 if (m_list.at(
i) != other.
m_list.at(
i)) {
1304 return m_list.begin();
1309 return m_list.end();
1315 return m_list.cbegin();
1320 return m_list.cend();
1325 return m_list.empty();
1330 return m_list.size();
1344 virtual void unregisterAll(
void) = 0;
1362 template <
typename T_Ptr,
typename T_Key = const
char*>
1375 this->reinitDeepCopy(sr);
1385 this->reinitDeepCopy(sr);
1395 if (!this->empty()) {
1396 for (
auto&& curr : this->list()) {
1399 this->list().clear();
1405 unregister(uniqKey);
1406 this->list().insert(std::make_pair(uniqKey, ptr));
1411 T_Ptr* existing =
get(uniqKey);
1412 if (existing !=
nullptr) {
1413 this->list().erase(uniqKey);
1419 T_Ptr*
get(
const T_Key& uniqKey) {
1420 iterator
it = this->list().find(uniqKey);
1421 return it == this->list().end()
1428 for (const_iterator
it = sr.cbegin();
it != sr.cend(); ++
it) {
1429 registerNew(
it->first,
new T_Ptr(*
it->second));
1438 template <
typename T_Ptr,
typename Pred>
1456 this->reinitDeepCopy(sr);
1466 this->reinitDeepCopy(sr);
1471 for (const_iterator
it = sr.
list().begin();
it != sr.
list().end(); ++
it) {
1479 if (!this->empty()) {
1480 for (
auto&& curr : this->list()) {
1483 this->list().clear();
1489 iterator iter = this->
begin();
1490 for (; iter != this->
end(); ++iter) {
1495 if (iter != this->
end() && *iter !=
nullptr) {
1496 this->list().erase(iter);
1503 this->list().push_back(ptr);
1508 template <
typename T,
typename T2>
1510 iterator iter = std::find_if(this->list().
begin(), this->list().
end(), Pred(arg1,
arg2));
1511 if (iter != this->list().
end() && *iter !=
nullptr) {
1519 for (const_iterator
it = sr.list().begin();
it != sr.list().end(); ++
it) {
1520 registerNew(
new T_Ptr(**
it));
1526 template <
typename T,
typename TPtr>
1528 if (mapT->find(
id) == mapT->end()) {
1529 mapT->insert(std::make_pair(
id, TPtr(
new T())));
1535 template <
typename T,
typename TPtr>
1537 if (mapT->find(
id) != mapT->end()) {
1542 template <
typename T,
typename TPtr>
1544 typename std::unordered_map<std::string, TPtr>::iterator iter = mapT->find(
id);
1545 if (iter != mapT->end()) {
1546 return static_cast<T*
>(iter->second.get());
1587 return m_userFormat;
1595 return m_dateTimeFormat;
1617 virtual void updateFormatSpec(
void)
ELPP_FINAL;
1642 m_formatSpecifier(formatSpecifier), m_resolver(resolver) {}
1644 return m_formatSpecifier;
1646 inline const FormatSpecifierValueResolver&
resolver(
void)
const {
1650 return strcmp(m_formatSpecifier, formatSpecifier) == 0;
1684 return m_configurationType;
1800 setGlobally(configurationType, value,
false);
1813 return m_configurationFile;
1817 void setToDefault(
void);
1826 void setRemainingToDefault(
void);
1909 return m_configurations;
1913 bool toFile(
Level level);
1915 bool toStandardOutput(
Level level);
1921 std::size_t maxLogFileSize(
Level level);
1922 std::size_t logFlushThreshold(
Level level);
1944 template <
typename Conf_T>
1945 inline Conf_T
getConfigByVal(
Level level,
const std::unordered_map<Level, Conf_T>* confMap,
const char* confName) {
1947 return unsafeGetConfigByVal(level, confMap, confName);
1950 template <
typename Conf_T>
1951 inline Conf_T&
getConfigByRef(
Level level, std::unordered_map<Level, Conf_T>* confMap,
const char* confName) {
1953 return unsafeGetConfigByRef(level, confMap, confName);
1956 template <
typename Conf_T>
1959 typename std::unordered_map<Level, Conf_T>::const_iterator
it = confMap->find(level);
1960 if (it == confMap->end()) {
1966 << std::endl <<
"Please ensure you have properly configured logger.",
false);
1973 template <
typename Conf_T>
1976 typename std::unordered_map<Level, Conf_T>::iterator
it = confMap->find(level);
1977 if (it == confMap->end()) {
1983 << std::endl <<
"Please ensure you have properly configured logger.",
false);
1989 template <
typename Conf_T>
1991 bool includeGlobalLevel =
true) {
1993 if (confMap->empty() && includeGlobalLevel) {
1998 typename std::unordered_map<Level, Conf_T>::iterator
it = confMap->find(
Level::Global);
1999 if (it != confMap->end() && it->second ==
value) {
2003 it = confMap->find(level);
2004 if (it == confMap->end()) {
2006 confMap->insert(std::make_pair(level, value));
2009 confMap->at(level) =
value;
2017 bool unsafeValidateFileRolling(
Level level,
const PreRollOutCallback& preRollOutCallback);
2021 return unsafeValidateFileRolling(level, preRollOutCallback);
2034 m_filename(filename),
2035 m_lineNumber(lineNumber),
2040 m_filename(hitCounter.m_filename),
2041 m_lineNumber(hitCounter.m_lineNumber),
2042 m_hitCounts(hitCounter.m_hitCounts) {
2046 if (&hitCounter !=
this) {
2060 m_lineNumber = lineNumber;
2076 return m_lineNumber;
2090 : m_filename(filename),
2091 m_lineNumber(lineNumber) {
2094 return ((counter !=
nullptr) &&
2095 (strcmp(counter->
m_filename, m_filename) == 0) &&
2135 template <
typename T>
2147 virtual void handle(
const T* handlePtr) = 0;
2155 return m_logMessage;
2158 return m_dispatchAction;
2161 m_logMessage = logMessage;
2164 m_dispatchAction = dispatchAction;
2178 std::unordered_map<std::string, std::unique_ptr<base::threading::Mutex>>
m_fileLocks;
2183 friend class base::PerformanceTracker;
2191 LogBuilder() : m_termSupportsColor(base::utils::OS::termSupportsColor()) {}
2224 void reconfigure(
void);
2231 return m_parentApplicationName;
2235 m_parentApplicationName = parentApplicationName;
2239 return &m_configurations;
2243 return m_typedConfigurations;
2254 return ++m_unflushedCount.find(level)->second >= m_typedConfigurations->logFlushThreshold(level);
2258 return m_logBuilder.get();
2262 m_logBuilder = logBuilder;
2266 return m_typedConfigurations->enabled(level);
2269 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED 2270 # define LOGGER_LEVEL_WRITERS_SIGNATURES(FUNCTION_NAME)\ 2271 template <typename T, typename... Args>\ 2272 inline void FUNCTION_NAME(const char*, const T&, const Args&...);\ 2273 template <typename T>\ 2274 inline void FUNCTION_NAME(const T&); 2276 template <
typename T,
typename... Args>
2277 inline void verbose(
int,
const char*,
const T&,
const Args&...);
2279 template <
typename T>
2280 inline void verbose(
int,
const T&);
2282 LOGGER_LEVEL_WRITERS_SIGNATURES(
info)
2283 LOGGER_LEVEL_WRITERS_SIGNATURES(
debug)
2284 LOGGER_LEVEL_WRITERS_SIGNATURES(warn)
2285 LOGGER_LEVEL_WRITERS_SIGNATURES(
error)
2286 LOGGER_LEVEL_WRITERS_SIGNATURES(fatal)
2287 LOGGER_LEVEL_WRITERS_SIGNATURES(trace)
2288 # undef LOGGER_LEVEL_WRITERS_SIGNATURES 2289 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED 2312 friend class el::base::PerformanceTracker;
2317 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED 2318 template <
typename T,
typename... Args>
2319 void log_(
Level,
int,
const char*,
const T&,
const Args&...);
2321 template <
typename T>
2322 inline void log_(
Level,
int,
const T&);
2324 template <
typename T,
typename... Args>
2325 void log(
Level,
const char*,
const T&,
const Args&...);
2327 template <
typename T>
2329 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED 2331 void initUnflushedCount(
void);
2337 void resolveLoggerFormatSpec(
void)
const;
2351 m_defaultConfigurations.setFromBase(const_cast<Configurations*>(&configurations));
2355 return &m_defaultConfigurations;
2360 template <
typename T>
2362 return base::utils::Utils::installCallback<T, base::type::LoggerRegistrationCallbackPtr>(
id,
2363 &m_loggerRegistrationCallbacks);
2366 template <
typename T>
2368 base::utils::Utils::uninstallCallback<T, base::type::LoggerRegistrationCallbackPtr>(
id, &m_loggerRegistrationCallbacks);
2371 template <
typename T>
2373 return base::utils::Utils::callback<T, base::type::LoggerRegistrationCallbackPtr>(
id, &m_loggerRegistrationCallbacks);
2379 return get(
id,
false) !=
nullptr;
2388 return &m_logStreamsReference;
2398 m_defaultLogBuilder = logBuilderPtr;
2408 void unsafeFlushAll(
void);
2427 void setModules(
const char* modules);
2431 inline const std::unordered_map<std::string, base::type::VerboseLevel>&
modules(
void)
const {
2445 std::unordered_map<std::string, base::type::VerboseLevel>
m_modules;
2452 m_level(level), m_file(file), m_line(line), m_func(func),
2453 m_verboseLevel(verboseLevel), m_logger(logger), m_message(logger->
stream().
str()) {
2468 return m_verboseLevel;
2486 #if ELPP_ASYNC_LOGGING 2487 class AsyncLogItem {
2490 : m_logMessage(logMessage), m_dispatchData(data), m_logLine(logLine) {}
2491 virtual ~AsyncLogItem() {}
2493 return &m_logMessage;
2496 return &m_dispatchData;
2508 virtual ~AsyncLogQueue() {
2512 inline AsyncLogItem
next(
void) {
2514 if (!m_queue.size())
2516 throw (
"Async Logger queue is empty!");
2518 AsyncLogItem
result = m_queue.back();
2523 inline void appendTo(AsyncLogQueue* otherQueue) {
2527 otherQueue->m_queue.insert(otherQueue->m_queue.begin(), m_queue.begin(), m_queue.end());
2531 inline void push(
const AsyncLogItem& item) {
2533 m_queue.push_front(item);
2535 inline void pop(
void) {
2539 inline AsyncLogItem front(
void) {
2541 return m_queue.front();
2543 inline bool empty(
void) {
2545 return m_queue.empty();
2547 inline void clear(
void) {
2551 inline size_t size(
void) {
2553 return m_queue.size();
2556 std::deque<AsyncLogItem> m_queue;
2560 virtual ~IWorker() {}
2561 virtual void start() = 0;
2563 #endif // ELPP_ASYNC_LOGGING 2567 #if ELPP_ASYNC_LOGGING 2568 Storage(
const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker);
2570 explicit Storage(
const LogBuilderPtr& defaultLogBuilder);
2571 #endif // ELPP_ASYNC_LOGGING 2573 virtual ~Storage(
void);
2576 return hitCounters()->validateEveryN(filename, lineNumber, occasion);
2580 return hitCounters()->validateAfterN(filename, lineNumber, n);
2584 return hitCounters()->validateNTimes(filename, lineNumber, n);
2588 return m_registeredHitCounters;
2592 return m_registeredLoggers;
2599 #if ELPP_ASYNC_LOGGING 2600 inline base::AsyncLogQueue* asyncLogWriteQueue(
void)
const {
2601 return m_asyncLogWriteQueue;
2604 inline base::AsyncLogQueue* asyncLogReadQueue(
void)
const {
2605 return m_asyncLogReadQueue;
2608 inline base::AsyncDispatchWorker* asyncDispatchWorker(
void)
const {
2609 return reinterpret_cast<el::base::AsyncDispatchWorker*
>(m_asyncDispatchWorker);
2611 #endif // ELPP_ASYNC_LOGGING 2614 return &m_commandLineArgs;
2646 return m_preRollOutCallback;
2649 bool hasCustomFormatSpecifier(
const char* formatSpecifier);
2651 bool uninstallCustomFormatSpecifier(
const char* formatSpecifier);
2654 return &m_customFormatSpecifiers;
2658 return m_customFormatSpecifiersLock;
2662 m_loggingLevel =
level;
2665 template <
typename T>
2667 return base::utils::Utils::installCallback<T, base::type::LogDispatchCallbackPtr>(
id, &m_logDispatchCallbacks);
2670 template <
typename T>
2672 base::utils::Utils::uninstallCallback<T, base::type::LogDispatchCallbackPtr>(
id, &m_logDispatchCallbacks);
2674 template <
typename T>
2676 return base::utils::Utils::callback<T, base::type::LogDispatchCallbackPtr>(
id, &m_logDispatchCallbacks);
2679 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) 2680 template <
typename T>
2681 inline bool installPerformanceTrackingCallback(
const std::string&
id) {
2682 return base::utils::Utils::installCallback<T, base::type::PerformanceTrackingCallbackPtr>(
id,
2683 &m_performanceTrackingCallbacks);
2686 template <
typename T>
2687 inline void uninstallPerformanceTrackingCallback(
const std::string&
id) {
2688 base::utils::Utils::uninstallCallback<T, base::type::PerformanceTrackingCallbackPtr>(
id,
2689 &m_performanceTrackingCallbacks);
2692 template <
typename T>
2693 inline T* performanceTrackingCallback(
const std::string&
id) {
2694 return base::utils::Utils::callback<T, base::type::PerformanceTrackingCallbackPtr>(
id, &m_performanceTrackingCallbacks);
2696 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) 2700 if (name.empty())
return;
2707 std::unordered_map<std::string, std::string>::const_iterator
it = m_threadNames.find(threadId);
2708 if (it == m_threadNames.end()) {
2713 #if ELPP_ASYNC_LOGGING 2715 #endif // ELPP_ASYNC_LOGGING 2722 #if ELPP_ASYNC_LOGGING 2724 base::AsyncLogQueue* m_asyncLogWriteQueue;
2726 base::AsyncLogQueue* m_asyncLogReadQueue;
2728 base::IWorker* m_asyncDispatchWorker;
2731 #endif // ELPP_ASYNC_LOGGING 2747 friend class el::base::PerformanceTracker;
2750 void setApplicationArguments(
int argc,
char** argv);
2753 setApplicationArguments(argc, const_cast<char**>(argv));
2757 #define ELPP el::base::elStorage 2765 #if ELPP_ASYNC_LOGGING 2772 AsyncDispatchWorker();
2773 virtual ~AsyncDispatchWorker();
2776 void emptyQueue(
void);
2777 virtual void start(
void);
2778 void handle(AsyncLogItem* logItem);
2780 void fetchLogQueue();
2782 void setContinueRunning(
bool value) {
2784 m_continueRunning =
value;
2787 bool continueRunning(
void)
const {
2788 return m_continueRunning;
2791 std::condition_variable
cv;
2792 bool m_continueRunning;
2794 std::thread m_asyncWorkerThread;
2797 #endif // ELPP_ASYNC_LOGGING 2809 m_logMessage(logMessage),
2810 m_dispatchAction(
std::
move(dispatchAction)) {
2813 void dispatch(
void);
2820 #if defined(ELPP_STL_LOGGING) 2821 namespace workarounds {
2829 template <
typename T,
typename Container>
2830 class IterableContainer {
2832 typedef typename Container::iterator iterator;
2833 typedef typename Container::const_iterator const_iterator;
2834 IterableContainer(
void) {}
2835 virtual ~IterableContainer(
void) {}
2836 iterator
begin(
void) {
2837 return getContainer().begin();
2839 iterator
end(
void) {
2840 return getContainer().end();
2843 virtual Container& getContainer(
void) = 0;
2846 template<
typename T,
typename Container = std::vector<T>,
typename Comparator = std::less<
typename Container::value_type>>
2847 class IterablePriorityQueue :
public IterableContainer<T, Container>,
2848 public std::priority_queue<T, Container, Comparator> {
2850 IterablePriorityQueue(std::priority_queue<T, Container, Comparator> queue_) {
2851 std::size_t count_ = 0;
2853 this->push(queue_.top());
2858 inline Container& getContainer(
void) {
2863 template<
typename T,
typename Container = std::deque<T>>
2864 class IterableQueue :
public IterableContainer<T, Container>,
public std::queue<T, Container> {
2866 IterableQueue(std::queue<T, Container> queue_) {
2867 std::size_t count_ = 0;
2869 this->push(queue_.front());
2874 inline Container& getContainer(
void) {
2879 template<
typename T,
typename Container = std::deque<T>>
2880 class IterableStack :
public IterableContainer<T, Container>,
public std::stack<T, Container> {
2882 IterableStack(std::stack<T, Container> stack_) {
2883 std::size_t count_ = 0;
2885 this->push(stack_.top());
2890 inline Container& getContainer(
void) {
2895 #endif // defined(ELPP_STL_LOGGING) 2900 void initialize(
Logger* logger);
2902 # define ELPP_SIMPLE_LOG(LOG_TYPE)\ 2903 MessageBuilder& operator<<(LOG_TYPE msg) {\ 2904 m_logger->stream() << msg;\ 2905 if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {\ 2906 m_logger->stream() << " ";\ 2934 m_logger->stream() << OStreamMani;
2937 #define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp) \ 2938 template <typename T> \ 2939 inline MessageBuilder& operator<<(const temp<T>& template_inst) { \ 2940 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ 2942 #define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp) \ 2943 template <typename T1, typename T2> \ 2944 inline MessageBuilder& operator<<(const temp<T1, T2>& template_inst) { \ 2945 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ 2947 #define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp) \ 2948 template <typename T1, typename T2, typename T3> \ 2949 inline MessageBuilder& operator<<(const temp<T1, T2, T3>& template_inst) { \ 2950 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ 2952 #define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp) \ 2953 template <typename T1, typename T2, typename T3, typename T4> \ 2954 inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4>& template_inst) { \ 2955 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ 2957 #define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp) \ 2958 template <typename T1, typename T2, typename T3, typename T4, typename T5> \ 2959 inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4, T5>& template_inst) { \ 2960 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ 2963 #if defined(ELPP_STL_LOGGING) 2971 template <class
T, class Container>
2972 inline MessageBuilder& operator<<(const
std::queue<T, Container>& queue_) {
2973 base::workarounds::IterableQueue<T, Container> iterableQueue_ =
2974 static_cast<base::workarounds::IterableQueue<T, Container>
>(queue_);
2975 return writeIterator(iterableQueue_.begin(), iterableQueue_.end(), iterableQueue_.size());
2977 template <
class T,
class Container>
2978 inline MessageBuilder& operator<<(const std::stack<T, Container>& stack_) {
2979 base::workarounds::IterableStack<T, Container> iterableStack_ =
2980 static_cast<base::workarounds::IterableStack<T, Container>
>(stack_);
2981 return writeIterator(iterableStack_.begin(), iterableStack_.end(), iterableStack_.size());
2983 template <
class T,
class Container,
class Comparator>
2984 inline MessageBuilder& operator<<(const std::priority_queue<T, Container, Comparator>& priorityQueue_) {
2985 base::workarounds::IterablePriorityQueue<T, Container, Comparator> iterablePriorityQueue_ =
2986 static_cast<base::workarounds::IterablePriorityQueue<T, Container, Comparator>
>(priorityQueue_);
2987 return writeIterator(iterablePriorityQueue_.begin(), iterablePriorityQueue_.end(), iterablePriorityQueue_.size());
2989 template <
class First,
class Second>
2990 MessageBuilder& operator<<(const std::pair<First, Second>& pair_) {
2992 operator << (static_cast<First>(pair_.first));
2994 operator << (static_cast<Second>(pair_.second));
2998 template <std::
size_t Size>
2999 MessageBuilder& operator<<(const std::bitset<Size>& bitset_) {
3005 # if defined(ELPP_LOG_STD_ARRAY) 3006 template <
class T, std::
size_t Size>
3007 inline MessageBuilder& operator<<(const std::array<T, Size>&
array) {
3010 # endif // defined(ELPP_LOG_STD_ARRAY) 3011 # if defined(ELPP_LOG_UNORDERED_MAP) 3014 # endif // defined(ELPP_LOG_UNORDERED_MAP) 3015 # if defined(ELPP_LOG_UNORDERED_SET) 3018 # endif // defined(ELPP_LOG_UNORDERED_SET) 3019 #endif // defined(ELPP_STL_LOGGING) 3020 #if defined(ELPP_QT_LOGGING) 3021 inline MessageBuilder&
operator<<(
const QString& msg) {
3022 # if defined(ELPP_UNICODE) 3023 m_logger->stream() << msg.toStdWString();
3025 m_logger->stream() << msg.toStdString();
3026 # endif // defined(ELPP_UNICODE) 3029 inline MessageBuilder&
operator<<(
const QByteArray& msg) {
3032 inline MessageBuilder&
operator<<(
const QStringRef& msg) {
3035 inline MessageBuilder&
operator<<(qint64 msg) {
3036 # if defined(ELPP_UNICODE) 3037 m_logger->stream() << QString::number(msg).toStdWString();
3039 m_logger->stream() << QString::number(msg).toStdString();
3040 # endif // defined(ELPP_UNICODE) 3043 inline MessageBuilder&
operator<<(quint64 msg) {
3044 # if defined(ELPP_UNICODE) 3045 m_logger->stream() << QString::number(msg).toStdWString();
3047 m_logger->stream() << QString::number(msg).toStdString();
3048 # endif // defined(ELPP_UNICODE) 3051 inline MessageBuilder&
operator<<(QChar msg) {
3052 m_logger->stream() << msg.toLatin1();
3055 inline MessageBuilder&
operator<<(
const QLatin1String& msg) {
3056 m_logger->stream() << msg.latin1();
3065 template <
typename First,
typename Second>
3066 MessageBuilder& operator<<(const QPair<First, Second>& pair_) {
3068 operator << (static_cast<First>(pair_.first));
3070 operator << (static_cast<Second>(pair_.second));
3074 template <
typename K,
typename V>
3075 MessageBuilder& operator<<(const QMap<K, V>& map_) {
3077 QList<K>
keys = map_.keys();
3078 typename QList<K>::const_iterator
begin = keys.begin();
3079 typename QList<K>::const_iterator
end = keys.end();
3081 for (
int index_ = 0; begin != end && index_ < max_; ++index_, ++
begin) {
3083 operator << (static_cast<K>(*begin));
3085 operator << (static_cast<V>(map_.value(*begin)));
3087 m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator :
ELPP_LITERAL(
""));
3095 template <
typename K,
typename V>
3096 inline MessageBuilder& operator<<(const QMultiMap<K, V>& map_) {
3097 operator << (static_cast<QMap<K, V>>(map_));
3100 template <
typename K,
typename V>
3101 MessageBuilder& operator<<(const QHash<K, V>& hash_) {
3103 QList<K>
keys = hash_.keys();
3104 typename QList<K>::const_iterator
begin = keys.begin();
3105 typename QList<K>::const_iterator
end = keys.end();
3107 for (
int index_ = 0; begin != end && index_ < max_; ++index_, ++
begin) {
3109 operator << (static_cast<K>(*begin));
3111 operator << (static_cast<V>(hash_.value(*begin)));
3113 m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator :
ELPP_LITERAL(
""));
3121 template <
typename K,
typename V>
3122 inline MessageBuilder& operator<<(const QMultiHash<K, V>& multiHash_) {
3123 operator << (static_cast<QHash<K, V>>(multiHash_));
3126 #endif // defined(ELPP_QT_LOGGING) 3127 #if defined(ELPP_BOOST_LOGGING) 3136 #endif // defined(ELPP_BOOST_LOGGING) 3146 #define MAKE_CONTAINERELPP_FRIENDLY(ContainerType, SizeMethod, ElementInstance) \ 3147 el::base::type::ostream_t& operator<<(el::base::type::ostream_t& ss, const ContainerType& container) {\ 3148 const el::base::type::char_t* sep = ELPP->hasFlag(el::LoggingFlag::NewLineForContainer) ? \ 3149 ELPP_LITERAL("\n ") : ELPP_LITERAL(", ");\ 3150 ContainerType::const_iterator elem = container.begin();\ 3151 ContainerType::const_iterator endElem = container.end();\ 3152 std::size_t size_ = container.SizeMethod; \ 3153 ss << ELPP_LITERAL("[");\ 3154 for (std::size_t i = 0; elem != endElem && i < el::base::consts::kMaxLogPerContainer; ++i, ++elem) { \ 3155 ss << ElementInstance;\ 3156 ss << ((i < size_ - 1) ? sep : ELPP_LITERAL(""));\ 3158 if (elem != endElem) {\ 3159 ss << ELPP_LITERAL("...");\ 3161 ss << ELPP_LITERAL("]");\ 3164 #if defined(ELPP_WXWIDGETS_LOGGING) 3166 # define ELPP_WX_PTR_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), *(*elem)) 3167 # define ELPP_WX_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), (*elem)) 3168 # define ELPP_WX_HASH_MAP_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), \ 3169 ELPP_LITERAL("(") << elem->first << ELPP_LITERAL(", ") << elem->second << ELPP_LITERAL(")") 3171 # define ELPP_WX_PTR_ENABLED(ContainerType) 3172 # define ELPP_WX_ENABLED(ContainerType) 3173 # define ELPP_WX_HASH_MAP_ENABLED(ContainerType) 3174 #endif // defined(ELPP_WXWIDGETS_LOGGING) 3176 template <
class Class>
3178 #undef ELPP_SIMPLE_LOG 3179 #undef ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG 3180 #undef ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG 3181 #undef ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG 3182 #undef ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG 3183 #undef ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG 3188 template<
class Iterator>
3195 if (begin_ != end_) {
3200 m_logger->
stream() <<
" ";
3215 template <
typename T>
3220 inline operator bool() {
3230 m_msg(nullptr), m_level(level), m_file(file), m_line(line), m_func(func), m_verboseLevel(verboseLevel),
3231 m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction) {
3236 m_line(0), m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction) {
3243 template <
typename T>
3245 #if ELPP_LOGGING_ENABLED 3247 m_messageBuilder <<
log;
3249 #endif // ELPP_LOGGING_ENABLED 3254 #if ELPP_LOGGING_ENABLED 3256 m_messageBuilder <<
log;
3258 #endif // ELPP_LOGGING_ENABLED 3262 inline operator bool() {
3282 void initializeLogger(
const std::string& loggerId,
bool lookup =
true,
bool needLock =
true);
3283 void processDispatch();
3284 void triggerDispatch(
void);
3291 base::
Writer(level, file, line, func, dispatchAction, verboseLevel) {
3298 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED 3299 template <
typename T,
typename... Args>
3311 log_(level, vlevel, ++s, args...);
3318 ELPP_INTERNAL_ERROR(
"Too many arguments provided. Unable to handle. Please provide more format specifiers",
false);
3320 template <
typename T>
3321 void Logger::log_(
Level level,
int vlevel,
const T&
log) {
3323 if (
ELPP->vRegistry()->allowed(vlevel, __FILE__)) {
3334 template <
typename T,
typename... Args>
3335 inline void Logger::log(
Level level,
const char* s,
const T& value,
const Args&... args) {
3337 log_(level, 0, s, value, args...);
3339 template <
typename T>
3342 log_(level, 0, log);
3344 # if ELPP_VERBOSE_LOG 3345 template <
typename T,
typename... Args>
3346 inline void Logger::verbose(
int vlevel,
const char* s,
const T& value,
const Args&... args) {
3350 template <
typename T>
3351 inline void Logger::verbose(
int vlevel,
const T& log) {
3356 template <
typename T,
typename... Args>
3357 inline void Logger::verbose(
int,
const char*,
const T&,
const Args&...) {
3360 template <
typename T>
3361 inline void Logger::verbose(
int,
const T&) {
3364 # endif // ELPP_VERBOSE_LOG 3365 # define LOGGER_LEVEL_WRITERS(FUNCTION_NAME, LOG_LEVEL)\ 3366 template <typename T, typename... Args>\ 3367 inline void Logger::FUNCTION_NAME(const char* s, const T& value, const Args&... args) {\ 3368 log(LOG_LEVEL, s, value, args...);\ 3370 template <typename T>\ 3371 inline void Logger::FUNCTION_NAME(const T& value) {\ 3372 log(LOG_LEVEL, value);\ 3374 # define LOGGER_LEVEL_WRITERS_DISABLED(FUNCTION_NAME, LOG_LEVEL)\ 3375 template <typename T, typename... Args>\ 3376 inline void Logger::FUNCTION_NAME(const char*, const T&, const Args&...) {\ 3379 template <typename T>\ 3380 inline void Logger::FUNCTION_NAME(const T&) {\ 3388 # endif // ELPP_INFO_LOG 3393 # endif // ELPP_DEBUG_LOG 3394 # if ELPP_WARNING_LOG 3398 # endif // ELPP_WARNING_LOG 3403 # endif // ELPP_ERROR_LOG 3408 # endif // ELPP_FATAL_LOG 3413 # endif // ELPP_TRACE_LOG 3414 # undef LOGGER_LEVEL_WRITERS 3415 # undef LOGGER_LEVEL_WRITERS_DISABLED 3416 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED 3417 #if ELPP_COMPILER_MSVC 3418 # define ELPP_VARIADIC_FUNC_MSVC(variadicFunction, variadicArgs) variadicFunction variadicArgs 3419 # define ELPP_VARIADIC_FUNC_MSVC_RUN(variadicFunction, ...) ELPP_VARIADIC_FUNC_MSVC(variadicFunction, (__VA_ARGS__)) 3420 # define el_getVALength(...) ELPP_VARIADIC_FUNC_MSVC_RUN(el_resolveVALength, 0, ## __VA_ARGS__,\ 3421 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 3423 # if ELPP_COMPILER_CLANG 3424 # define el_getVALength(...) el_resolveVALength(0, __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 3426 # define el_getVALength(...) el_resolveVALength(0, ## __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 3427 # endif // ELPP_COMPILER_CLANG 3428 #endif // ELPP_COMPILER_MSVC 3429 #define el_resolveVALength(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N 3430 #define ELPP_WRITE_LOG(writer, level, dispatchAction, ...) \ 3431 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) 3432 #define ELPP_WRITE_LOG_IF(writer, condition, level, dispatchAction, ...) if (condition) \ 3433 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) 3434 #define ELPP_WRITE_LOG_EVERY_N(writer, occasion, level, dispatchAction, ...) \ 3435 ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion) && \ 3436 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) 3437 #define ELPP_WRITE_LOG_AFTER_N(writer, n, level, dispatchAction, ...) \ 3438 ELPP->validateAfterNCounter(__FILE__, __LINE__, n) && \ 3439 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) 3440 #define ELPP_WRITE_LOG_N_TIMES(writer, n, level, dispatchAction, ...) \ 3441 ELPP->validateNTimesCounter(__FILE__, __LINE__, n) && \ 3442 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) 3443 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) 3444 class PerformanceTrackingData {
3447 Checkpoint = 1, Complete = 2
3450 explicit PerformanceTrackingData(DataType dataType) : m_performanceTracker(
nullptr),
3451 m_dataType(dataType), m_firstCheckpoint(
false), m_file(
""), m_line(0), m_func(
"") {}
3453 inline const struct timeval* startTime(
void)
const;
3454 inline const struct timeval* endTime(
void)
const;
3455 inline const struct timeval* lastCheckpointTime(
void)
const;
3456 inline const base::PerformanceTracker* performanceTracker(
void)
const {
3457 return m_performanceTracker;
3459 inline PerformanceTrackingData::DataType dataType(
void)
const {
3462 inline bool firstCheckpoint(
void)
const {
3463 return m_firstCheckpoint;
3466 return m_checkpointId;
3468 inline const char* file(
void)
const {
3474 inline const char*
func(
void)
const {
3478 return &m_formattedTimeTaken;
3482 base::PerformanceTracker* m_performanceTracker;
3484 PerformanceTrackingData::DataType m_dataType;
3485 bool m_firstCheckpoint;
3490 inline void init(base::PerformanceTracker* performanceTracker,
bool firstCheckpoint =
false) {
3491 m_performanceTracker = performanceTracker;
3492 m_firstCheckpoint = firstCheckpoint;
3495 friend class el::base::PerformanceTracker;
3500 class PerformanceTracker :
public base::threading::ThreadSafe,
public Loggable {
3507 PerformanceTracker(
const PerformanceTracker&
t) :
3508 m_blockName(t.m_blockName), m_timestampUnit(t.m_timestampUnit), m_loggerId(t.m_loggerId), m_scopedLog(t.m_scopedLog),
3509 m_level(t.m_level), m_hasChecked(t.m_hasChecked), m_lastCheckpointId(t.m_lastCheckpointId), m_enabled(t.m_enabled),
3510 m_startTime(t.m_startTime), m_endTime(t.m_endTime), m_lastCheckpointTime(t.m_lastCheckpointTime) {
3512 virtual ~PerformanceTracker(
void);
3516 const char*
func =
"");
3529 struct timeval m_startTime, m_endTime, m_lastCheckpointTime;
3531 PerformanceTracker(
void);
3533 friend class el::PerformanceTrackingData;
3534 friend class base::DefaultPerformanceTrackingCallback;
3537 return getFormattedTimeTaken(m_startTime);
3543 os << getFormattedTimeTaken();
3546 class DefaultPerformanceTrackingCallback :
public PerformanceTrackingCallback {
3548 void handle(
const PerformanceTrackingData*
data) {
3551 if (m_data->dataType() == PerformanceTrackingData::DataType::Complete) {
3556 if (!m_data->checkpointId().empty()) {
3560 *m_data->performanceTracker();
3562 && m_data->performanceTracker()->m_hasChecked) {
3564 if (m_data->performanceTracker()->m_lastCheckpointId.empty()) {
3567 ss <<
ELPP_LITERAL(
"checkpoint '") << m_data->performanceTracker()->m_lastCheckpointId.c_str() <<
ELPP_LITERAL(
"'");
3575 m_data->loggerId().c_str()) << ss.str();
3578 const PerformanceTrackingData* m_data;
3581 inline const std::string* PerformanceTrackingData::blockName()
const {
3582 return const_cast<const std::string*
>(&m_performanceTracker->m_blockName);
3584 inline const struct timeval* PerformanceTrackingData::startTime()
const {
3585 return const_cast<const struct timeval*
>(&m_performanceTracker->m_startTime);
3587 inline const struct timeval* PerformanceTrackingData::endTime()
const {
3588 return const_cast<const struct timeval*
>(&m_performanceTracker->m_endTime);
3590 inline const struct timeval* PerformanceTrackingData::lastCheckpointTime()
const {
3591 return const_cast<const struct timeval*
>(&m_performanceTracker->m_lastCheckpointTime);
3593 inline const std::string& PerformanceTrackingData::loggerId(
void)
const {
3594 return m_performanceTracker->m_loggerId;
3596 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) 3600 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) 3601 class StackTrace : base::NoCopy {
3603 static const unsigned int kMaxStack = 64;
3604 static const unsigned int kStackStart = 2;
3605 class StackTraceEntry {
3609 StackTraceEntry(std::size_t index,
const std::string& loc) :
3613 std::size_t m_index;
3618 friend std::ostream&
operator<<(std::ostream& ss,
const StackTraceEntry& si);
3621 StackTraceEntry(
void);
3628 virtual ~StackTrace(
void) {
3631 inline std::vector<StackTraceEntry>& getLatestStack(
void) {
3635 friend std::ostream&
operator<<(std::ostream& os,
const StackTrace&
st);
3638 std::vector<StackTraceEntry> m_stack;
3640 void generateNew(
void);
3645 typedef void (*Handler)(int);
3649 setHandler(cHandler);
3651 void setHandler(
const Handler& cHandler);
3661 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) 3665 #define MAKE_LOGGABLE(ClassType, ClassInstance, OutputStreamInstance) \ 3666 el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamInstance, const ClassType& ClassInstance) 3667 class SysLogInitializer {
3671 #if defined(ELPP_SYSLOG) 3672 openlog(processIdent, options, facility);
3677 #endif // defined(ELPP_SYSLOG) 3680 #if defined(ELPP_SYSLOG) 3682 #endif // defined(ELPP_SYSLOG) 3685 #define ELPP_INITIALIZE_SYSLOG(id, opt, fac) el::SysLogInitializer elSyslogInit(id, opt, fac) 3686 class Helpers : base::StaticClass {
3698 static inline void setArgs(
int argc,
char** argv) {
3699 ELPP->setApplicationArguments(argc, argv);
3702 static inline void setArgs(
int argc,
const char** argv) {
3703 ELPP->setApplicationArguments(argc, const_cast<char**>(argv));
3707 ELPP->setThreadName(name);
3712 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) 3713 static inline void setCrashHandler(
const el::base::debug::CrashHandler::Handler& crashHandler) {
3721 static void crashAbort(
int sig,
const char* sourceFile =
"",
unsigned int long line = 0);
3727 static void logCrashReason(
int sig,
bool stackTraceIfAvailable =
false,
3729 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) 3730 static inline void installPreRollOutCallback(
const PreRollOutCallback&
callback) {
3733 ELPP->setPreRollOutCallback(callback);
3737 ELPP->unsetPreRollOutCallback();
3740 template <
typename T>
3742 return ELPP->installLogDispatchCallback<
T>(
id);
3745 template <
typename T>
3747 ELPP->uninstallLogDispatchCallback<
T>(
id);
3749 template <
typename T>
3751 return ELPP->logDispatchCallback<
T>(
id);
3753 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) 3754 template <
typename T>
3756 static inline bool installPerformanceTrackingCallback(
const std::string&
id) {
3757 return ELPP->installPerformanceTrackingCallback<
T>(
id);
3760 template <
typename T>
3761 static inline void uninstallPerformanceTrackingCallback(
const std::string&
id) {
3762 ELPP->uninstallPerformanceTrackingCallback<
T>(
id);
3764 template <
typename T>
3765 static inline T* performanceTrackingCallback(
const std::string&
id) {
3766 return ELPP->performanceTrackingCallback<
T>(
id);
3768 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) 3769 template <
typename T>
3774 if (logger ==
nullptr) {
3781 #if defined(ELPP_UNICODE) 3785 #endif // defined(ELPP_UNICODE) 3792 return ELPP->commandLineArgs();
3797 ELPP->m_customFormatSpecifiers.reserve(size);
3801 ELPP->installCustomFormatSpecifier(customFormatSpecifier);
3805 return ELPP->uninstallCustomFormatSpecifier(formatSpecifier);
3809 return ELPP->hasCustomFormatSpecifier(formatSpecifier);
3812 if (logger ==
nullptr)
return;
3820 static Logger* getLogger(
const std::string& identity,
bool registerIfNotAvailable =
true);
3824 template <
typename T>
3826 return ELPP->registeredLoggers()->installLoggerRegistrationCallback<
T>(
id);
3829 template <
typename T>
3831 ELPP->registeredLoggers()->uninstallLoggerRegistrationCallback<
T>(
id);
3833 template <
typename T>
3835 return ELPP->registeredLoggers()->loggerRegistrationCallback<
T>(
id);
3839 static bool unregisterLogger(
const std::string& identity);
3841 static bool hasLogger(
const std::string& identity);
3850 static void reconfigureAllLoggers(
const Configurations& configurations);
3853 reconfigureAllLoggers(
Level::Global, configurationType, value);
3859 static void setDefaultConfigurations(
const Configurations& configurations,
3860 bool reconfigureExistingLoggers =
false);
3869 static std::vector<std::string>* populateAllLoggerIds(std::vector<std::string>* targetList);
3871 static void configureFromGlobal(
const char* globalConfigurationFilePath);
3876 static bool configureFromArg(
const char* argKey);
3878 static void flushAll(
void);
3881 ELPP->addFlag(flag);
3885 ELPP->removeFlag(flag);
3889 return ELPP->hasFlag(flag);
3917 ELPP->setLoggingLevel(level);
3924 static void setVModules(
const char* modules);
3926 static void clearVModules(
void);
3938 #define VLOG_IS_ON(verboseLevel) (ELPP->vRegistry()->allowed(verboseLevel, __FILE__)) 3942 #undef TIMED_SCOPE_IF 3944 #undef TIMED_FUNC_IF 3945 #undef ELPP_MIN_UNIT 3946 #if defined(ELPP_PERFORMANCE_MICROSECONDS) 3947 # define ELPP_MIN_UNIT el::base::TimestampUnit::Microsecond 3949 # define ELPP_MIN_UNIT el::base::TimestampUnit::Millisecond 3950 #endif // (defined(ELPP_PERFORMANCE_MICROSECONDS)) 3958 #define TIMED_SCOPE_IF(obj, blockname, condition) el::base::type::PerformanceTrackerPtr obj( condition ? \ 3959 new el::base::PerformanceTracker(blockname, ELPP_MIN_UNIT) : nullptr ) 3960 #define TIMED_SCOPE(obj, blockname) TIMED_SCOPE_IF(obj, blockname, true) 3961 #define TIMED_BLOCK(obj, blockName) for (struct { int i; el::base::type::PerformanceTrackerPtr timer; } obj = { 0, \ 3962 el::base::type::PerformanceTrackerPtr(new el::base::PerformanceTracker(blockName, ELPP_MIN_UNIT)) }; obj.i < 1; ++obj.i) 3963 #define TIMED_FUNC_IF(obj,condition) TIMED_SCOPE_IF(obj, ELPP_FUNC, condition) 3970 #define TIMED_FUNC(obj) TIMED_SCOPE(obj, ELPP_FUNC) 3971 #undef PERFORMANCE_CHECKPOINT 3972 #undef PERFORMANCE_CHECKPOINT_WITH_ID 3973 #define PERFORMANCE_CHECKPOINT(obj) obj->checkpoint(std::string(), __FILE__, __LINE__, ELPP_FUNC) 3974 #define PERFORMANCE_CHECKPOINT_WITH_ID(obj, id) obj->checkpoint(id, __FILE__, __LINE__, ELPP_FUNC) 3976 #undef ELPP_COUNTER_POS 3977 #define ELPP_COUNTER (ELPP->hitCounters()->getCounter(__FILE__, __LINE__)) 3979 #define ELPP_COUNTER_POS (ELPP_COUNTER == nullptr ? -1 : ELPP_COUNTER->hitCounts()) 4004 #undef CINFO_EVERY_N 4005 #undef CWARNING_EVERY_N 4006 #undef CDEBUG_EVERY_N 4007 #undef CERROR_EVERY_N 4008 #undef CFATAL_EVERY_N 4009 #undef CTRACE_EVERY_N 4010 #undef CVERBOSE_EVERY_N 4011 #undef CINFO_AFTER_N 4012 #undef CWARNING_AFTER_N 4013 #undef CDEBUG_AFTER_N 4014 #undef CERROR_AFTER_N 4015 #undef CFATAL_AFTER_N 4016 #undef CTRACE_AFTER_N 4017 #undef CVERBOSE_AFTER_N 4018 #undef CINFO_N_TIMES 4019 #undef CWARNING_N_TIMES 4020 #undef CDEBUG_N_TIMES 4021 #undef CERROR_N_TIMES 4022 #undef CFATAL_N_TIMES 4023 #undef CTRACE_N_TIMES 4024 #undef CVERBOSE_N_TIMES 4027 # define CINFO(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Info, dispatchAction, __VA_ARGS__) 4029 # define CINFO(writer, dispatchAction, ...) el::base::NullWriter() 4030 #endif // ELPP_INFO_LOG 4031 #if ELPP_WARNING_LOG 4032 # define CWARNING(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Warning, dispatchAction, __VA_ARGS__) 4034 # define CWARNING(writer, dispatchAction, ...) el::base::NullWriter() 4035 #endif // ELPP_WARNING_LOG 4037 # define CDEBUG(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Debug, dispatchAction, __VA_ARGS__) 4039 # define CDEBUG(writer, dispatchAction, ...) el::base::NullWriter() 4040 #endif // ELPP_DEBUG_LOG 4042 # define CERROR(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Error, dispatchAction, __VA_ARGS__) 4044 # define CERROR(writer, dispatchAction, ...) el::base::NullWriter() 4045 #endif // ELPP_ERROR_LOG 4047 # define CFATAL(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Fatal, dispatchAction, __VA_ARGS__) 4049 # define CFATAL(writer, dispatchAction, ...) el::base::NullWriter() 4050 #endif // ELPP_FATAL_LOG 4052 # define CTRACE(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Trace, dispatchAction, __VA_ARGS__) 4054 # define CTRACE(writer, dispatchAction, ...) el::base::NullWriter() 4055 #endif // ELPP_TRACE_LOG 4056 #if ELPP_VERBOSE_LOG 4057 # define CVERBOSE(writer, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel)) writer(\ 4058 el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) 4060 # define CVERBOSE(writer, vlevel, dispatchAction, ...) el::base::NullWriter() 4061 #endif // ELPP_VERBOSE_LOG 4064 # define CINFO_IF(writer, condition_, dispatchAction, ...) \ 4065 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Info, dispatchAction, __VA_ARGS__) 4067 # define CINFO_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() 4068 #endif // ELPP_INFO_LOG 4069 #if ELPP_WARNING_LOG 4070 # define CWARNING_IF(writer, condition_, dispatchAction, ...)\ 4071 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Warning, dispatchAction, __VA_ARGS__) 4073 # define CWARNING_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() 4074 #endif // ELPP_WARNING_LOG 4076 # define CDEBUG_IF(writer, condition_, dispatchAction, ...)\ 4077 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Debug, dispatchAction, __VA_ARGS__) 4079 # define CDEBUG_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() 4080 #endif // ELPP_DEBUG_LOG 4082 # define CERROR_IF(writer, condition_, dispatchAction, ...)\ 4083 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Error, dispatchAction, __VA_ARGS__) 4085 # define CERROR_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() 4086 #endif // ELPP_ERROR_LOG 4088 # define CFATAL_IF(writer, condition_, dispatchAction, ...)\ 4089 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Fatal, dispatchAction, __VA_ARGS__) 4091 # define CFATAL_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() 4092 #endif // ELPP_FATAL_LOG 4094 # define CTRACE_IF(writer, condition_, dispatchAction, ...)\ 4095 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Trace, dispatchAction, __VA_ARGS__) 4097 # define CTRACE_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() 4098 #endif // ELPP_TRACE_LOG 4099 #if ELPP_VERBOSE_LOG 4100 # define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel) && (condition_)) writer( \ 4101 el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) 4103 # define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) el::base::NullWriter() 4104 #endif // ELPP_VERBOSE_LOG 4107 # define CINFO_EVERY_N(writer, occasion, dispatchAction, ...)\ 4108 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Info, dispatchAction, __VA_ARGS__) 4110 # define CINFO_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() 4111 #endif // ELPP_INFO_LOG 4112 #if ELPP_WARNING_LOG 4113 # define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...)\ 4114 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Warning, dispatchAction, __VA_ARGS__) 4116 # define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() 4117 #endif // ELPP_WARNING_LOG 4119 # define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...)\ 4120 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Debug, dispatchAction, __VA_ARGS__) 4122 # define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() 4123 #endif // ELPP_DEBUG_LOG 4125 # define CERROR_EVERY_N(writer, occasion, dispatchAction, ...)\ 4126 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Error, dispatchAction, __VA_ARGS__) 4128 # define CERROR_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() 4129 #endif // ELPP_ERROR_LOG 4131 # define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...)\ 4132 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Fatal, dispatchAction, __VA_ARGS__) 4134 # define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() 4135 #endif // ELPP_FATAL_LOG 4137 # define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...)\ 4138 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Trace, dispatchAction, __VA_ARGS__) 4140 # define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() 4141 #endif // ELPP_TRACE_LOG 4142 #if ELPP_VERBOSE_LOG 4143 # define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...)\ 4144 CVERBOSE_IF(writer, ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion), vlevel, dispatchAction, __VA_ARGS__) 4146 # define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...) el::base::NullWriter() 4147 #endif // ELPP_VERBOSE_LOG 4150 # define CINFO_AFTER_N(writer, n, dispatchAction, ...)\ 4151 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__) 4153 # define CINFO_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() 4154 #endif // ELPP_INFO_LOG 4155 #if ELPP_WARNING_LOG 4156 # define CWARNING_AFTER_N(writer, n, dispatchAction, ...)\ 4157 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__) 4159 # define CWARNING_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() 4160 #endif // ELPP_WARNING_LOG 4162 # define CDEBUG_AFTER_N(writer, n, dispatchAction, ...)\ 4163 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__) 4165 # define CDEBUG_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() 4166 #endif // ELPP_DEBUG_LOG 4168 # define CERROR_AFTER_N(writer, n, dispatchAction, ...)\ 4169 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__) 4171 # define CERROR_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() 4172 #endif // ELPP_ERROR_LOG 4174 # define CFATAL_AFTER_N(writer, n, dispatchAction, ...)\ 4175 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__) 4177 # define CFATAL_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() 4178 #endif // ELPP_FATAL_LOG 4180 # define CTRACE_AFTER_N(writer, n, dispatchAction, ...)\ 4181 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__) 4183 # define CTRACE_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() 4184 #endif // ELPP_TRACE_LOG 4185 #if ELPP_VERBOSE_LOG 4186 # define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...)\ 4187 CVERBOSE_IF(writer, ELPP->validateAfterNCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__) 4189 # define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter() 4190 #endif // ELPP_VERBOSE_LOG 4193 # define CINFO_N_TIMES(writer, n, dispatchAction, ...)\ 4194 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__) 4196 # define CINFO_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() 4197 #endif // ELPP_INFO_LOG 4198 #if ELPP_WARNING_LOG 4199 # define CWARNING_N_TIMES(writer, n, dispatchAction, ...)\ 4200 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__) 4202 # define CWARNING_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() 4203 #endif // ELPP_WARNING_LOG 4205 # define CDEBUG_N_TIMES(writer, n, dispatchAction, ...)\ 4206 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__) 4208 # define CDEBUG_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() 4209 #endif // ELPP_DEBUG_LOG 4211 # define CERROR_N_TIMES(writer, n, dispatchAction, ...)\ 4212 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__) 4214 # define CERROR_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() 4215 #endif // ELPP_ERROR_LOG 4217 # define CFATAL_N_TIMES(writer, n, dispatchAction, ...)\ 4218 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__) 4220 # define CFATAL_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() 4221 #endif // ELPP_FATAL_LOG 4223 # define CTRACE_N_TIMES(writer, n, dispatchAction, ...)\ 4224 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__) 4226 # define CTRACE_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() 4227 #endif // ELPP_TRACE_LOG 4228 #if ELPP_VERBOSE_LOG 4229 # define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...)\ 4230 CVERBOSE_IF(writer, ELPP->validateNTimesCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__) 4232 # define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter() 4233 #endif // ELPP_VERBOSE_LOG 4242 #undef CLOG_VERBOSE_IF 4245 #undef CVLOG_EVERY_N 4247 #undef CVLOG_AFTER_N 4249 #undef CVLOG_N_TIMES 4251 #define CLOG(LEVEL, ...)\ 4252 C##LEVEL(el::base::Writer, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4253 #define CVLOG(vlevel, ...) CVERBOSE(el::base::Writer, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4255 #define CLOG_IF(condition, LEVEL, ...)\ 4256 C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4257 #define CVLOG_IF(condition, vlevel, ...)\ 4258 CVERBOSE_IF(el::base::Writer, condition, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4260 #define CLOG_EVERY_N(n, LEVEL, ...)\ 4261 C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4262 #define CVLOG_EVERY_N(n, vlevel, ...)\ 4263 CVERBOSE_EVERY_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4264 #define CLOG_AFTER_N(n, LEVEL, ...)\ 4265 C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4266 #define CVLOG_AFTER_N(n, vlevel, ...)\ 4267 CVERBOSE_AFTER_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4268 #define CLOG_N_TIMES(n, LEVEL, ...)\ 4269 C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4270 #define CVLOG_N_TIMES(n, vlevel, ...)\ 4271 CVERBOSE_N_TIMES(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4286 #undef ELPP_CURR_FILE_LOGGER_ID 4287 #if defined(ELPP_DEFAULT_LOGGER) 4288 # define ELPP_CURR_FILE_LOGGER_ID ELPP_DEFAULT_LOGGER 4290 # define ELPP_CURR_FILE_LOGGER_ID el::base::consts::kDefaultLoggerId 4293 #define ELPP_TRACE CLOG(TRACE, ELPP_CURR_FILE_LOGGER_ID) 4295 #define LOG(LEVEL) CLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4296 #define VLOG(vlevel) CVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID) 4298 #define LOG_IF(condition, LEVEL) CLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4299 #define VLOG_IF(condition, vlevel) CVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4301 #define LOG_EVERY_N(n, LEVEL) CLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4302 #define VLOG_EVERY_N(n, vlevel) CVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4303 #define LOG_AFTER_N(n, LEVEL) CLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4304 #define VLOG_AFTER_N(n, vlevel) CVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4305 #define LOG_N_TIMES(n, LEVEL) CLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4306 #define VLOG_N_TIMES(n, vlevel) CVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4316 #define CPLOG(LEVEL, ...)\ 4317 C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4318 #define CPLOG_IF(condition, LEVEL, ...)\ 4319 C##LEVEL##_IF(el::base::PErrorWriter, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4320 #define DCPLOG(LEVEL, ...)\ 4321 if (ELPP_DEBUG_LOG) C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__) 4322 #define DCPLOG_IF(condition, LEVEL, ...)\ 4323 C##LEVEL##_IF(el::base::PErrorWriter, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::NormalLog, __VA_ARGS__) 4324 #define PLOG(LEVEL) CPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4325 #define PLOG_IF(condition, LEVEL) CPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4326 #define DPLOG(LEVEL) DCPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4327 #define DPLOG_IF(condition, LEVEL) DCPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4331 #undef CSYSLOG_EVERY_N 4332 #undef CSYSLOG_AFTER_N 4333 #undef CSYSLOG_N_TIMES 4336 #undef SYSLOG_EVERY_N 4337 #undef SYSLOG_AFTER_N 4338 #undef SYSLOG_N_TIMES 4341 #undef DCSYSLOG_EVERY_N 4342 #undef DCSYSLOG_AFTER_N 4343 #undef DCSYSLOG_N_TIMES 4346 #undef DSYSLOG_EVERY_N 4347 #undef DSYSLOG_AFTER_N 4348 #undef DSYSLOG_N_TIMES 4349 #if defined(ELPP_SYSLOG) 4350 # define CSYSLOG(LEVEL, ...)\ 4351 C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__) 4352 # define CSYSLOG_IF(condition, LEVEL, ...)\ 4353 C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::SysLog, __VA_ARGS__) 4354 # define CSYSLOG_EVERY_N(n, LEVEL, ...) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) 4355 # define CSYSLOG_AFTER_N(n, LEVEL, ...) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) 4356 # define CSYSLOG_N_TIMES(n, LEVEL, ...) C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) 4357 # define SYSLOG(LEVEL) CSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId) 4358 # define SYSLOG_IF(condition, LEVEL) CSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId) 4359 # define SYSLOG_EVERY_N(n, LEVEL) CSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId) 4360 # define SYSLOG_AFTER_N(n, LEVEL) CSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId) 4361 # define SYSLOG_N_TIMES(n, LEVEL) CSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId) 4362 # define DCSYSLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__) 4363 # define DCSYSLOG_IF(condition, LEVEL, ...)\ 4364 C##LEVEL##_IF(el::base::Writer, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::SysLog, __VA_ARGS__) 4365 # define DCSYSLOG_EVERY_N(n, LEVEL, ...)\ 4366 if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) 4367 # define DCSYSLOG_AFTER_N(n, LEVEL, ...)\ 4368 if (ELPP_DEBUG_LOG) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) 4369 # define DCSYSLOG_N_TIMES(n, LEVEL, ...)\ 4370 if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) 4371 # define DSYSLOG(LEVEL) DCSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId) 4372 # define DSYSLOG_IF(condition, LEVEL) DCSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId) 4373 # define DSYSLOG_EVERY_N(n, LEVEL) DCSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId) 4374 # define DSYSLOG_AFTER_N(n, LEVEL) DCSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId) 4375 # define DSYSLOG_N_TIMES(n, LEVEL) DCSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId) 4377 # define CSYSLOG(LEVEL, ...) el::base::NullWriter() 4378 # define CSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter() 4379 # define CSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter() 4380 # define CSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter() 4381 # define CSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter() 4382 # define SYSLOG(LEVEL) el::base::NullWriter() 4383 # define SYSLOG_IF(condition, LEVEL) el::base::NullWriter() 4384 # define SYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter() 4385 # define SYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter() 4386 # define SYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter() 4387 # define DCSYSLOG(LEVEL, ...) el::base::NullWriter() 4388 # define DCSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter() 4389 # define DCSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter() 4390 # define DCSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter() 4391 # define DCSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter() 4392 # define DSYSLOG(LEVEL) el::base::NullWriter() 4393 # define DSYSLOG_IF(condition, LEVEL) el::base::NullWriter() 4394 # define DSYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter() 4395 # define DSYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter() 4396 # define DSYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter() 4397 #endif // defined(ELPP_SYSLOG) 4406 #undef DCLOG_EVERY_N 4407 #undef DCVLOG_EVERY_N 4408 #undef DCLOG_AFTER_N 4409 #undef DCVLOG_AFTER_N 4410 #undef DCLOG_N_TIMES 4411 #undef DCVLOG_N_TIMES 4413 #define DCLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG(LEVEL, __VA_ARGS__) 4414 #define DCLOG_VERBOSE(vlevel, ...) if (ELPP_DEBUG_LOG) CLOG_VERBOSE(vlevel, __VA_ARGS__) 4415 #define DCVLOG(vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG(vlevel, __VA_ARGS__) 4417 #define DCLOG_IF(condition, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_IF(condition, LEVEL, __VA_ARGS__) 4418 #define DCVLOG_IF(condition, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_IF(condition, vlevel, __VA_ARGS__) 4420 #define DCLOG_EVERY_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_EVERY_N(n, LEVEL, __VA_ARGS__) 4421 #define DCVLOG_EVERY_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_EVERY_N(n, vlevel, __VA_ARGS__) 4422 #define DCLOG_AFTER_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_AFTER_N(n, LEVEL, __VA_ARGS__) 4423 #define DCVLOG_AFTER_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_AFTER_N(n, vlevel, __VA_ARGS__) 4424 #define DCLOG_N_TIMES(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_N_TIMES(n, LEVEL, __VA_ARGS__) 4425 #define DCVLOG_N_TIMES(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_N_TIMES(n, vlevel, __VA_ARGS__) 4429 #if !defined(ELPP_NO_DEBUG_MACROS) 4436 #undef DVLOG_EVERY_N 4438 #undef DVLOG_AFTER_N 4440 #undef DVLOG_N_TIMES 4442 #define DLOG(LEVEL) DCLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4443 #define DVLOG(vlevel) DCVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID) 4445 #define DLOG_IF(condition, LEVEL) DCLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4446 #define DVLOG_IF(condition, vlevel) DCVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4448 #define DLOG_EVERY_N(n, LEVEL) DCLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4449 #define DVLOG_EVERY_N(n, vlevel) DCVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4450 #define DLOG_AFTER_N(n, LEVEL) DCLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4451 #define DVLOG_AFTER_N(n, vlevel) DCVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4452 #define DLOG_N_TIMES(n, LEVEL) DCLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) 4453 #define DVLOG_N_TIMES(n, vlevel) DCVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) 4454 #endif // defined(ELPP_NO_DEBUG_MACROS) 4455 #if !defined(ELPP_NO_CHECK_MACROS) 4465 #undef CCHECK_BOUNDS 4466 #undef CCHECK_NOTNULL 4467 #undef CCHECK_STRCASEEQ 4468 #undef CCHECK_STRCASENE 4478 #undef CHECK_NOTNULL 4479 #undef CHECK_STRCASEEQ 4480 #undef CHECK_STRCASENE 4481 #define CCHECK(condition, ...) CLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] " 4482 #define CPCHECK(condition, ...) CPLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] " 4483 #define CHECK(condition) CCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) 4484 #define PCHECK(condition) CPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) 4485 #define CCHECK_EQ(a, b, ...) CCHECK(a == b, __VA_ARGS__) 4486 #define CCHECK_NE(a, b, ...) CCHECK(a != b, __VA_ARGS__) 4487 #define CCHECK_LT(a, b, ...) CCHECK(a < b, __VA_ARGS__) 4488 #define CCHECK_GT(a, b, ...) CCHECK(a > b, __VA_ARGS__) 4489 #define CCHECK_LE(a, b, ...) CCHECK(a <= b, __VA_ARGS__) 4490 #define CCHECK_GE(a, b, ...) CCHECK(a >= b, __VA_ARGS__) 4491 #define CCHECK_BOUNDS(val, min, max, ...) CCHECK(val >= min && val <= max, __VA_ARGS__) 4492 #define CHECK_EQ(a, b) CCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID) 4493 #define CHECK_NE(a, b) CCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID) 4494 #define CHECK_LT(a, b) CCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID) 4495 #define CHECK_GT(a, b) CCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID) 4496 #define CHECK_LE(a, b) CCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID) 4497 #define CHECK_GE(a, b) CCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID) 4498 #define CHECK_BOUNDS(val, min, max) CCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID) 4499 #define CCHECK_NOTNULL(ptr, ...) CCHECK((ptr) != nullptr, __VA_ARGS__) 4500 #define CCHECK_STREQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \ 4501 << "Check failed: [" << #str1 << " == " << #str2 << "] " 4502 #define CCHECK_STRNE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \ 4503 << "Check failed: [" << #str1 << " != " << #str2 << "] " 4504 #define CCHECK_STRCASEEQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \ 4505 << "Check failed: [" << #str1 << " == " << #str2 << "] " 4506 #define CCHECK_STRCASENE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \ 4507 << "Check failed: [" << #str1 << " != " << #str2 << "] " 4508 #define CHECK_NOTNULL(ptr) CCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID) 4509 #define CHECK_STREQ(str1, str2) CCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4510 #define CHECK_STRNE(str1, str2) CCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4511 #define CHECK_STRCASEEQ(str1, str2) CCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4512 #define CHECK_STRCASENE(str1, str2) CCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4520 #undef DCCHECK_BOUNDS 4521 #undef DCCHECK_NOTNULL 4522 #undef DCCHECK_STRCASEEQ 4523 #undef DCCHECK_STRCASENE 4532 #undef DCHECK_BOUNDS_ 4533 #undef DCHECK_NOTNULL 4534 #undef DCHECK_STRCASEEQ 4535 #undef DCHECK_STRCASENE 4537 #define DCCHECK(condition, ...) if (ELPP_DEBUG_LOG) CCHECK(condition, __VA_ARGS__) 4538 #define DCCHECK_EQ(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_EQ(a, b, __VA_ARGS__) 4539 #define DCCHECK_NE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_NE(a, b, __VA_ARGS__) 4540 #define DCCHECK_LT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LT(a, b, __VA_ARGS__) 4541 #define DCCHECK_GT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GT(a, b, __VA_ARGS__) 4542 #define DCCHECK_LE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LE(a, b, __VA_ARGS__) 4543 #define DCCHECK_GE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GE(a, b, __VA_ARGS__) 4544 #define DCCHECK_BOUNDS(val, min, max, ...) if (ELPP_DEBUG_LOG) CCHECK_BOUNDS(val, min, max, __VA_ARGS__) 4545 #define DCCHECK_NOTNULL(ptr, ...) if (ELPP_DEBUG_LOG) CCHECK_NOTNULL((ptr), __VA_ARGS__) 4546 #define DCCHECK_STREQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STREQ(str1, str2, __VA_ARGS__) 4547 #define DCCHECK_STRNE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRNE(str1, str2, __VA_ARGS__) 4548 #define DCCHECK_STRCASEEQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASEEQ(str1, str2, __VA_ARGS__) 4549 #define DCCHECK_STRCASENE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASENE(str1, str2, __VA_ARGS__) 4550 #define DCPCHECK(condition, ...) if (ELPP_DEBUG_LOG) CPCHECK(condition, __VA_ARGS__) 4551 #define DCHECK(condition) DCCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) 4552 #define DCHECK_EQ(a, b) DCCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID) 4553 #define DCHECK_NE(a, b) DCCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID) 4554 #define DCHECK_LT(a, b) DCCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID) 4555 #define DCHECK_GT(a, b) DCCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID) 4556 #define DCHECK_LE(a, b) DCCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID) 4557 #define DCHECK_GE(a, b) DCCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID) 4558 #define DCHECK_BOUNDS(val, min, max) DCCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID) 4559 #define DCHECK_NOTNULL(ptr) DCCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID) 4560 #define DCHECK_STREQ(str1, str2) DCCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4561 #define DCHECK_STRNE(str1, str2) DCCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4562 #define DCHECK_STRCASEEQ(str1, str2) DCCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4563 #define DCHECK_STRCASENE(str1, str2) DCCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) 4564 #define DPCHECK(condition) DCPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) 4565 #endif // defined(ELPP_NO_CHECK_MACROS) 4566 #if defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING) 4567 # define ELPP_USE_DEF_CRASH_HANDLER false 4569 # define ELPP_USE_DEF_CRASH_HANDLER true 4570 #endif // defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING) 4571 #define ELPP_CRASH_HANDLER_INIT 4572 #define ELPP_INIT_EASYLOGGINGPP(val) \ 4575 el::base::type::StoragePointer elStorage(val); \ 4577 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER); \ 4580 #if ELPP_ASYNC_LOGGING 4581 # define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()),\ 4582 new el::base::AsyncDispatchWorker())) 4584 # define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()))) 4585 #endif // ELPP_ASYNC_LOGGING 4586 #define INITIALIZE_NULL_EASYLOGGINGPP \ 4589 el::base::type::StoragePointer elStorage;\ 4591 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\ 4593 #define SHARE_EASYLOGGINGPP(initializedStorage)\ 4596 el::base::type::StoragePointer elStorage(initializedStorage);\ 4598 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\ 4601 #if defined(ELPP_UNICODE) 4602 # define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv); std::locale::global(std::locale("")) 4604 # define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv) 4605 #endif // defined(ELPP_UNICODE) 4606 #endif // EASYLOGGINGPP_H
std::unordered_map< Level, std::size_t > m_logFlushThresholdMap
Conf_T & getConfigByRef(Level level, std::unordered_map< Level, Conf_T > *confMap, const char *confName)
static const textual_icon lock
const base::type::string_t & message(void) const
void setArgs(int argc, const char **argv)
Sets arguments and parses them.
std::shared_ptr< base::type::fstream_t > FileStreamPtr
Specifies precision of the subsecond part. It should be within range (1-6).
void setValue(Level level, const Conf_T &value, std::unordered_map< Level, Conf_T > *confMap, bool includeGlobalLevel=true)
void setLogBuilder(const LogBuilderPtr &logBuilder)
const std::string & configurationFile(void) const
Gets configuration file used in parsing this configurations.
Abstract registry (aka repository) that provides basic interface for pointer repository specified by ...
std::unordered_map< Level, bool > m_enabledMap
const std::string & value(void) const
Gets string based configuration value.
virtual const_iterator cbegin(void) const ELPP_FINAL
base::threading::Mutex m_mutex
Parser used internally to parse configurations from file or text.
void unregister(const T_Key &uniqKey)
Unregisters single entry mapped to specified unique key.
GLboolean GLboolean GLboolean b
static const unsigned int kMaxLogPerCounter
Determines whether or not corresponding level and logger of logging is enabled You may disable all lo...
Mutex wrapper used when multi-threading is disabled.
GLenum GLsizei const void * pointer
Operating System helper static class used internally. You should not use it.
static const textual_icon unlock
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
SysLogInitializer(const char *processIdent, int options=0, int facility=0)
Determines whether or not performance tracking is enabled.
GLuint const GLchar * name
virtual void releaseLock(void) ELPP_FINAL
static bool installLogDispatchCallback(const std::string &id)
Installs post log dispatch callback, this callback is triggered when log is dispatched.
static T * callback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
void uninstallLoggerRegistrationCallback(const std::string &id)
Used to find configuration from configuration (pointers) repository. Avoid using it.
Creates logger automatically when not available.
static const char * kFilePathSeperator
static void removeFlag(LoggingFlag flag)
Removes logging flag used internally.
bool operator==(const plane &lhs, const plane &rhs)
Container::const_iterator const_iterator
static bool hasFlag(LoggingFlag flag)
Determines whether or not certain flag is active.
void setLoggingLevel(Level level)
Information representing errors in application but application will keep running. ...
const base::type::LineNumber m_line
const std::unordered_map< std::string, base::type::VerboseLevel > & modules(void) const
ELPP_EXPORT base::type::StoragePointer elStorage
void setDefaultLogBuilder(LogBuilderPtr &logBuilderPtr)
std::shared_ptr< base::Storage > StoragePointer
base::type::stringstream_t & stream(void)
static std::string getThreadName()
static base::type::EnumType castToInt(Level level)
Casts level to int, useful for iterating through enum.
static T * loggerRegistrationCallback(const std::string &id)
std::size_t hitCounts(void) const
virtual const_iterator cend(void) const ELPP_FINAL
MessageBuilder & operator<<(std::ostream &(*OStreamMani)(std::ostream &))
GLuint64 GLenum void * handle
virtual ~Configurations(void)
std::unordered_map< std::string, base::type::PerformanceTrackingCallbackPtr > m_performanceTrackingCallbacks
virtual void deepCopy(const AbstractRegistry< T_Ptr, std::vector< T_Ptr * >> &sr)
bool validateNTimesCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
GLsizei const GLchar *const * path
#define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp)
static void setThreadName(const std::string &name)
Sets thread name for current thread. Requires std::thread.
bool enabled(Level level) const
friend base::type::ostream_t & operator<<(base::type::ostream_t &os, const RegistryWithPred &sr)
static bool uninstallCustomFormatSpecifier(const char *formatSpecifier)
Uninstalls user defined format specifier and handler.
std::shared_ptr< LogDispatchCallback > LogDispatchCallbackPtr
Informational events most useful for developers to debug application.
base::type::VerboseLevel m_level
base::RegisteredLoggers * registeredLoggers(void) const
Severe error information that will presumably abort application.
base::threading::Mutex m_threadNamesLock
Main entry point of each logging.
ConfigurationType m_configurationType
static Level castFromInt(base::type::EnumType l)
Casts int(ushort) to level, useful for iterating through enum.
Base of thread safe class, this class is inheritable-only.
ConfigurationType m_configurationType
void setGlobally(ConfigurationType configurationType, const std::string &value)
Sets configuration for all levels.
base::threading::internal::NoScopedLock< base::threading::Mutex > ScopedLock
Easylogging++ entry namespace.
Base of Easylogging++ friendly class.
LoggingFlag
Flags used while writing logs. This flags are set by user.
Makes sure we have new line for each container log entry.
SubsecondPrecision MillisecondsWidth
Type alias of SubsecondPrecision.
Disables comparing performance tracker's checkpoints.
Conf_T & unsafeGetConfigByRef(Level level, std::unordered_map< Level, Conf_T > *confMap, const char *confName)
void setFlags(base::type::EnumType flags)
static const unsigned int kMaxLogPerContainer
unsigned long int LineNumber
GLsizei const GLchar *const * string
static std::string getCurrentThreadId(void)
base::DispatchAction dispatchAction(void) const
bool hasFlag(LoggingFlag flag) const
const struct el::base::consts::@14 kCrashSignals[]
std::unordered_map< Level, bool > m_performanceTrackingMap
#define ELPP_INTERNAL_INFO(lvl, msg)
static const char * convertToString(Level level)
Converts level to associated const char*.
virtual void registerNew(T_Ptr *ptr) ELPP_FINAL
virtual iterator end(void) ELPP_FINAL
RegistryWithPred(const RegistryWithPred &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
base::VRegistry * m_vRegistry
std::unordered_map< Level, std::string > m_filenameMap
base::RegisteredLoggers * m_registeredLoggers
Represents unknown level.
Writer & operator<<(const T &log)
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.
Level
Represents enumeration for severity level used to determine level of logging.
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
AbstractRegistry(AbstractRegistry &&sr)
Move constructor that is useful for base classes.
RegistryWithPred< T_Ptr, Pred >::iterator iterator
base::DispatchAction m_dispatchAction
static std::string convertTemplateToStdString(const T &templ)
Converts template to std::string - useful for loggable classes to log containers within log(std::ostr...
void setApplicationArguments(int argc, const char **argv)
T * logDispatchCallback(const std::string &id)
virtual void unregister(T_Ptr *&ptr) ELPP_FINAL
virtual ~Configuration(void)
const LogMessage * logMessage(void) const
FormatFlags
Format flags used to determine specifiers that are active for performance improvements.
std::ostream & operator<<(std::ostream &os, const textual_icon &i)
LogBuilderPtr m_logBuilder
std::unordered_map< Level, base::FileStreamPtr > m_fileStreamMap
Determines log file (full path) to write logs to for correponding level and logger.
virtual ~ThreadSafe(void)
base::RegisteredHitCounters * hitCounters(void) const
base::type::LineNumber m_line
base::TypedConfigurations * m_typedConfigurations
Writes nothing - Used when certain log is disabled.
base::type::LineNumber m_lineNumber
GLenum GLuint GLenum GLsizei const GLchar * buf
Container::iterator iterator
static const unsigned int kDefaultSubsecondPrecision
def info(name, value, persistent=False)
Conf_T getConfigByVal(Level level, const std::unordered_map< Level, Conf_T > *confMap, const char *confName)
virtual ~LogBuilder(void)
#define ELPP_INTERNAL_ERROR(msg, pe)
GLuint GLuint GLuint GLuint arg1
std::size_t operator()(const el::Level &l) const
Adds spaces b/w logs that separated by left-shift operator.
virtual ~NoScopedLock(void)
std::unordered_map< std::string, std::string > m_paramsWithValue
Internal helper class that prevent copy constructor for class.
String utilities helper class used internally. You should not use it.
CommandLineArgs(int argc, const char **argv)
static void defaultPreRollOutCallback(const char *, std::size_t)
static const int kCrashSignalsCount
const struct el::base::consts::@13 kTimeFormats[]
Makes sure if -vmodule is used and does not specifies a module, then verbose logging is allowed via t...
void initialize(Logger *logger)
Information that can be highly useful and vary with verbose logging level.
void setDispatchAction(base::DispatchAction dispatchAction)
Determines format of logging corresponding level and logger.
static void removeFlag(Enum e, base::type::EnumType *flag)
static void setStorage(base::type::StoragePointer storage)
Shares logging repository (base::Storage)
Disable VModules extensions.
#define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp)
static void installCustomFormatSpecifier(const CustomFormatSpecifier &customFormatSpecifier)
Installs user defined format specifier and handler.
LogBuilderPtr m_defaultLogBuilder
std::unique_ptr< el::base::PerformanceTracker > PerformanceTrackerPtr
bool contains(const std::shared_ptr< librealsense::device_info > &first, const std::shared_ptr< librealsense::device_info > &second)
virtual ~AbstractRegistry(void)
friend el::base::type::ostream_t & operator<<(el::base::type::ostream_t &os, const Loggable &loggable)
base::type::EnumType m_flags
virtual std::size_t size(void) const ELPP_FINAL
SubsecondPrecision(int width)
base::TypedConfigurations * typedConfigurations(void)
void addFlag(LoggingFlag flag)
static std::enable_if< std::is_pointer< T * >::value, void >::type safeDelete(T *&pointer)
Deletes memory safely and points to null.
Writer & operator<<(std::ostream &(*log)(std::ostream &))
bool validateEveryNCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t occasion)
std::unordered_map< Level, unsigned int > m_unflushedCount
A pointer registry mechanism to manage memory and provide search functionalities. (predicate version)...
LogDispatcher(bool proceed, LogMessage *logMessage, base::DispatchAction dispatchAction)
LogMessage * m_logMessage
bool operator==(const SubsecondPrecision &ssPrec)
base::type::EnumType flags(void) const
std::unordered_map< std::string, FileStreamPtr > LogStreamsReferenceMap
std::vector< std::string > m_params
std::shared_ptr< PerformanceTrackingCallback > PerformanceTrackingCallbackPtr
static base::type::EnumType And(Enum e, base::type::EnumType flag)
std::unordered_map< Level, bool > m_toStandardOutputMap
virtual void log(el::base::type::ostream_t &os) const
static const Level kPerformanceTrackerDefaultLevel
base::LogStreamsReferenceMap m_logStreamsReference
static void uninstallLogDispatchCallback(const std::string &id)
Uninstalls log dispatch callback.
Registry & operator=(const Registry &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
LogMessage(Level level, const std::string &file, base::type::LineNumber line, const std::string &func, base::type::VerboseLevel verboseLevel, Logger *logger)
Preserves time format and does not convert it to sec, hour etc (performance tracking only) ...
#define ELPP_SIMPLE_LOG(LOG_TYPE)
void clear(void)
Clears repository so that all the configurations are unset.
std::function< std::string(const LogMessage *)> FormatSpecifierValueResolver
Resolving function for format specifier.
Registry< T_Ptr, T_Key >::const_iterator const_iterator
const base::utils::CommandLineArgs * commandLineArgs(void) const
static base::type::EnumType castToInt(ConfigurationType configurationType)
Casts configuration type to int, useful for iterating through enum.
base::LogStreamsReferenceMap * m_logStreamsReference
bool validateFileRolling(Level level, const PreRollOutCallback &preRollOutCallback)
static const char * kDefaultLoggerId
bool has(const std::string &id)
HitCounter(const HitCounter &hitCounter)
Static class that contains helper functions for el::ConfigurationType.
bool operator!=(const AbstractRegistry< T_Ptr, Container > &other)
const char * filename(void) const
bool isFlushNeeded(Level level)
virtual void log(el::base::type::ostream_t &) const =0
static std::condition_variable cv
GLint GLint GLsizei GLint GLenum format
static void addFlag(Enum e, base::type::EnumType *flag)
void unsetPreRollOutCallback(void)
bool operator()(const HitCounter *counter)
def run(include_folder_path, addon_folder_path)
std::string trim(std::string const &str)
Returns a new string without whitespace at the start/end.
static void setArgs(int argc, const char **argv)
Sets application arguments and figures out whats active for logging and whats not.
bool endsWith(std::string const &s, std::string const &suffix)
base::DispatchAction m_dispatchAction
static bool isDigit(char c)
Checks if character is digit. Dont use libc implementation of it to prevent locale issues...
static const char * kPerformanceLoggerId
Adds flag and removes it when scope goes out.
unsigned short VerboseLevel
void unregister(Logger *&logger)
void setEnabled(bool enabled)
A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate vers...
RegistryWithPred & operator=(const RegistryWithPred &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
static const std::size_t kSourceFilenameMaxLength
Static helpers to deal with loggers and their configurations.
GLenum GLenum GLsizei const GLuint GLboolean enabled
base::VRegistry * vRegistry(void) const
base::threading::Mutex m_customFormatSpecifiersLock
bool installLogDispatchCallback(const std::string &id)
static bool hasFlag(Enum e, base::type::EnumType flag)
std::unordered_map< std::string, std::string > m_threadNames
Contains utilities for cross-platform date/time. This class make use of el::base::utils::Str.
ScopedAddFlag(LoggingFlag flag)
base::threading::internal::NoMutex Mutex
static const char kFormatSpecifierCharValue
BOOST_DEDUCED_TYPENAME optional< T >::reference_const_type get(optional< T > const &opt)
const std::string & parentApplicationName(void) const
std::unordered_map< Level, base::LogFormat > m_logFormatMap
Configurations with data types.
base::type::VerboseLevel verboseLevel(void) const
MessageBuilder & writeIterator(Iterator begin_, Iterator end_, std::size_t size_)
static void setLoggingLevel(Level level)
Sets hierarchy for logging. Needs to enable logging flag (HierarchicalLogging)
virtual ~TypedConfigurations(void)
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.
std::vector< std::string > m_loggerIds
Configurations * m_configurations
void setPreRollOutCallback(const PreRollOutCallback &callback)
virtual ~CommandLineArgs(void)
base::utils::CommandLineArgs m_commandLineArgs
const base::type::char_t * unit
PreRollOutCallback m_preRollOutCallback
std::shared_ptr< LogBuilder > LogBuilderPtr
virtual void acquireLock(void) ELPP_FINAL
const base::HitCounter * getCounter(const char *filename, base::type::LineNumber lineNumber)
Gets hit counter registered at specified position.
Make terminal output colorful for supported terminals.
#define ELPP_LITERAL(txt)
HitCounter & operator=(const HitCounter &hitCounter)
Repository for hit counters used across the application.
void removeFlag(LoggingFlag flag)
Configurations m_defaultConfigurations
Writer(Level level, const char *file, base::type::LineNumber line, const char *func, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog, base::type::VerboseLevel verboseLevel=0)
static const int kTimeFormatsCount
virtual ~SysLogInitializer(void)
ConfigurationType configurationType(void) const
Gets configuration type of current configuration.
bool installLoggerRegistrationCallback(const std::string &id)
bool validateAfterNCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
void validateHitCounts(std::size_t n)
Validates hit counts and resets it if necessary.
Useful when application has potentially harmful situtaions.
PErrorWriter(Level level, const char *file, base::type::LineNumber line, const char *func, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog, base::type::VerboseLevel verboseLevel=0)
When handling crashes by default, detailed crash reason will be logged as well.
DispatchAction
Action to be taken for dispatching.
void setThreadName(const std::string &name)
Sets thread name for current thread. Requires std::thread.
Enables strict file rolling.
static base::type::StoragePointer storage()
Conf_T unsafeGetConfigByVal(Level level, const std::unordered_map< Level, Conf_T > *confMap, const char *confName)
std::unordered_map< std::string, std::unique_ptr< base::threading::Mutex > > m_fileLocks
static void uninstallPreRollOutCallback(void)
Uninstalls pre rollout callback.
NullWriter & operator<<(const T &)
base::type::LineNumber lineNumber(void) const
std::string m_parentApplicationName
static void uninstallLoggerRegistrationCallback(const std::string &id)
Uninstalls log dispatch callback.
virtual Container & list(void) ELPP_FINAL
Returns underlying container by reference.
LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ep)
Removes flag and add it when scope goes out.
static T * logDispatchCallback(const std::string &id)
Level level(void) const
Gets level of current configuration.
MessageBuilder & operator<<(const std::string &msg)
Writer & construct(Logger *logger, bool needLock=true)
LogBuilder * logBuilder(void) const
Flushes log with every log-entry (performance sensative) - Disabled by default.
const Configurations * configurations(void) const
static void reserveCustomFormatSpecifiers(std::size_t size)
Reserve space for custom format specifiers for performance.
void next(auto_any_t cur, type2type< T, C > *)
Thread-safe Configuration repository.
CommandLineArgs(int argc, char **argv)
Writer(LogMessage *msg, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog)
Mainly useful to represent current progress of application.
void setValue(const std::string &value)
Set string based configuration value.
base::threading::Mutex m_fileLocksMapLock
static bool installCallback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
base::threading::Mutex & customFormatSpecifiersLock()
Predicate(const char *filename, base::type::LineNumber lineNumber)
virtual void deepCopy(const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * >> &sr) ELPP_FINAL
static void reconfigureAllLoggers(ConfigurationType configurationType, const std::string &value)
Reconfigures single configuration for all the loggers.
void construct(Factory const &factory, void *address)
std::function< void(const char *, std::size_t)> PreRollOutCallback
void resetLocation(const char *filename, base::type::LineNumber lineNumber)
Resets location of current hit counter.
Configurations * configurations(void)
virtual ~RegisteredLoggers(void)
bool operator==(const AbstractRegistry< T_Ptr, Container > &other)
TimestampUnit
Enum to represent timestamp unit.
Command line arguments for application if specified using el::Helpers::setArgs(..) or START_EASYLOGGI...
Configurations * defaultConfigurations(void)
PreRollOutCallback & preRollOutCallback(void)
void setDefaultConfigurations(const Configurations &configurations)
base::RegisteredHitCounters * m_registeredHitCounters
base::DispatchAction m_dispatchAction
std::string getThreadName(const std::string &threadId)
static const char kFormatSpecifierChar
base::MessageBuilder m_messageBuilder
Specifies number of log entries to hold until we flush pending log data.
void log(std::string message)
base::type::string_t m_message
std::string m_configurationFile
static void addFlag(LoggingFlag flag)
Adds logging flag used internally.
std::unordered_map< std::string, base::type::LoggerRegistrationCallbackPtr > m_loggerRegistrationCallbacks
static void validateFileRolling(Logger *logger, Level level)
Configurations m_configurations
std::shared_ptr< LoggerRegistrationCallback > LoggerRegistrationCallbackPtr
LogMessage * m_logMessage
AbstractRegistry(void)
Default constructor.
NullWriter & operator<<(std::ostream &(*)(std::ostream &))
base::debug::CrashHandler elCrashHandler
T * loggerRegistrationCallback(const std::string &id)
static const el::base::utils::CommandLineArgs * commandLineArgs(void)
Returns command line arguments (pointer) provided to easylogging++.
bool vModulesEnabled(void)
Whether or not vModules enabled.
A subsecond precision class containing actual width and offset of the subsecond part.
static bool installLoggerRegistrationCallback(const std::string &id)
Installs logger registration callback, this callback is triggered when new logger is registered...
#define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp)
const std::string & func(void) const
virtual iterator begin(void) ELPP_FINAL
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
static const std::size_t kSourceLineMaxLength
std::unordered_map< std::string, base::type::LogDispatchCallbackPtr > m_logDispatchCallbacks
base::LogStreamsReferenceMap * logStreamsReference(void)
base::type::VerboseLevel m_verboseLevel
std::unordered_map< std::string, base::type::VerboseLevel > m_modules
virtual ~HitCounter(void)
base::type::VerboseLevel level(void) const
base::type::LineNumber line(void) const
virtual const Container & list(void) const ELPP_FINAL
Returns underlying container by constant reference.
Generic level that represents all the levels. Useful when setting global configuration for all levels...
Registry< T_Ptr, T_Key >::iterator iterator
virtual void registerNew(const T_Key &uniqKey, T_Ptr *ptr) ELPP_FINAL
Registers new registry to repository.
Whether or not to write corresponding log to log file.
#define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp)
Represents single configuration that has representing level, configuration type and a string based va...
Internal helper class that makes all default constructors private.
void uninstallLogDispatchCallback(const std::string &id)
void setLogMessage(LogMessage *logMessage)
static base::type::EnumType Not(Enum e, base::type::EnumType flag)
virtual ~RegistryWithPred(void)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
ScopedRemoveFlag(LoggingFlag flag)
const base::type::char_t * m_containerLogSeperator
Whether or not to write corresponding level and logger log to standard output. By standard output mea...
Class that keeps record of current line hit for occasional logging.
Represents a logger holding ID and configurations we need to write logs.
ConfigurationType
Represents enumeration of ConfigurationType used to configure or access certain aspect of logging...
Generic::PredicateMatcher< T > Predicate(std::function< bool(T const &)> const &predicate, std::string const &description="")
base::type::stringstream_t m_stream
Logger * logger(void) const
AbstractRegistry & operator=(AbstractRegistry &&sr)
Assignment move operator.
Registry(const Registry &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
Lock guard wrapper used when multi-threading is disabled.
std::unordered_map< Level, bool > m_toFileMap
static base::type::EnumType Or(Enum e, base::type::EnumType flag)
RegistryWithPred< T_Ptr, Pred >::const_iterator const_iterator
const LogDispatchData * m_data
HitCounter(const char *filename, base::type::LineNumber lineNumber)
std::stringstream stringstream_t
std::vector< CustomFormatSpecifier > m_customFormatSpecifiers
base::type::VerboseLevel m_verboseLevel
Static class that contains helper functions for el::Level.
void setParentApplicationName(const std::string &parentApplicationName)
std::unordered_map< Level, std::size_t > m_maxLogFileSizeMap
void reinitDeepCopy(const AbstractRegistry< T_Ptr, Container > &sr)
static void uninstallCallback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
base::type::LineNumber m_lineNumber
const std::string & file(void) const
const std::string & id(void) const
base::LogStreamsReferenceMap * m_logStreamsReference
Enables hierarchical logging.
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
static bool hasCustomFormatSpecifier(const char *formatSpecifier)
Returns true if custom format specifier is installed.
Supports use of multiple logging in same macro, e.g, CLOG(INFO, "default", "network") ...
Static helpers for developers.
static ConfigurationType castFromInt(base::type::EnumType c)
Casts int(ushort) to configurationt type, useful for iterating through enum.
#define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp)
Information that can be useful to back-trace certain events - mostly useful than debug logs...
virtual base::threading::Mutex & lock(void) ELPP_FINAL
Specifies log file max size.
Represents registries for verbose logging.
std::unordered_map< Level, base::SubsecondPrecision > m_subsecondPrecisionMap
static void setArgs(int argc, char **argv)
Sets application arguments and figures out whats active for logging and whats not.
base::type::EnumType * m_pFlags
bool startsWith(std::string const &s, std::string const &prefix)
Easylogging++ management storage.
const std::vector< CustomFormatSpecifier > * customFormatSpecifiers(void) const
Allows to disable application abortion when logged using FATAL level.
virtual bool empty(void) const ELPP_FINAL