16 #ifndef EASYLOGGINGPP_H
17 #define EASYLOGGINGPP_H
20 # define ELPP_COMPILER_GCC 1
21 # define ELPP_GCC_VERSION (__GNUC__ * 10000 \
22 + __GNUC_MINOR__ * 100 \
23 + __GNUC_PATCHLEVEL__)
24 # if defined(__GXX_EXPERIMENTAL_CXX0X__)
26 # elif(ELPP_GCC_VERSION >= 40801)
28 # endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
29 #endif // defined(__GNUC__)
32 # define ELPP_COMPILER_MSVC 1
33 # define ELPP_CRT_DBG_WARNINGS 1
34 # if (_MSC_VER == 1600)
36 # elif(_MSC_VER >= 1700)
38 # endif // (_MSC_VER == 1600)
39 #endif // defined(_MSC_VER)
41 #if defined(__clang__) && (__clang__ == 1)
42 # define ELPP_COMPILER_CLANG 1
43 # define ELPP_CLANG_VERSION (__clang_major__ * 10000 \
44 + __clang_minor__ * 100 \
45 + __clang_patchlevel__)
46 # if (ELPP_CLANG_VERSION >= 30300)
48 # endif // (ELPP_CLANG_VERSION >= 30300)
49 #endif // defined(__clang__) && (__clang__ == 1)
51 #if defined(__MINGW32__) || defined(__MINGW64__)
53 #endif // defined(__MINGW32__) || defined(__MINGW64__)
55 #if defined(__CYGWIN__) && (__CYGWIN__ == 1)
56 # define ELPP_CYGWIN 1
57 #endif // defined(__CYGWIN__) && (__CYGWIN__ == 1)
59 #if defined(__INTEL_COMPILER)
60 # define ELPP_COMPILER_INTEL 1
64 #if defined(_WIN32) || defined(_WIN64)
65 # define ELPP_OS_WINDOWS 1
66 #endif // defined(_WIN32) || defined(_WIN64)
68 #if (defined(__linux) || defined(__linux__))
69 # define ELPP_OS_LINUX 1
70 #endif // (defined(__linux) || defined(__linux__))
72 #if defined(__APPLE__)
73 # define ELPP_OS_MAC 1
74 #endif // defined(__APPLE__)
76 #if defined(__FreeBSD__)
77 # define ELPP_OS_FREEBSD 1
81 # define ELPP_OS_SOLARIS 1
84 #if ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_SOLARIS) && (!ELPP_OS_WINDOWS))
85 # define ELPP_OS_UNIX 1
86 #endif // ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_SOLARIS) && (!ELPP_OS_WINDOWS))
88 #if defined(__ANDROID__)
89 # define ELPP_OS_ANDROID 1
90 #endif // defined(__ANDROID__)
92 #if !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN
95 # define ELPP_OS_UNIX 1
96 # define ELPP_OS_LINUX 1
97 #endif // !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN
98 #if !defined(ELPP_INTERNAL_DEBUGGING_OUT_INFO)
99 # define ELPP_INTERNAL_DEBUGGING_OUT_INFO std::cout
100 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
101 #if !defined(ELPP_INTERNAL_DEBUGGING_OUT_ERROR)
102 # define ELPP_INTERNAL_DEBUGGING_OUT_ERROR std::cerr
103 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
104 #if !defined(ELPP_INTERNAL_DEBUGGING_ENDL)
105 # define ELPP_INTERNAL_DEBUGGING_ENDL std::endl
106 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
107 #if !defined(ELPP_INTERNAL_DEBUGGING_MSG)
108 # define ELPP_INTERNAL_DEBUGGING_MSG(msg) msg
109 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
111 #if !defined(ELPP_DISABLE_ASSERT)
112 # if (defined(ELPP_DEBUG_ASSERT_FAILURE))
113 # define ELPP_ASSERT(expr, msg) if (!(expr)) { \
114 std::stringstream internalInfoStream; internalInfoStream << msg; \
115 ELPP_INTERNAL_DEBUGGING_OUT_ERROR \
116 << "EASYLOGGING++ ASSERTION FAILED (LINE: " << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" \
117 << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" << ELPP_INTERNAL_DEBUGGING_ENDL; base::utils::abort(1, \
118 "ELPP Assertion failure, please define ELPP_DEBUG_ASSERT_FAILURE"); }
120 # define ELPP_ASSERT(expr, msg) if (!(expr)) { \
121 std::stringstream internalInfoStream; internalInfoStream << msg; \
122 ELPP_INTERNAL_DEBUGGING_OUT_ERROR\
123 << "ASSERTION FAILURE FROM EASYLOGGING++ (LINE: " \
124 << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" \
125 << ELPP_INTERNAL_DEBUGGING_ENDL; }
126 # endif // (defined(ELPP_DEBUG_ASSERT_FAILURE))
128 # define ELPP_ASSERT(x, y)
129 #endif //(!defined(ELPP_DISABLE_ASSERT)
130 #if ELPP_COMPILER_MSVC
131 # define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \
132 { char buff[256]; strerror_s(buff, 256, errno); \
133 ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << buff << " [" << errno << "]";} (void)0
135 # define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \
136 ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << strerror(errno) << " [" << errno << "]"; (void)0
137 #endif // ELPP_COMPILER_MSVC
138 #if defined(ELPP_DEBUG_ERRORS)
139 # if !defined(ELPP_INTERNAL_ERROR)
140 # define ELPP_INTERNAL_ERROR(msg, pe) { \
141 std::stringstream internalInfoStream; internalInfoStream << "<ERROR> " << msg; \
142 ELPP_INTERNAL_DEBUGGING_OUT_ERROR \
143 << "ERROR FROM EASYLOGGING++ (LINE: " << __LINE__ << ") " \
144 << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << ELPP_INTERNAL_DEBUGGING_ENDL; \
145 if (pe) { ELPP_INTERNAL_DEBUGGING_OUT_ERROR << " "; ELPP_INTERNAL_DEBUGGING_WRITE_PERROR; }} (void)0
148 # undef ELPP_INTERNAL_INFO
149 # define ELPP_INTERNAL_ERROR(msg, pe)
150 #endif // defined(ELPP_DEBUG_ERRORS)
151 #if (defined(ELPP_DEBUG_INFO))
152 # if !(defined(ELPP_INTERNAL_INFO_LEVEL))
153 # define ELPP_INTERNAL_INFO_LEVEL 9
154 # endif // !(defined(ELPP_INTERNAL_INFO_LEVEL))
155 # if !defined(ELPP_INTERNAL_INFO)
156 # define ELPP_INTERNAL_INFO(lvl, msg) { if (lvl <= ELPP_INTERNAL_INFO_LEVEL) { \
157 std::stringstream internalInfoStream; internalInfoStream << "<INFO> " << msg; \
158 ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) \
159 << ELPP_INTERNAL_DEBUGGING_ENDL; }}
162 # undef ELPP_INTERNAL_INFO
163 # define ELPP_INTERNAL_INFO(lvl, msg)
164 #endif // (defined(ELPP_DEBUG_INFO))
165 #if defined(ELPP_STACKTRACE_ON_CRASH)
166 # if (ELPP_COMPILER_GCC && !ELPP_MINGW)
167 # define ELPP_STACKTRACE 1
169 # if ELPP_COMPILER_MSVC
170 # pragma message("Stack trace not available for this compiler")
172 # warning "Stack trace not available for this compiler";
173 # endif // ELPP_COMPILER_MSVC
174 # endif // ELPP_COMPILER_GCC
175 #endif // (defined(ELPP_STACKTRACE_ON_CRASH))
177 #define ELPP_UNUSED(x) (void)x
180 # define ELPP_LOG_PERMS S_IRUSR | S_IWUSR | S_IXUSR | S_IWGRP | S_IRGRP | S_IXGRP | S_IWOTH | S_IXOTH
181 #endif // ELPP_OS_UNIX
182 #if defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC
183 # if defined(ELPP_EXPORT_SYMBOLS)
184 # define ELPP_EXPORT __declspec(dllexport)
186 # define ELPP_EXPORT __declspec(dllimport)
187 # endif // defined(ELPP_EXPORT_SYMBOLS)
190 #endif // defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC
196 #if ELPP_CRT_DBG_WARNINGS
197 # define STRTOK(a, b, c) strtok_s(a, b, c)
198 # define STRERROR(a, b, c) strerror_s(a, b, c)
199 # define STRCAT(a, b, len) strcat_s(a, len, b)
200 # define STRCPY(a, b, len) strcpy_s(a, len, b)
202 # define STRTOK(a, b, c) strtok(a, b)
203 # define STRERROR(a, b, c) strerror(c)
204 # define STRCAT(a, b, len) strcat(a, b)
205 # define STRCPY(a, b, len) strcpy(a, b)
208 #if (!ELPP_MINGW && !ELPP_COMPILER_CLANG) || defined(ELPP_FORCE_USE_STD_THREAD)
209 # define ELPP_USE_STD_THREADING 1
210 #endif // (!ELPP_MINGW && !ELPP_COMPILER_CLANG) || defined(ELPP_FORCE_USE_STD_THREAD)
212 #if ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702)
215 # define ELPP_FINAL final
216 #endif // ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702)
217 #if defined(ELPP_EXPERIMENTAL_ASYNC)
218 # define ELPP_ASYNC_LOGGING 1
220 # define ELPP_ASYNC_LOGGING 0
221 #endif // defined(ELPP_EXPERIMENTAL_ASYNC)
222 #if defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING
223 # define ELPP_THREADING_ENABLED 1
224 #endif // defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING
227 #if ELPP_COMPILER_MSVC // Visual C++
228 # define ELPP_FUNC __FUNCSIG__
229 #elif ELPP_COMPILER_GCC // GCC
230 # define ELPP_FUNC __PRETTY_FUNCTION__
231 #elif ELPP_COMPILER_INTEL // Intel C++
232 # define ELPP_FUNC __PRETTY_FUNCTION__
233 #elif ELPP_COMPILER_CLANG // Clang++
234 # define ELPP_FUNC __PRETTY_FUNCTION__
236 # if defined(__func__)
237 # define ELPP_FUNC __func__
239 # define ELPP_FUNC ""
240 # endif // defined(__func__)
241 #endif // defined(_MSC_VER)
242 #undef ELPP_VARIADIC_TEMPLATES_SUPPORTED
244 #if ELPP_COMPILER_GCC || ELPP_COMPILER_CLANG || ELPP_COMPILER_INTEL || (ELPP_COMPILER_MSVC && _MSC_VER >= 1800)
245 # define ELPP_VARIADIC_TEMPLATES_SUPPORTED 1
246 #endif // ELPP_COMPILER_GCC || ELPP_COMPILER_CLANG || ELPP_COMPILER_INTEL || (ELPP_COMPILER_MSVC && _MSC_VER >= 1800)
248 #if (!defined(ELPP_DISABLE_LOGS))
249 # define ELPP_LOGGING_ENABLED 1
250 #endif // (!defined(ELPP_DISABLE_LOGS))
251 #if (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED) && ((defined(_DEBUG)) || (!defined(NDEBUG))))
252 # define ELPP_DEBUG_LOG 1
254 # define ELPP_DEBUG_LOG 0
255 #endif // (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED) && ((defined(_DEBUG)) || (!defined(NDEBUG))))
256 #if (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED))
257 # define ELPP_INFO_LOG 1
259 # define ELPP_INFO_LOG 0
260 #endif // (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED))
261 #if (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED))
262 # define ELPP_WARNING_LOG 1
264 # define ELPP_WARNING_LOG 0
265 #endif // (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED))
266 #if (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED))
267 # define ELPP_ERROR_LOG 1
269 # define ELPP_ERROR_LOG 0
270 #endif // (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED))
271 #if (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED))
272 # define ELPP_FATAL_LOG 1
274 # define ELPP_FATAL_LOG 0
275 #endif // (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED))
276 #if (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED))
277 # define ELPP_TRACE_LOG 1
279 # define ELPP_TRACE_LOG 0
280 #endif // (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED))
281 #if (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED))
282 # define ELPP_VERBOSE_LOG 1
284 # define ELPP_VERBOSE_LOG 0
285 #endif // (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED))
286 #if (!(ELPP_CXX0X || ELPP_CXX11))
287 # error "Easylogging++ 9.0+ is only compatible with C++0x (or higher) compliant compiler"
288 #endif // (!(ELPP_CXX0X || ELPP_CXX11))
290 #if defined(ELPP_SYSLOG)
292 #endif // defined(ELPP_SYSLOG)
301 #if defined(ELPP_UNICODE)
305 # endif // ELPP_OS_WINDOWS
306 #endif // defined(ELPP_UNICODE)
309 # include <execinfo.h>
310 #endif // ELPP_STACKTRACE
312 # include <sys/system_properties.h>
313 #endif // ELPP_OS_ANDROID
315 # include <sys/stat.h>
316 # include <sys/time.h>
317 #elif ELPP_OS_WINDOWS
319 # include <windows.h>
320 # if defined(WIN32_LEAN_AND_MEAN)
321 # if defined(ELPP_WINSOCK2)
322 # include <winsock2.h>
324 # include <winsock.h>
325 # endif // defined(ELPP_WINSOCK2)
326 # endif // defined(WIN32_LEAN_AND_MEAN)
327 #endif // ELPP_OS_UNIX
332 #include <functional>
338 #include <type_traits>
339 #if ELPP_THREADING_ENABLED
340 # if ELPP_USE_STD_THREADING
345 # include <pthread.h>
346 # endif // ELPP_OS_UNIX
347 # endif // ELPP_USE_STD_THREADING
348 #endif // ELPP_THREADING_ENABLED
349 #if ELPP_ASYNC_LOGGING
352 # include <condition_variable>
353 #endif // ELPP_ASYNC_LOGGING
354 #if defined(ELPP_STL_LOGGING)
362 # if defined(ELPP_LOG_STD_ARRAY)
364 # endif // defined(ELPP_LOG_STD_ARRAY)
365 # if defined(ELPP_LOG_UNORDERED_MAP)
366 # include <unordered_map>
367 # endif // defined(ELPP_LOG_UNORDERED_MAP)
368 # if defined(ELPP_LOG_UNORDERED_SET)
369 # include <unordered_set>
370 # endif // defined(ELPP_UNORDERED_SET)
371 #endif // defined(ELPP_STL_LOGGING)
372 #if defined(ELPP_QT_LOGGING)
375 # include <QByteArray>
382 # include <QLinkedList>
384 # include <QMultiHash>
386 #endif // defined(ELPP_QT_LOGGING)
387 #if defined(ELPP_BOOST_LOGGING)
389 # include <boost/container/vector.hpp>
390 # include <boost/container/stable_vector.hpp>
391 # include <boost/container/list.hpp>
392 # include <boost/container/deque.hpp>
393 # include <boost/container/map.hpp>
394 # include <boost/container/flat_map.hpp>
395 # include <boost/container/set.hpp>
396 # include <boost/container/flat_set.hpp>
397 #endif // defined(ELPP_BOOST_LOGGING)
398 #if defined(ELPP_WXWIDGETS_LOGGING)
400 # include <wx/vector.h>
401 #endif // defined(ELPP_WXWIDGETS_LOGGING)
423 #if ELPP_ASYNC_LOGGING
424 class AsyncLogDispatchCallback;
425 class AsyncDispatchWorker;
426 #endif // ELPP_ASYNC_LOGGING
439 #if defined(ELPP_UNICODE)
440 # define ELPP_LITERAL(txt) L##txt
441 # define ELPP_STRLEN wcslen
442 # if defined ELPP_CUSTOM_COUT
443 # define ELPP_COUT ELPP_CUSTOM_COUT
445 # define ELPP_COUT std::wcout
446 # endif // defined ELPP_CUSTOM_COUT
453 # define ELPP_LITERAL(txt) txt
454 # define ELPP_STRLEN strlen
455 # if defined ELPP_CUSTOM_COUT
456 # define ELPP_COUT ELPP_CUSTOM_COUT
458 # define ELPP_COUT std::cout
459 # endif // defined ELPP_CUSTOM_COUT
465 #endif // defined(ELPP_UNICODE)
466 #if defined(ELPP_CUSTOM_COUT_LINE)
467 # define ELPP_COUT_LINE(logLine) ELPP_CUSTOM_COUT_LINE(logLine)
469 # define ELPP_COUT_LINE(logLine) logLine << std::flush
470 #endif // defined(ELPP_CUSTOM_COUT_LINE)
535 return static_cast<Level>(l);
555 if ((strcmp(levelStr,
"GLOBAL") == 0) || (strcmp(levelStr,
"global") == 0))
557 if ((strcmp(levelStr,
"DEBUG") == 0) || (strcmp(levelStr,
"debug") == 0))
559 if ((strcmp(levelStr,
"INFO") == 0) || (strcmp(levelStr,
"info") == 0))
561 if ((strcmp(levelStr,
"WARNING") == 0) || (strcmp(levelStr,
"warning") == 0))
563 if ((strcmp(levelStr,
"ERROR") == 0) || (strcmp(levelStr,
"error") == 0))
565 if ((strcmp(levelStr,
"FATAL") == 0) || (strcmp(levelStr,
"fatal") == 0))
567 if ((strcmp(levelStr,
"VERBOSE") == 0) || (strcmp(levelStr,
"verbose") == 0))
569 if ((strcmp(levelStr,
"TRACE") == 0) || (strcmp(levelStr,
"trace") == 0))
584 }
while (*startIndex <= lIndexMax);
652 if ((strcmp(configStr,
"ENABLED") == 0) || (strcmp(configStr,
"enabled") == 0))
654 if ((strcmp(configStr,
"TO_FILE") == 0) || (strcmp(configStr,
"to_file") == 0))
656 if ((strcmp(configStr,
"TO_STANDARD_OUTPUT") == 0) || (strcmp(configStr,
"to_standard_output") == 0))
658 if ((strcmp(configStr,
"FORMAT") == 0) || (strcmp(configStr,
"format") == 0))
660 if ((strcmp(configStr,
"FILENAME") == 0) || (strcmp(configStr,
"filename") == 0))
662 if ((strcmp(configStr,
"MILLISECONDS_WIDTH") == 0) || (strcmp(configStr,
"milliseconds_width") == 0))
664 if ((strcmp(configStr,
"PERFORMANCE_TRACKING") == 0) || (strcmp(configStr,
"performance_tracking") == 0))
666 if ((strcmp(configStr,
"MAX_LOG_FILE_SIZE") == 0) || (strcmp(configStr,
"max_log_file_size") == 0))
668 if ((strcmp(configStr,
"LOG_FLUSH_THRESHOLD") == 0) || (strcmp(configStr,
"log_flush_threshold") == 0))
684 }
while (*startIndex <= cIndexMax);
755 static const char* kDateTimeFormatSpecifierForFilename =
"%datetime";
757 static const char* kDays[7] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday" };
758 static const char* kDaysAbbrev[7] = {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat" };
759 static const char* kMonths[12] = {
"January",
"February",
"March",
"Apri",
"May",
"June",
"July",
"August",
760 "September",
"October",
"November",
"December" };
761 static const char* kMonthsAbbrev[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" };
762 static const char* kDefaultDateTimeFormat =
"%Y-%M-%d %H:%m:%s,%g";
763 static const char* kDefaultDateTimeFormatInFilename =
"%Y-%M-%d_%H-%m";
764 static const int kYearBase = 1900;
765 static const char* kAm =
"AM";
766 static const char* kPm =
"PM";
768 static const char* kDefaultLoggerId =
"default";
769 static const char* kPerformanceLoggerId =
"performance";
770 static const char* kSysLogLoggerId =
"syslog";
771 static const char* kNullPointer =
"nullptr";
772 static const char kFormatSpecifierChar =
'%';
773 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED
774 static const char kFormatSpecifierCharValue =
'v';
775 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
776 static const unsigned int kMaxLogPerContainer = 100;
777 static const unsigned int kMaxLogPerCounter = 100000;
778 static const unsigned int kDefaultMillisecondsWidth = 3;
780 static const char* kUnknownUser =
"user";
781 static const char* kUnknownHost =
"unknown-host";
782 #if defined(ELPP_DEFAULT_LOG_FILE)
783 static const char* kDefaultLogFile = ELPP_DEFAULT_LOG_FILE;
787 static const char* kDefaultLogFile =
"logs/myeasylog.log";
789 static const char* kDefaultLogFile =
"logs/myeasylog.log";
790 # endif // ELPP_OS_ANDROID
791 # elif ELPP_OS_WINDOWS
792 static const char* kDefaultLogFile =
"logs\\myeasylog.log";
793 # endif // ELPP_OS_UNIX
794 #endif // defined(ELPP_DEFAULT_LOG_FILE)
795 #if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
796 static const char* kDefaultLogFileParam =
"--default-log-file";
797 #endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
798 #if defined(ELPP_LOGGING_FLAGS_FROM_ARG)
799 static const char* kLoggingFlagsParam =
"--logging-flags";
800 #endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG)
802 static const char* kFilePathSeperator =
"\\";
804 static const char* kFilePathSeperator =
"/";
805 #endif // ELPP_OS_WINDOWS
806 static const char* kValidLoggerIdSymbols =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._";
807 static const char* kConfigurationComment =
"##";
808 static const char* kConfigurationLevel =
"*";
809 static const char* kConfigurationLoggerId =
"--";
810 static const std::size_t kSourceFilenameMaxLength = 100;
811 static const std::size_t kSourceLineMaxLength = 10;
832 { SIGABRT,
"SIGABRT",
"Abnormal termination",
833 "Program was abnormally terminated." },
834 { SIGFPE,
"SIGFPE",
"Erroneous arithmetic operation",
835 "Arithemetic operation issue such as division by zero or operation resulting in overflow." },
836 { SIGILL,
"SIGILL",
"Illegal instruction",
837 "Generally due to a corruption in the code or to an attempt to execute data."},
838 { SIGSEGV,
"SIGSEGV",
"Invalid access to memory",
839 "Program is trying to read an invalid (unallocated, deleted or corrupted) or inaccessible memory." },
840 { SIGINT,
"SIGINT",
"Interactive attention signal",
841 "Interruption generated (generally) by user or operating system." },
848 static inline void defaultPreRollOutCallback(
const char*, std::size_t) {}
867 void init(
int width) {
868 if (width < 1 || width > 6) {
869 width = base::consts::kDefaultMillisecondsWidth;
884 template <
typename T>
887 safeDelete(T*& pointer) {
888 if (pointer ==
nullptr)
894 static inline const char* charPtrVal(
const char* pointer) {
895 return pointer ==
nullptr ? base::consts::kNullPointer : pointer;
898 static inline void abort(
int status,
const std::string& reason = std::string()) {
902 #if defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG)
907 #endif // defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG)
912 template <
typename Enum>
916 template <
typename Enum>
920 template <
typename Enum>
925 template <
typename Enum>
927 *flag = base::utils::bitwise::Or<Enum>(e, *flag);
929 template <
typename Enum>
931 *flag = base::utils::bitwise::Not<Enum>(e, *flag);
933 template <
typename Enum>
935 return base::utils::bitwise::And<Enum>(e, flag) > 0x0;
938 namespace threading {
939 #if ELPP_THREADING_ENABLED
940 # if !ELPP_USE_STD_THREADING
947 pthread_mutex_init(&m_underlyingMutex,
nullptr);
948 # elif ELPP_OS_WINDOWS
949 InitializeCriticalSection(&m_underlyingMutex);
950 # endif // ELPP_OS_UNIX
953 virtual ~
Mutex(
void) {
955 pthread_mutex_destroy(&m_underlyingMutex);
956 # elif ELPP_OS_WINDOWS
957 DeleteCriticalSection(&m_underlyingMutex);
958 # endif // ELPP_OS_UNIX
961 inline void lock(
void) {
963 pthread_mutex_lock(&m_underlyingMutex);
964 # elif ELPP_OS_WINDOWS
965 EnterCriticalSection(&m_underlyingMutex);
966 # endif // ELPP_OS_UNIX
969 inline bool try_lock(
void) {
971 return (pthread_mutex_trylock(&m_underlyingMutex) == 0);
972 # elif ELPP_OS_WINDOWS
973 return TryEnterCriticalSection(&m_underlyingMutex);
974 # endif // ELPP_OS_UNIX
977 inline void unlock(
void) {
979 pthread_mutex_unlock(&m_underlyingMutex);
980 # elif ELPP_OS_WINDOWS
981 LeaveCriticalSection(&m_underlyingMutex);
982 # endif // ELPP_OS_UNIX
987 pthread_mutex_t m_underlyingMutex;
988 # elif ELPP_OS_WINDOWS
989 CRITICAL_SECTION m_underlyingMutex;
990 # endif // ELPP_OS_UNIX
993 template <
typename M>
1010 static inline std::string getCurrentThreadId(
void) {
1011 std::stringstream ss;
1012 # if (ELPP_OS_WINDOWS)
1013 ss << GetCurrentThreadId();
1014 # endif // (ELPP_OS_WINDOWS)
1017 static inline void msleep(
int) {
1021 typedef base::threading::internal::ScopedLock<base::threading::Mutex>
ScopedLock;
1023 static inline std::string getCurrentThreadId(
void) {
1025 std::stringstream ss;
1026 ss << std::this_thread::get_id();
1029 static inline void msleep(
int ms) {
1031 #if ELPP_ASYNC_LOGGING
1032 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
1033 #endif // ELPP_ASYNC_LOGGING
1035 typedef std::mutex
Mutex;
1036 typedef std::lock_guard<std::mutex>
ScopedLock;
1037 # endif // !ELPP_USE_STD_THREADING
1039 namespace internal {
1049 template <
typename Mutex>
1060 static inline std::string getCurrentThreadId(
void) {
1061 return std::string();
1063 static inline void msleep(
int) {
1068 #endif // ELPP_THREADING_ENABLED
1090 #if defined(ELPP_UNICODE)
1091 std::locale elppUnicodeLocale(
"");
1093 std::locale elppUnicodeLocaleWindows(elppUnicodeLocale,
new std::codecvt_utf8_utf16<wchar_t>);
1094 elppUnicodeLocale = elppUnicodeLocaleWindows;
1096 fs->imbue(elppUnicodeLocale);
1097 #endif // defined(ELPP_UNICODE)
1098 if (fs->is_open()) {
1101 base::utils::safeDelete(fs);
1109 if (fs ==
nullptr) {
1112 std::streampos currPos = fs->tellg();
1113 fs->seekg(0, fs->end);
1114 std::size_t size =
static_cast<std::size_t
>(fs->tellg());
1120 static inline bool pathExists(
const char* path,
bool considerFile =
false) {
1121 if (path ==
nullptr) {
1127 return (stat(path, &st) == 0);
1128 #elif ELPP_OS_WINDOWS
1129 DWORD fileType = GetFileAttributesA(path);
1130 if (fileType == INVALID_FILE_ATTRIBUTES) {
1133 return considerFile ?
true : ((fileType & FILE_ATTRIBUTE_DIRECTORY) == 0 ?
false :
true);
1134 #endif // ELPP_OS_UNIX
1148 char* currPath =
const_cast<char*
>(path.c_str());
1149 std::string builtPath = std::string();
1151 if (path[0] ==
'/') {
1154 currPath =
STRTOK(currPath, base::consts::kFilePathSeperator, 0);
1155 #elif ELPP_OS_WINDOWS
1157 char* nextTok_ =
nullptr;
1158 currPath =
STRTOK(currPath, base::consts::kFilePathSeperator, &nextTok_);
1160 #endif // ELPP_OS_UNIX
1161 while (currPath !=
nullptr) {
1162 builtPath.append(currPath);
1163 builtPath.append(base::consts::kFilePathSeperator);
1165 status = mkdir(builtPath.c_str(), ELPP_LOG_PERMS);
1166 currPath =
STRTOK(
nullptr, base::consts::kFilePathSeperator, 0);
1167 #elif ELPP_OS_WINDOWS
1168 status = _mkdir(builtPath.c_str());
1169 currPath =
STRTOK(
nullptr, base::consts::kFilePathSeperator, &nextTok_);
1170 #endif // ELPP_OS_UNIX
1180 const char* seperator = base::consts::kFilePathSeperator) {
1181 if ((fullPath ==
"") || (fullPath.find(seperator) == std::string::npos)) {
1184 std::size_t lastSlashAt = fullPath.find_last_of(seperator);
1185 if (lastSlashAt == 0) {
1186 return std::string(seperator);
1188 return fullPath.substr(0, lastSlashAt + 1);
1192 std::size_t limit = base::consts::kSourceFilenameMaxLength) {
1193 std::size_t sizeOfFilename = strlen(filename);
1194 if (sizeOfFilename >= limit) {
1195 filename += (sizeOfFilename - limit);
1196 if (filename[0] !=
'.' && filename[1] !=
'.') {
1198 STRCAT(buff,
"..", limit);
1201 STRCAT(buff, filename, limit);
1205 std::size_t limit = base::consts::kSourceFilenameMaxLength,
1206 const char* seperator = base::consts::kFilePathSeperator) {
1207 const char *filename = fullPath.c_str();
1208 std::size_t lastSlashAt = fullPath.find_last_of(seperator);
1209 filename += lastSlashAt ? lastSlashAt+1 : 0;
1210 std::size_t sizeOfFilename = strlen(filename);
1211 if (sizeOfFilename >= limit) {
1212 filename += (sizeOfFilename - limit);
1213 if (filename[0] !=
'.' && filename[1] !=
'.') {
1215 STRCAT(buff,
"..", limit);
1218 STRCAT(buff, filename, limit);
1226 return c >=
'0' && c <=
'9';
1247 if (*str++ != *pattern++)
1252 return !*str && !*pattern;
1257 static inline std::string&
ltrim(std::string& str) {
1258 str.erase(str.begin(), std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun<int, int>(&std::isspace))));
1264 static inline std::string&
rtrim(std::string& str) {
1265 str.erase(std::find_if(str.rbegin(), str.rend(), std::not1(std::ptr_fun<int, int>(&std::isspace))).base(), str.end());
1271 static inline std::string&
trim(std::string& str) {
1279 static inline bool startsWith(
const std::string& str,
const std::string& start) {
1280 return (str.length() >= start.length()) && (str.compare(0, start.length(), start) == 0);
1287 static inline bool endsWith(
const std::string& str,
const std::string& end) {
1288 return (str.length() >= end.length()) && (str.compare(str.length() - end.length(), end.length(), end) == 0);
1296 static inline std::string&
replaceAll(std::string& str,
char replaceWhat,
char replaceWith) {
1297 std::replace(str.begin(), str.end(), replaceWhat, replaceWith);
1306 static inline std::string&
replaceAll(std::string& str,
const std::string& replaceWhat,
1307 const std::string& replaceWith) {
1308 if (replaceWhat == replaceWith)
1310 std::size_t foundAt = std::string::npos;
1311 while ((foundAt = str.find(replaceWhat, foundAt + 1)) != std::string::npos) {
1312 str.replace(foundAt, replaceWhat.length(), replaceWith);
1319 std::size_t foundAt = base::type::string_t::npos;
1320 while ((foundAt = str.find(replaceWhat, foundAt + 1)) != base::type::string_t::npos) {
1321 if (foundAt > 0 && str[foundAt - 1] == base::consts::kFormatSpecifierChar) {
1322 str.erase(foundAt > 0 ? foundAt - 1 : 0, 1);
1325 str.replace(foundAt, replaceWhat.length(), replaceWith);
1330 #if defined(ELPP_UNICODE)
1332 const std::string& replaceWith) {
1335 #endif // defined(ELPP_UNICODE)
1336 static inline std::string&
toUpper(std::string& str) {
1340 std::transform(str.begin(), str.end(), str.begin(), ::toupper);
1345 static inline bool cStringEq(
const char* s1,
const char* s2) {
1346 if (s1 ==
nullptr && s2 ==
nullptr)
return true;
1347 if (s1 ==
nullptr || s2 ==
nullptr)
return false;
1348 return strcmp(s1, s2) == 0;
1354 if (s1 ==
nullptr && s2 ==
nullptr)
return true;
1355 if (s1 ==
nullptr || s2 ==
nullptr)
return false;
1356 if (strlen(s1) != strlen(s2))
return false;
1357 while (*s1 !=
'\0' && *s2 !=
'\0') {
1358 if (::toupper(*s1) != ::toupper(*s2))
return false;
1367 for (; *str; ++str) {
1374 static inline char*
convertAndAddToBuff(std::size_t n,
int len,
char* buf,
const char* bufLim,
bool zeroPadded =
true) {
1375 char localBuff[10] =
"";
1376 char* p = localBuff +
sizeof(localBuff) - 2;
1378 for (; n > 0 && p > localBuff && len > 0; n /= 10, --len)
1379 *--p = static_cast<char>(n % 10 +
'0');
1385 while (p > localBuff && len-- > 0) *--p =
static_cast<char>(
'0');
1389 static inline char*
addToBuff(
const char* str,
char* buf,
const char* bufLim) {
1390 while ((buf < bufLim) && ((*buf = *str++) !=
'\0'))
1395 static inline char*
clearBuff(
char buff[], std::size_t lim) {
1404 std::size_t len_ = wcslen(line) + 1;
1405 char* buff_ =
static_cast<char*
>(malloc(len_ + 1));
1406 # if ELPP_OS_UNIX || (ELPP_OS_WINDOWS && !ELPP_CRT_DBG_WARNINGS)
1407 std::wcstombs(buff_, line, len_);
1408 # elif ELPP_OS_WINDOWS
1409 std::size_t convCount_ = 0;
1411 ::memset(static_cast<void*>(&mbState_), 0,
sizeof(mbState_));
1412 wcsrtombs_s(&convCount_, buff_, len_, &line, len_, &mbState_);
1413 # endif // ELPP_OS_UNIX || (ELPP_OS_WINDOWS && !ELPP_CRT_DBG_WARNINGS)
1421 static const char* getWindowsEnvironmentVariable(
const char* varname) {
1426 const DWORD bufferLen = 50;
1427 static char buffer[bufferLen];
1428 if (GetEnvironmentVariableA(varname, buffer, bufferLen)) {
1433 #endif // ELPP_OS_WINDOWS
1435 static inline std::string getProperty(
const char* prop) {
1437 char propVal[PROP_VALUE_MAX + 1];
1438 int ret = __system_property_get(prop, propVal);
1439 return ret == 0 ? std::string() : std::string(propVal);
1443 static std::string getDeviceName(
void) {
1444 std::stringstream ss;
1445 std::string manufacturer = getProperty(
"ro.product.manufacturer");
1446 std::string model = getProperty(
"ro.product.model");
1447 if (manufacturer.empty() || model.empty()) {
1448 return std::string();
1450 ss << manufacturer <<
"-" << model;
1453 #endif // ELPP_OS_ANDROID
1461 #if (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN)
1462 if (command ==
nullptr) {
1463 return std::string();
1465 FILE* proc =
nullptr;
1466 if ((proc = popen(command,
"r")) ==
nullptr) {
1468 return std::string();
1471 if (fgets(hBuff,
sizeof(hBuff), proc) !=
nullptr) {
1473 if (hBuff[strlen(hBuff) - 1] ==
'\n') {
1474 hBuff[strlen(hBuff) - 1] =
'\0';
1476 return std::string(hBuff);
1478 return std::string();
1481 return std::string();
1482 #endif // (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN)
1490 static std::string
getEnvironmentVariable(
const char* variableName,
const char* defaultVal,
const char* alternativeBashCommand =
nullptr) {
1492 const char* val = getenv(variableName);
1493 #elif ELPP_OS_WINDOWS
1494 const char* val = getWindowsEnvironmentVariable(variableName);
1495 #endif // ELPP_OS_UNIX
1496 if ((val ==
nullptr) || ((strcmp(val,
"") == 0))) {
1497 #if ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH)
1500 if (valBash.empty()) {
1501 return std::string(defaultVal);
1505 #elif ELPP_OS_WINDOWS || ELPP_OS_UNIX
1507 return std::string(defaultVal);
1508 #endif // ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH)
1510 return std::string(val);
1514 #if ELPP_OS_UNIX && !ELPP_OS_ANDROID
1516 #elif ELPP_OS_WINDOWS
1518 #elif ELPP_OS_ANDROID
1520 return std::string(
"android");
1522 return std::string();
1523 #endif // ELPP_OS_UNIX && !ELPP_OS_ANDROID
1530 #if ELPP_OS_UNIX && !ELPP_OS_ANDROID
1532 #elif ELPP_OS_WINDOWS
1534 #elif ELPP_OS_ANDROID
1536 return getDeviceName();
1538 return std::string();
1539 #endif // ELPP_OS_UNIX && !ELPP_OS_ANDROID
1544 return term ==
"xterm" || term ==
"xterm-color" || term ==
"xterm-256color" ||
1545 term ==
"screen" || term ==
"linux" || term ==
"cygwin";
1551 #define ELPP_INITI_BASIC_DECLR \
1555 std::string s_currentUser = el::base::utils::OS::currentUser(); \
1556 std::string s_currentHost = el::base::utils::OS::currentHost(); \
1557 bool s_termSupportsColor = el::base::utils::OS::termSupportsColor(); \
1561 class DateTime : base::StaticClass {
1570 if (tv !=
nullptr) {
1571 # if ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS)
1572 const unsigned __int64 delta_ = 11644473600000000Ui64;
1574 const unsigned __int64 delta_ = 11644473600000000ULL;
1575 # endif // ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS)
1576 const double secOffSet = 0.000001;
1577 const unsigned long usecOffSet = 1000000;
1579 GetSystemTimeAsFileTime(&fileTime);
1580 unsigned __int64 present = 0;
1581 present |= fileTime.dwHighDateTime;
1582 present = present << 32;
1583 present |= fileTime.dwLowDateTime;
1587 tv->tv_sec =
static_cast<long>(present * secOffSet);
1588 tv->tv_usec =
static_cast<long>(present % usecOffSet);
1592 #endif // ELPP_OS_WINDOWS
1600 struct timeval currTime;
1602 struct ::tm timeInfo;
1603 buildTimeInfo(&currTime, &timeInfo);
1604 const int kBuffSize = 30;
1605 char buff_[kBuffSize] =
"";
1606 parseFormat(buff_, kBuffSize, format, &timeInfo, static_cast<std::size_t>(currTime.tv_usec / msWidth->
m_offset), msWidth);
1607 return std::string(buff_);
1612 double result =
static_cast<double>(time);
1623 ss << result <<
" " <<
unit;
1630 return static_cast<unsigned long long>(
static_cast<unsigned long long>(1000000 * endTime.tv_sec + endTime.tv_usec) -
1631 static_cast<unsigned long long>(1000000 * startTime.tv_sec + startTime.tv_usec));
1633 return static_cast<unsigned long long>((((endTime.tv_sec - startTime.tv_sec) * 1000000) + (endTime.tv_usec - startTime.tv_usec)) / 1000);
1638 static inline struct ::tm* buildTimeInfo(
struct timeval* currTime, struct ::tm* timeInfo) {
1640 time_t rawTime = currTime->tv_sec;
1641 ::localtime_r(&rawTime, timeInfo);
1644 # if ELPP_COMPILER_MSVC
1648 localtime_s(timeInfo, &t);
1652 time_t rawTime = currTime->tv_sec;
1653 struct tm* tmInf = localtime(&rawTime);
1656 # endif // ELPP_COMPILER_MSVC
1657 #endif // ELPP_OS_UNIX
1659 static char* parseFormat(
char* buf, std::size_t bufSz,
const char* format,
const struct tm* tInfo,
1661 const char* bufLim = buf + bufSz;
1662 for (; *format; ++format) {
1663 if (*format == base::consts::kFormatSpecifierChar) {
1664 switch (*++format) {
1665 case base::consts::kFormatSpecifierChar:
1717 if (buf == bufLim)
break;
1727 setArgs(0, static_cast<char**>(
nullptr));
1737 inline void setArgs(
int argc,
const char** argv) {
1738 setArgs(argc, const_cast<char**>(argv));
1743 m_paramsWithValue.clear();
1744 if (argc == 0 || argv ==
nullptr) {
1749 for (
int i = 1; i < m_argc; ++i) {
1750 const char* v = (strstr(m_argv[i],
"="));
1751 if (v !=
nullptr && strlen(v) > 0) {
1752 std::string key = std::string(m_argv[i]);
1753 key = key.substr(0, key.find_first_of(
'='));
1758 m_paramsWithValue.insert(std::make_pair(key, std::string(v + 1)));
1765 m_params.push_back(std::string(m_argv[i]));
1772 return m_paramsWithValue.find(std::string(paramKey)) != m_paramsWithValue.end();
1777 return m_paramsWithValue.find(std::string(paramKey))->second.c_str();
1781 return std::find(m_params.begin(), m_params.end(), std::string(paramKey)) != m_params.end();
1785 return m_params.empty() && m_paramsWithValue.empty();
1788 inline std::size_t
size(
void)
const {
1789 return m_params.size() + m_paramsWithValue.size();
1792 for (
int i = 1; i < c.m_argc; ++i) {
1794 if (i < c.m_argc - 1) {
1804 std::map<std::string, std::string> m_paramsWithValue;
1805 std::vector<std::string> m_params;
1813 template <
typename T_Ptr,
typename Container>
1828 m_list = std::move(sr.m_list);
1835 for (std::size_t i = 0; i < m_list.size(); ++i) {
1836 if (m_list.at(i) != other.m_list.at(i)) {
1847 for (std::size_t i = 0; i < m_list.size(); ++i) {
1848 if (m_list.at(i) != other.m_list.at(i)) {
1861 m_list = std::move(sr.m_list);
1870 return m_list.begin();
1875 return m_list.end();
1881 return m_list.cbegin();
1886 return m_list.cend();
1891 return m_list.empty();
1896 return m_list.size();
1928 template <
typename T_Ptr,
typename T_Key = const
char*>
1961 if (!this->
empty()) {
1962 for (
auto&& curr : this->
list()) {
1963 base::utils::safeDelete(curr.second);
1965 this->
list().clear();
1972 this->
list().insert(std::make_pair(uniqKey, ptr));
1977 T_Ptr* existing =
get(uniqKey);
1978 if (existing !=
nullptr) {
1979 base::utils::safeDelete(existing);
1980 this->
list().erase(uniqKey);
1985 inline T_Ptr*
get(
const T_Key& uniqKey) {
1987 return it == this->
list().end()
2004 template <
typename T_Ptr,
typename Pred>
2045 if (!this->
empty()) {
2046 for (
auto&& curr : this->
list()) {
2047 base::utils::safeDelete(curr);
2049 this->
list().clear();
2056 for (; iter != this->
end(); ++iter) {
2061 if (iter != this->
end() && *iter !=
nullptr) {
2062 this->
list().erase(iter);
2063 base::utils::safeDelete(*iter);
2069 this->
list().push_back(ptr);
2074 template <
typename T,
typename T2>
2075 inline T_Ptr*
get(
const T& arg1,
const T2 arg2) {
2077 if (iter != this->
list().
end() && *iter !=
nullptr) {
2084 virtual inline void deepCopy(
const AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>& sr) {
2085 for (
const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) {
2112 m_userFormat(base::type::
string_t()),
2114 m_dateTimeFormat(std::string()),
2119 : m_level(level), m_userFormat(format) {
2124 m_level = logFormat.m_level;
2125 m_userFormat = logFormat.m_userFormat;
2126 m_format = logFormat.m_format;
2127 m_dateTimeFormat = logFormat.m_dateTimeFormat;
2128 m_flags = logFormat.m_flags;
2132 m_level = std::move(logFormat.m_level);
2133 m_userFormat = std::move(logFormat.m_userFormat);
2134 m_format = std::move(logFormat.m_format);
2135 m_dateTimeFormat = std::move(logFormat.m_dateTimeFormat);
2136 m_flags = std::move(logFormat.m_flags);
2140 m_level = logFormat.m_level;
2141 m_userFormat = logFormat.m_userFormat;
2142 m_dateTimeFormat = logFormat.m_dateTimeFormat;
2143 m_flags = logFormat.m_flags;
2151 return m_level == other.m_level && m_userFormat == other.m_userFormat && m_format == other.m_format &&
2152 m_dateTimeFormat == other.m_dateTimeFormat && m_flags == other.m_flags;
2164 std::size_t foundAt = base::type::string_t::npos;
2165 while ((foundAt = formatCopy.find(specifier, foundAt + 1)) != base::type::string_t::npos){
2166 if (foundAt > 0 && formatCopy[foundAt - 1] == base::consts::kFormatSpecifierChar) {
2170 formatCopy.erase(foundAt > 0 ? foundAt - 1 : 0, 1);
2193 std::size_t dateIndex = std::string::npos;
2194 if ((dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier)) != std::string::npos) {
2195 while (dateIndex > 0 && formatCopy[dateIndex - 1] == base::consts::kFormatSpecifierChar) {
2196 dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier, dateIndex + 1);
2198 if (dateIndex != std::string::npos) {
2203 m_format = formatCopy;
2212 return m_userFormat;
2220 return m_dateTimeFormat;
2228 return base::utils::hasFlag(flag, m_flags);
2244 if ((currFormat.size() >
index) && (ptr[0] ==
'{')) {
2248 std::stringstream ss;
2249 for (; *ptr; ++ptr, ++count) {
2256 currFormat.erase(
index, count);
2257 m_dateTimeFormat = ss.str();
2261 m_dateTimeFormat = std::string(base::consts::kDefaultDateTimeFormat);
2271 base::consts::kDebugLevelLogValue);
2273 base::consts::kDebugLevelShortLogValue);
2276 base::consts::kInfoLevelLogValue);
2278 base::consts::kInfoLevelShortLogValue);
2281 base::consts::kWarningLevelLogValue);
2283 base::consts::kWarningLevelShortLogValue);
2286 base::consts::kErrorLevelLogValue);
2288 base::consts::kErrorLevelShortLogValue);
2291 base::consts::kFatalLevelLogValue);
2293 base::consts::kFatalLevelShortLogValue);
2296 base::consts::kVerboseLevelLogValue);
2298 base::consts::kVerboseLevelShortLogValue);
2301 base::consts::kTraceLevelLogValue);
2303 base::consts::kTraceLevelShortLogValue);
2318 base::utils::addFlag(flag, &m_flags);
2325 std::string m_dateTimeFormat;
2338 m_formatSpecifier(formatSpecifier), m_resolver(resolver) {}
2342 return strcmp(m_formatSpecifier, formatSpecifier) == 0;
2346 const char* m_formatSpecifier;
2362 m_configurationType(c.m_configurationType),
2363 m_value(c.m_value) {
2367 m_level = c.m_level;
2368 m_configurationType = c.m_configurationType;
2369 m_value = c.m_value;
2379 m_configurationType(configurationType),
2390 return m_configurationType;
2394 inline const std::string&
value(
void)
const {
2416 m_configurationType(configurationType) {
2420 return ((conf !=
nullptr) && (conf->
level() == m_level) && (conf->
configurationType() == m_configurationType));
2431 std::string m_value;
2441 m_configurationFile(std::string()),
2442 m_isFromFile(false) {
2452 m_configurationFile(configurationFile),
2453 m_isFromFile(false) {
2455 if (useDefaultsForRemaining) {
2472 bool assertionPassed =
true;
2474 "Configuration file [" << configurationFile <<
"] does not exist!");
2475 if (!assertionPassed) {
2479 m_isFromFile = success;
2494 m_isFromFile =
false;
2502 if (base ==
nullptr || base ==
this) {
2517 bool result =
false;
2532 #if ELPP_COMPILER_INTEL
2535 return RegistryWithPred::get(level, configurationType) !=
nullptr;
2538 #endif // ELPP_COMPILER_INTEL
2555 unsafeSet(level, configurationType, value);
2557 unsafeSetGlobally(configurationType, value,
false);
2564 if (conf ==
nullptr) {
2593 return m_configurationFile;
2599 #if !defined(ELPP_NO_DEFAULT_LOG_FILE)
2603 #endif // !defined(ELPP_NO_DEFAULT_LOG_FILE)
2630 #if !defined(ELPP_NO_DEFAULT_LOG_FILE)
2632 #endif // !defined(ELPP_NO_DEFAULT_LOG_FILE)
2640 std::string(
"%datetime %level [%logger] [%user@%host] [%func] [%loc] %msg"));
2663 std::ifstream fileStream_(configurationFile.c_str(), std::ifstream::in);
2664 ELPP_ASSERT(fileStream_.is_open(),
"Unable to open configuration file [" << configurationFile <<
"] for parsing.");
2665 bool parsedSuccessfully =
false;
2666 std::string line = std::string();
2668 std::string currConfigStr = std::string();
2669 std::string currLevelStr = std::string();
2670 while (fileStream_.good()) {
2671 std::getline(fileStream_, line);
2672 parsedSuccessfully = parseLine(&line, &currConfigStr, &currLevelStr, &currLevel, sender);
2673 ELPP_ASSERT(parsedSuccessfully,
"Unable to parse configuration line: " << line);
2675 return parsedSuccessfully;
2690 bool parsedSuccessfully =
false;
2691 std::stringstream ss(configurationsString);
2692 std::string line = std::string();
2694 std::string currConfigStr = std::string();
2695 std::string currLevelStr = std::string();
2696 while (std::getline(ss, line)) {
2697 parsedSuccessfully = parseLine(&line, &currConfigStr, &currLevelStr, &currLevel, sender);
2698 ELPP_ASSERT(parsedSuccessfully,
"Unable to parse configuration line: " << line);
2700 return parsedSuccessfully;
2705 static void ignoreComments(std::string* line) {
2706 std::size_t foundAt = 0;
2707 std::size_t quotesStart = line->find(
"\"");
2708 std::size_t quotesEnd = std::string::npos;
2709 if (quotesStart != std::string::npos) {
2710 quotesEnd = line->find(
"\"", quotesStart + 1);
2711 while (quotesEnd != std::string::npos && line->at(quotesEnd - 1) ==
'\\') {
2713 quotesEnd = line->find(
"\"", quotesEnd + 2);
2716 if ((foundAt = line->find(base::consts::kConfigurationComment)) != std::string::npos) {
2717 if (foundAt < quotesEnd) {
2718 foundAt = line->find(base::consts::kConfigurationComment, quotesEnd + 1);
2720 *line = line->substr(0, foundAt);
2723 static inline bool isLevel(
const std::string& line) {
2727 static inline bool isComment(
const std::string& line) {
2731 static inline bool isConfig(
const std::string& line) {
2732 std::size_t assignment = line.find(
'=');
2733 return line !=
"" &&
2734 (line[0] >= 65 || line[0] <= 90 || line[0] >= 97 || line[0] <= 122) &&
2735 (assignment != std::string::npos) &&
2736 (line.size() > assignment);
2739 static bool parseLine(std::string* line, std::string* currConfigStr, std::string* currLevelStr,
Level* currLevel,
Configurations* conf) {
2741 std::string currValue = std::string();
2743 if (isComment(*line))
return true;
2744 ignoreComments(line);
2746 if (line->empty()) {
2750 if (isLevel(*line)) {
2751 if (line->size() <= 2) {
2754 *currLevelStr = line->substr(1, line->size() - 2);
2760 if (isConfig(*line)) {
2761 std::size_t assignment = line->find(
'=');
2762 *currConfigStr = line->substr(0, assignment);
2766 currValue = line->substr(assignment + 1);
2768 std::size_t quotesStart = currValue.find(
"\"", 0);
2769 std::size_t quotesEnd = std::string::npos;
2770 if (quotesStart != std::string::npos) {
2771 quotesEnd = currValue.find(
"\"", quotesStart + 1);
2772 while (quotesEnd != std::string::npos && currValue.at(quotesEnd - 1) ==
'\\') {
2773 currValue = currValue.erase(quotesEnd - 1, 1);
2774 quotesEnd = currValue.find(
"\"", quotesEnd + 2);
2777 if (quotesStart != std::string::npos && quotesEnd != std::string::npos) {
2779 ELPP_ASSERT((quotesStart < quotesEnd),
"Configuration error - No ending quote found in ["
2780 << currConfigStr <<
"]");
2781 ELPP_ASSERT((quotesStart + 1 != quotesEnd),
"Empty configuration value for [" << currConfigStr <<
"]");
2782 if ((quotesStart != quotesEnd) && (quotesStart + 1 != quotesEnd)) {
2784 currValue = currValue.substr(quotesStart + 1, quotesEnd - 1);
2793 conf->set(*currLevel, currConfig, currValue);
2799 std::string m_configurationFile;
2806 if (conf ==
nullptr) {
2807 unsafeSet(level, configurationType, value);
2814 if (conf ==
nullptr) {
2815 registerNew(
new Configuration(level, configurationType, value));
2817 conf->setValue(value);
2820 unsafeSetGlobally(configurationType, value,
false);
2827 if (includeGlobalLevel) {
2839 void unsafeSetGlobally(
ConfigurationType configurationType,
const std::string& value,
bool includeGlobalLevel) {
2840 if (includeGlobalLevel) {
2867 m_logStreamsReference = logStreamsReference;
2868 build(m_configurations);
2872 this->m_configurations = other.m_configurations;
2873 this->m_logStreamsReference = other.m_logStreamsReference;
2874 build(m_configurations);
2881 return m_configurations;
2885 return getConfigByVal<bool>(level, &m_enabledMap,
"enabled");
2889 return getConfigByVal<bool>(level, &m_toFileMap,
"toFile");
2893 return getConfigByRef<std::string>(level, &m_filenameMap,
"filename");
2897 return getConfigByVal<bool>(level, &m_toStandardOutputMap,
"toStandardOutput");
2901 return getConfigByRef<base::LogFormat>(level, &m_logFormatMap,
"logFormat");
2905 return getConfigByRef<base::MillisecondsWidth>(level, &m_millisecondsWidthMap,
"millisecondsWidth");
2909 return getConfigByVal<bool>(level, &m_performanceTrackingMap,
"performanceTracking");
2913 return getConfigByRef<base::FileStreamPtr>(level, &m_fileStreamMap,
"fileStream").
get();
2917 return getConfigByVal<std::size_t>(level, &m_maxLogFileSizeMap,
"maxLogFileSize");
2921 return getConfigByVal<std::size_t>(level, &m_logFlushThresholdMap,
"logFlushThreshold");
2926 std::map<Level, bool> m_enabledMap;
2927 std::map<Level, bool> m_toFileMap;
2928 std::map<Level, std::string> m_filenameMap;
2929 std::map<Level, bool> m_toStandardOutputMap;
2930 std::map<Level, base::LogFormat> m_logFormatMap;
2931 std::map<Level, base::MillisecondsWidth> m_millisecondsWidthMap;
2932 std::map<Level, bool> m_performanceTrackingMap;
2933 std::map<Level, base::FileStreamPtr> m_fileStreamMap;
2934 std::map<Level, std::size_t> m_maxLogFileSizeMap;
2935 std::map<Level, std::size_t> m_logFlushThresholdMap;
2944 template <
typename Conf_T>
2945 inline Conf_T getConfigByVal(
Level level,
const std::map<Level, Conf_T>* confMap,
const char* confName) {
2947 return unsafeGetConfigByVal(level, confMap, confName);
2950 template <
typename Conf_T>
2951 inline Conf_T& getConfigByRef(
Level level, std::map<Level, Conf_T>* confMap,
const char* confName) {
2953 return unsafeGetConfigByRef(level, confMap, confName);
2956 template <
typename Conf_T>
2957 inline Conf_T unsafeGetConfigByVal(
Level level,
const std::map<Level, Conf_T>* confMap,
const char* confName) {
2959 typename std::map<Level, Conf_T>::const_iterator it = confMap->find(level);
2960 if (it == confMap->end()) {
2966 << std::endl <<
"Please ensure you have properly configured logger.",
false);
2973 template <
typename Conf_T>
2974 inline Conf_T& unsafeGetConfigByRef(
Level level, std::map<Level, Conf_T>* confMap,
const char* confName) {
2976 typename std::map<Level, Conf_T>::iterator it = confMap->find(level);
2977 if (it == confMap->end()) {
2983 << std::endl <<
"Please ensure you have properly configured logger.",
false);
2989 template <
typename Conf_T>
2990 void setValue(
Level level,
const Conf_T& value, std::map<Level, Conf_T>* confMap,
bool includeGlobalLevel =
true) {
2992 if (confMap->empty() && includeGlobalLevel) {
2997 typename std::map<Level, Conf_T>::iterator it = confMap->find(
Level::Global);
2998 if (it != confMap->end() && it->second ==
value) {
3002 it = confMap->find(level);
3003 if (it == confMap->end()) {
3005 confMap->insert(std::make_pair(level, value));
3008 confMap->at(level) =
value;
3014 auto getBool = [] (std::string boolStr) ->
bool {
3016 return (boolStr ==
"TRUE" || boolStr ==
"true" || boolStr ==
"1");
3018 std::vector<Configuration*> withFileSizeLimit;
3020 Configuration* conf = *it;
3023 setValue(conf->level(), getBool(conf->value()), &m_enabledMap);
3025 setValue(conf->level(), getBool(conf->value()), &m_toFileMap);
3027 setValue(conf->level(), getBool(conf->value()), &m_toStandardOutputMap);
3035 setValue(conf->level(), base::LogFormat(conf->level(),
3039 base::MillisecondsWidth(static_cast<int>(getULong(conf->value()))), &m_millisecondsWidthMap);
3041 setValue(
Level::Global, getBool(conf->value()), &m_performanceTrackingMap);
3043 setValue(conf->level(),
static_cast<std::size_t
>(getULong(conf->value())), &m_maxLogFileSizeMap);
3044 #if !defined(ELPP_NO_DEFAULT_LOG_FILE)
3045 withFileSizeLimit.push_back(conf);
3046 #endif // !defined(ELPP_NO_DEFAULT_LOG_FILE)
3048 setValue(conf->level(),
static_cast<std::size_t
>(getULong(conf->value())), &m_logFlushThresholdMap);
3053 Configuration* conf = *it;
3055 insertFile(conf->level(), conf->value());
3058 for (std::vector<Configuration*>::iterator conf = withFileSizeLimit.begin();
3059 conf != withFileSizeLimit.end(); ++conf) {
3061 unsafeValidateFileRolling((*conf)->level(), base::defaultPreRollOutCallback);
3065 unsigned long getULong(std::string confVal) {
3068 valid = !confVal.empty() && std::find_if(confVal.begin(), confVal.end(),
3072 ELPP_ASSERT(valid,
"Configuration value not a valid integer [" << confVal <<
"]");
3075 return atol(confVal.c_str());
3078 std::string resolveFilename(
const std::string&
filename) {
3079 std::string resultingFilename =
filename;
3080 std::size_t dateIndex = std::string::npos;
3081 std::string dateTimeFormatSpecifierStr = std::string(base::consts::kDateTimeFormatSpecifierForFilename);
3082 if ((dateIndex = resultingFilename.find(dateTimeFormatSpecifierStr.c_str())) != std::string::npos) {
3083 while (dateIndex > 0 && resultingFilename[dateIndex - 1] == base::consts::kFormatSpecifierChar) {
3084 dateIndex = resultingFilename.find(dateTimeFormatSpecifierStr.c_str(), dateIndex + 1);
3086 if (dateIndex != std::string::npos) {
3087 const char* ptr = resultingFilename.c_str() + dateIndex;
3089 ptr += dateTimeFormatSpecifierStr.size();
3091 if ((resultingFilename.size() > dateIndex) && (ptr[0] ==
'{')) {
3095 std::stringstream ss;
3096 for (; *ptr; ++ptr, ++count) {
3103 resultingFilename.erase(dateIndex + dateTimeFormatSpecifierStr.size(), count);
3106 fmt = std::string(base::consts::kDefaultDateTimeFormatInFilename);
3108 base::MillisecondsWidth msWidth(3);
3114 return resultingFilename;
3117 void insertFile(
Level level,
const std::string& fullFilename) {
3118 std::string resolvedFilename = resolveFilename(fullFilename);
3119 if (resolvedFilename.empty()) {
3120 std::cerr <<
"Could not load empty file for logging, please re-check your configurations for level ["
3124 if (filePath.size() < resolvedFilename.size()) {
3127 auto create = [&](
Level level) {
3128 base::LogStreamsReferenceMap::iterator filestreamIter = m_logStreamsReference->find(resolvedFilename);
3130 if (filestreamIter == m_logStreamsReference->end()) {
3133 m_filenameMap.insert(std::make_pair(level, resolvedFilename));
3135 m_logStreamsReference->insert(std::make_pair(resolvedFilename,
base::FileStreamPtr(m_fileStreamMap.at(level))));
3138 m_filenameMap.insert(std::make_pair(level, filestreamIter->first));
3139 m_fileStreamMap.insert(std::make_pair(level,
base::FileStreamPtr(filestreamIter->second)));
3140 fs = filestreamIter->second.get();
3142 if (fs ==
nullptr) {
3146 setValue(level,
false, &m_toFileMap);
3151 create(m_filenameMap.empty() && m_fileStreamMap.empty() ?
Level::Global : level);
3156 if (fs ==
nullptr) {
3159 std::size_t
maxLogFileSize = unsafeGetConfigByVal(level, &m_maxLogFileSizeMap,
"maxLogFileSize");
3161 if (maxLogFileSize != 0 && currFileSize >= maxLogFileSize) {
3162 std::string fname = unsafeGetConfigByRef(level, &m_filenameMap,
"filename");
3163 ELPP_INTERNAL_INFO(1,
"Truncating log file [" << fname <<
"] as a result of configurations for level ["
3167 fs->open(fname, std::fstream::out | std::fstream::trunc);
3173 bool validateFileRolling(
Level level,
const PreRollOutCallback& PreRollOutCallback) {
3175 return unsafeValidateFileRolling(level, PreRollOutCallback);
3188 m_filename(filename),
3189 m_lineNumber(lineNumber),
3194 m_filename(hitCounter.m_filename),
3195 m_lineNumber(hitCounter.m_lineNumber),
3196 m_hitCounts(hitCounter.m_hitCounts) {
3200 m_filename = hitCounter.m_filename;
3201 m_lineNumber = hitCounter.m_lineNumber;
3202 m_hitCounts = hitCounter.m_hitCounts;
3217 if (m_hitCounts >= base::consts::kMaxLogPerCounter) {
3218 m_hitCounts = (n >= 1 ? base::consts::kMaxLogPerCounter % n : 0);
3228 return m_lineNumber;
3242 : m_filename(filename),
3243 m_lineNumber(lineNumber) {
3246 return ((counter !=
nullptr) &&
3247 (strcmp(counter->m_filename, m_filename) == 0) &&
3248 (counter->m_lineNumber == m_lineNumber));
3252 const char* m_filename;
3253 unsigned long int m_lineNumber;
3257 const char* m_filename;
3258 unsigned long int m_lineNumber;
3259 std::size_t m_hitCounts;
3266 bool validateEveryN(
const char* filename,
unsigned long int lineNumber, std::size_t n) {
3269 if (counter ==
nullptr) {
3273 bool result = (n >= 1 && counter->
hitCounts() != 0 && counter->
hitCounts() % n == 0);
3279 bool validateAfterN(
const char* filename,
unsigned long int lineNumber, std::size_t n) {
3282 if (counter ==
nullptr) {
3296 bool validateNTimes(
const char* filename,
unsigned long int lineNumber, std::size_t n) {
3299 if (counter ==
nullptr) {
3312 return get(filename, lineNumber);
3320 template <
typename T>
3321 class Callback :
protected base::threading::ThreadSafe {
3324 inline bool enabled(
void)
const {
return m_enabled; }
3330 virtual void handle(
const T* handlePtr) = 0;
3363 *logLine =
ELPP_LITERAL(
"\x1b[31m") + *logLine + resetColor;
3365 *logLine =
ELPP_LITERAL(
"\x1b[33m") + *logLine + resetColor;
3378 m_typedConfigurations(nullptr),
3379 m_parentApplicationName(std::string()),
3380 m_isConfigured(false),
3381 m_logStreamsReference(logStreamsReference) {
3382 initUnflushedCount();
3387 m_typedConfigurations(nullptr),
3388 m_parentApplicationName(std::string()),
3389 m_isConfigured(false),
3390 m_logStreamsReference(logStreamsReference) {
3391 initUnflushedCount();
3396 base::utils::safeDelete(m_typedConfigurations);
3398 m_typedConfigurations = logger.m_typedConfigurations;
3399 m_parentApplicationName = logger.m_parentApplicationName;
3400 m_isConfigured = logger.m_isConfigured;
3401 m_configurations = logger.m_configurations;
3402 m_unflushedCount = logger.m_unflushedCount;
3403 m_logStreamsReference = logger.m_logStreamsReference;
3407 base::utils::safeDelete(m_typedConfigurations);
3409 m_typedConfigurations = logger.m_typedConfigurations;
3410 m_parentApplicationName = logger.m_parentApplicationName;
3411 m_isConfigured = logger.m_isConfigured;
3412 m_configurations = logger.m_configurations;
3413 m_unflushedCount = logger.m_unflushedCount;
3414 m_logStreamsReference = logger.m_logStreamsReference;
3419 base::utils::safeDelete(m_typedConfigurations);
3428 m_isConfigured =
false;
3429 initUnflushedCount();
3430 if (m_typedConfigurations !=
nullptr) {
3438 if (m_configurations != configurations) {
3439 m_configurations.
setFromBase(const_cast<Configurations*>(&configurations));
3441 base::utils::safeDelete(m_typedConfigurations);
3443 resolveLoggerFormatSpec();
3444 m_isConfigured =
true;
3453 inline const std::string&
id(
void)
const {
3458 return m_parentApplicationName;
3466 return &m_configurations;
3470 return m_typedConfigurations;
3474 for (std::string::const_iterator it =
id.begin(); it !=
id.end(); ++it) {
3493 if (fs ==
nullptr && m_typedConfigurations->
toFile(level)) {
3494 fs = m_typedConfigurations->
fileStream(level);
3496 if (fs !=
nullptr) {
3498 m_unflushedCount.find(level)->second = 0;
3503 return ++m_unflushedCount.find(level)->second >= m_typedConfigurations->
logFlushThreshold(level);
3507 return m_logBuilder.get();
3515 return m_typedConfigurations->
enabled(level);
3518 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED
3519 # define LOGGER_LEVEL_WRITERS_SIGNATURES(FUNCTION_NAME)\
3520 template <typename T, typename... Args>\
3521 inline void FUNCTION_NAME(const char*, const T&, const Args&...);\
3522 template <typename T>\
3523 inline void FUNCTION_NAME(const T&);
3525 template <
typename T,
typename...
Args>
3526 inline void verbose(
int,
const char*,
const T&,
const Args&...);
3528 template <
typename T>
3529 inline void verbose(
int,
const T&);
3531 LOGGER_LEVEL_WRITERS_SIGNATURES(info)
3532 LOGGER_LEVEL_WRITERS_SIGNATURES(
debug)
3533 LOGGER_LEVEL_WRITERS_SIGNATURES(warn)
3534 LOGGER_LEVEL_WRITERS_SIGNATURES(
error)
3535 LOGGER_LEVEL_WRITERS_SIGNATURES(fatal)
3536 LOGGER_LEVEL_WRITERS_SIGNATURES(trace)
3537 # undef LOGGER_LEVEL_WRITERS_SIGNATURES
3538 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
3543 std::string m_parentApplicationName;
3544 bool m_isConfigured;
3546 std::map<Level, unsigned int> m_unflushedCount;
3564 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED
3565 template <
typename T,
typename...
Args>
3566 void log_(
Level,
int,
const char*,
const T&,
const Args&...);
3568 template <
typename T>
3569 inline void log_(
Level,
int,
const T&);
3571 template <
typename T,
typename...
Args>
3572 void log(
Level,
const char*,
const T&,
const Args&...);
3574 template <
typename T>
3576 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
3578 void initUnflushedCount(
void) {
3579 m_unflushedCount.clear();
3591 void resolveLoggerFormatSpec(
void)
const {
3594 base::LogFormat* logFormat =
3606 m_defaultLogBuilder(defaultLogBuilder) {
3616 m_defaultConfigurations.
setFromBase(const_cast<Configurations*>(&configurations));
3620 return &m_defaultConfigurations;
3623 Logger*
get(
const std::string&
id,
bool forceCreation =
true) {
3626 if (logger_ ==
nullptr && forceCreation) {
3629 ELPP_ASSERT(validId,
"Invalid logger ID [" <<
id <<
"]. Not registering this logger.");
3632 logger_ =
new Logger(
id, m_defaultConfigurations, &m_logStreamsReference);
3633 logger_->m_logBuilder = m_defaultLogBuilder;
3639 bool remove(
const std::string&
id) {
3640 if (
id ==
"default") {
3644 if (logger !=
nullptr) {
3650 inline bool has(
const std::string&
id) {
3651 return get(
id,
false) !=
nullptr;
3660 return &m_logStreamsReference;
3666 for (base::LogStreamsReferenceMap::iterator it = m_logStreamsReference.begin();
3667 it != m_logStreamsReference.end(); ++it) {
3668 if (it->second.get() ==
nullptr)
continue;
3669 it->second->flush();
3691 m_level = base::consts::kMaxVerboseLevel;
3707 auto addSuffix = [](std::stringstream& ss,
const char* sfx,
const char* prev) {
3709 std::string chr(ss.str().substr(0, ss.str().size() - strlen(prev)));
3710 ss.str(std::string(
""));
3714 std::string chr(ss.str().substr(0, ss.str().size() - strlen(sfx)));
3715 ss.str(std::string(
""));
3722 addSuffix(ss,
".h",
nullptr);
3723 m_modules.insert(std::make_pair(ss.str(),
level));
3724 addSuffix(ss,
".c",
".h");
3725 m_modules.insert(std::make_pair(ss.str(),
level));
3726 addSuffix(ss,
".cpp",
".c");
3727 m_modules.insert(std::make_pair(ss.str(),
level));
3728 addSuffix(ss,
".cc",
".cpp");
3729 m_modules.insert(std::make_pair(ss.str(),
level));
3730 addSuffix(ss,
".cxx",
".cc");
3731 m_modules.insert(std::make_pair(ss.str(),
level));
3732 addSuffix(ss,
".-inl.h",
".cxx");
3733 m_modules.insert(std::make_pair(ss.str(),
level));
3734 addSuffix(ss,
".hxx",
".-inl.h");
3735 m_modules.insert(std::make_pair(ss.str(),
level));
3736 addSuffix(ss,
".hpp",
".hxx");
3737 m_modules.insert(std::make_pair(ss.str(),
level));
3738 addSuffix(ss,
".hh",
".hpp");
3740 m_modules.insert(std::make_pair(ss.str(),
level));
3743 bool isLevel =
false;
3744 std::stringstream ss;
3755 if (!ss.str().empty() && level != -1) {
3757 ss.str(std::string(
""));
3764 }
else if (isLevel) {
3765 if (isdigit(*modules)) {
3772 if (!ss.str().empty() && level != -1) {
3779 if (m_modules.empty() || file ==
nullptr) {
3780 return vlevel <= m_level;
3782 std::map<std::string, base::type::VerboseLevel>::iterator it = m_modules.begin();
3783 for (; it != m_modules.end(); ++it) {
3785 return vlevel <= it->second;
3795 inline const std::map<std::string, base::type::VerboseLevel>&
modules(
void)
const {
3800 if (commandLineArgs->
hasParam(
"-v") || commandLineArgs->
hasParam(
"--verbose") ||
3801 commandLineArgs->
hasParam(
"-V") || commandLineArgs->
hasParam(
"--VERBOSE")) {
3802 setLevel(base::consts::kMaxVerboseLevel);
3822 std::map<std::string, base::type::VerboseLevel> m_modules;
3829 m_level(level), m_file(file), m_line(line), m_func(func),
3830 m_verboseLevel(verboseLevel), m_logger(logger), m_message(std::move(logger->stream().str())) {
3833 inline const std::string&
file(
void)
const {
return m_file; }
3834 inline unsigned long int line(
void)
const {
return m_line; }
3835 inline const std::string&
func(
void)
const {
return m_func; }
3842 unsigned long int m_line;
3849 #if ELPP_ASYNC_LOGGING
3850 class AsyncLogItem {
3853 : m_logMessage(logMessage), m_dispatchData(data), m_logLine(logLine) {}
3854 virtual ~AsyncLogItem() {}
3855 inline LogMessage* logMessage(
void) {
return &m_logMessage; }
3856 inline LogDispatchData* data(
void) {
return &m_dispatchData; }
3860 LogDispatchData m_dispatchData;
3863 class AsyncLogQueue :
public base::threading::ThreadSafe {
3865 virtual ~AsyncLogQueue() {
3869 inline AsyncLogItem next(
void) {
3871 AsyncLogItem result = m_queue.front();
3876 inline void push(
const AsyncLogItem& item) {
3880 inline void pop(
void) {
3884 inline AsyncLogItem front(
void) {
3886 return m_queue.front();
3888 inline bool empty(
void) {
3890 return m_queue.empty();
3893 std::queue<AsyncLogItem> m_queue;
3897 virtual ~IWorker() {}
3898 virtual void start() = 0;
3900 #endif // ELPP_ASYNC_LOGGING
3901 class Storage : base::NoCopy,
public base::threading::ThreadSafe {
3904 #if ELPP_ASYNC_LOGGING
3912 m_vRegistry(new base::
VRegistry(0, &m_flags)),
3914 m_asyncLogQueue(new base::AsyncLogQueue()),
3915 m_asyncDispatchWorker(asyncDispatchWorker),
3917 m_preRollOutCallback(base::defaultPreRollOutCallback) {
3919 m_registeredLoggers->
get(std::string(base::consts::kDefaultLoggerId));
3921 Logger* performanceLogger = m_registeredLoggers->
get(std::string(base::consts::kPerformanceLoggerId));
3924 #if defined(ELPP_SYSLOG)
3926 Logger* sysLogLogger = m_registeredLoggers->
get(std::string(base::consts::kSysLogLoggerId));
3931 #endif // defined(ELPP_SYSLOG)
3933 #if ELPP_ASYNC_LOGGING
3934 installLogDispatchCallback<base::AsyncLogDispatchCallback>(std::string(
"AsyncLogDispatchCallback"));
3936 installLogDispatchCallback<base::DefaultLogDispatchCallback>(std::string(
"DefaultLogDispatchCallback"));
3937 #endif // ELPP_ASYNC_LOGGING
3938 installPerformanceTrackingCallback<base::DefaultPerformanceTrackingCallback>(std::string(
"DefaultPerformanceTrackingCallback"));
3940 #if ELPP_ASYNC_LOGGING
3941 m_asyncDispatchWorker->start();
3942 #endif // ELPP_ASYNC_LOGGING
3947 #if ELPP_ASYNC_LOGGING
3949 uninstallLogDispatchCallback<base::AsyncLogDispatchCallback>(std::string(
"AsyncLogDispatchCallback"));
3950 installLogDispatchCallback<base::DefaultLogDispatchCallback>(std::string(
"DefaultLogDispatchCallback"));
3952 base::utils::safeDelete(m_asyncDispatchWorker);
3954 base::utils::safeDelete(m_asyncLogQueue);
3955 #endif // ELPP_ASYNC_LOGGING
3957 base::utils::safeDelete(m_registeredHitCounters);
3959 base::utils::safeDelete(m_registeredLoggers);
3961 base::utils::safeDelete(m_vRegistry);
3977 return m_registeredHitCounters;
3981 return m_registeredLoggers;
3988 #if ELPP_ASYNC_LOGGING
3989 inline base::AsyncLogQueue* asyncLogQueue(
void)
const {
3990 return m_asyncLogQueue;
3992 #endif // ELPP_ASYNC_LOGGING
3995 return &m_commandLineArgs;
3999 base::utils::addFlag(flag, &m_flags);
4003 base::utils::removeFlag(flag, &m_flags);
4007 return base::utils::hasFlag(flag, m_flags);
4019 m_preRollOutCallback = callback;
4023 m_preRollOutCallback = base::defaultPreRollOutCallback;
4027 return m_preRollOutCallback;
4032 return std::find(m_customFormatSpecifiers.begin(), m_customFormatSpecifiers.end(),
4033 formatSpecifier) != m_customFormatSpecifiers.end();
4041 m_customFormatSpecifiers.push_back(customFormatSpecifier);
4046 std::vector<CustomFormatSpecifier>::iterator it = std::find(m_customFormatSpecifiers.begin(),
4047 m_customFormatSpecifiers.end(), formatSpecifier);
4048 if (it != m_customFormatSpecifiers.end() && strcmp(formatSpecifier, it->formatSpecifier()) == 0) {
4049 m_customFormatSpecifiers.erase(it);
4056 return &m_customFormatSpecifiers;
4060 m_loggingLevel = level;
4063 template <
typename T>
4065 return installCallback<T, base::type::LogDispatchCallbackPtr>(
id, &m_logDispatchCallbacks);
4068 template <
typename T>
4070 uninstallCallback<T, base::type::LogDispatchCallbackPtr>(
id, &m_logDispatchCallbacks);
4072 template <
typename T>
4074 return callback<T, base::type::LogDispatchCallbackPtr>(
id, &m_logDispatchCallbacks);
4077 template <
typename T>
4079 return installCallback<T, base::type::PerformanceTrackingCallbackPtr>(
id, &m_performanceTrackingCallbacks);
4082 template <
typename T>
4084 uninstallCallback<T, base::type::PerformanceTrackingCallbackPtr>(
id, &m_performanceTrackingCallbacks);
4087 template <
typename T>
4089 return callback<T, base::type::PerformanceTrackingCallbackPtr>(
id, &m_performanceTrackingCallbacks);
4096 #if ELPP_ASYNC_LOGGING
4097 base::AsyncLogQueue* m_asyncLogQueue;
4098 base::IWorker* m_asyncDispatchWorker;
4099 #endif // ELPP_ASYNC_LOGGING
4101 PreRollOutCallback m_preRollOutCallback;
4102 std::map<std::string, base::type::LogDispatchCallbackPtr> m_logDispatchCallbacks;
4103 std::map<std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
4104 std::vector<CustomFormatSpecifier> m_customFormatSpecifiers;
4105 Level m_loggingLevel;
4115 void setApplicationArguments(
int argc,
char** argv) {
4116 m_commandLineArgs.
setArgs(argc, argv);
4119 #if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
4126 it->second->configure(c);
4129 #endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
4130 #if defined(ELPP_LOGGING_FLAGS_FROM_ARG)
4132 m_flags = atoi(m_commandLineArgs.
getParamValue(base::consts::kLoggingFlagsParam));
4134 #endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG)
4137 inline void setApplicationArguments(
int argc,
const char** argv) {
4138 setApplicationArguments(argc, const_cast<char**>(argv));
4141 template <
typename T,
typename TPtr>
4142 inline bool installCallback(
const std::string&
id, std::map<std::string, TPtr>* mapT) {
4143 if (mapT->find(
id) == mapT->end()) {
4144 mapT->insert(std::make_pair(
id, TPtr(
new T())));
4150 template <
typename T,
typename TPtr>
4151 inline void uninstallCallback(
const std::string&
id, std::map<std::string, TPtr>* mapT) {
4152 if (mapT->find(
id) != mapT->end()) {
4157 template <
typename T,
typename TPtr>
4158 inline T* callback(
const std::string&
id, std::map<std::string, TPtr>* mapT) {
4159 typename std::map<std::string, TPtr>::iterator iter = mapT->find(
id);
4160 if (iter != mapT->end()) {
4161 return static_cast<T*
>(iter->second.get());
4167 #define ELPP el::base::elStorage
4181 if (fs !=
nullptr) {
4182 fs->write(logLine.c_str(), logLine.size());
4186 <<
"Few possible reasons (could be something else):\n" <<
" * Permission denied\n"
4187 <<
" * Disk full\n" <<
" * Disk is not writable",
true);
4195 <<
"has not been configured but [TO_FILE] is configured to TRUE. [Logger ID: "
4205 #if defined(ELPP_SYSLOG)
4208 int sysLogPriority = 0;
4210 sysLogPriority = LOG_EMERG;
4212 sysLogPriority = LOG_ERR;
4214 sysLogPriority = LOG_WARNING;
4216 sysLogPriority = LOG_INFO;
4218 sysLogPriority = LOG_DEBUG;
4220 sysLogPriority = LOG_NOTICE;
4221 # if defined(ELPP_UNICODE)
4223 syslog(sysLogPriority,
"%s", line);
4226 syslog(sysLogPriority,
"%s", logLine.c_str());
4229 #endif // defined(ELPP_SYSLOG)
4232 #if ELPP_ASYNC_LOGGING
4233 class AsyncLogDispatchCallback :
public LogDispatchCallback {
4235 void handle(
const LogDispatchData* data) {
4237 if (data->dispatchAction() ==
base::DispatchAction::NormalLog && data->logMessage()->logger()->typedConfigurations()->toStandardOutput(data->logMessage()->level())) {
4239 data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, data->logMessage()->level());
4243 if (data->logMessage()->logger()->typedConfigurations()->toFile(data->logMessage()->level())) {
4244 ELPP->asyncLogQueue()->push(AsyncLogItem(*(data->logMessage()), *data, logLine));
4248 class AsyncDispatchWorker :
public base::IWorker,
public base::threading::ThreadSafe {
4250 AsyncDispatchWorker() {
4251 setContinueRunning(
false);
4254 virtual ~AsyncDispatchWorker() {
4255 setContinueRunning(
false);
4261 inline bool clean() {
4263 std::unique_lock<std::mutex> lk(m);
4264 cv.wait(lk, []{
return !
ELPP->asyncLogQueue()->empty(); });
4268 return ELPP->asyncLogQueue()->empty();
4271 inline void emptyQueue() {
4272 while (!
ELPP->asyncLogQueue()->empty()) {
4273 AsyncLogItem data =
ELPP->asyncLogQueue()->next();
4275 base::threading::msleep(100);
4279 virtual inline void start() {
4280 base::threading::msleep(5000);
4281 setContinueRunning(
true);
4282 std::thread t1(&AsyncDispatchWorker::runner,
this);
4286 void handle(AsyncLogItem* logItem) {
4287 LogDispatchData* data = logItem->data();
4288 LogMessage* logMessage = logItem->logMessage();
4289 Logger*
logger = logMessage->logger();
4290 base::TypedConfigurations* conf = logger->typedConfigurations();
4293 if (conf->toFile(logMessage->level())) {
4295 if (fs !=
nullptr) {
4296 fs->write(logLine.c_str(), logLine.size());
4299 << conf->filename(logMessage->level()) <<
"].\n"
4300 <<
"Few possible reasons (could be something else):\n" <<
" * Permission denied\n"
4301 <<
" * Disk full\n" <<
" * Disk is not writable",
true);
4304 logger->flush(logMessage->level(), fs);
4309 <<
"has not been configured but [TO_FILE] is configured to TRUE. [Logger ID: " << logger->id() <<
"]",
false);
4313 # if defined(ELPP_SYSLOG)
4316 int sysLogPriority = 0;
4318 sysLogPriority = LOG_EMERG;
4320 sysLogPriority = LOG_ERR;
4322 sysLogPriority = LOG_WARNING;
4324 sysLogPriority = LOG_INFO;
4326 sysLogPriority = LOG_DEBUG;
4328 sysLogPriority = LOG_NOTICE;
4329 # if defined(ELPP_UNICODE)
4331 syslog(sysLogPriority,
"%s", line);
4334 syslog(sysLogPriority,
"%s", logLine.c_str());
4337 # endif // defined(ELPP_SYSLOG)
4341 while (continueRunning()) {
4343 base::threading::msleep(10);
4347 static void* runner(
void *context) {
4348 static_cast<AsyncDispatchWorker*
>(context)->run();
4352 void setContinueRunning(
bool value) {
4354 m_continueRunning =
value;
4356 bool continueRunning(
void) {
4357 return m_continueRunning;
4360 std::condition_variable cv;
4361 bool m_continueRunning;
4364 #endif // ELPP_ASYNC_LOGGING
4373 char buff[base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength] =
"";
4374 const char* bufLim = buff +
sizeof(buff);
4383 base::threading::getCurrentThreadId());
4413 base::consts::kSourceLineMaxLength, buf, bufLim,
false);
4419 base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength);
4424 base::consts::kSourceLineMaxLength, buf, bufLim,
false);
4437 #if !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS)
4438 for (std::vector<CustomFormatSpecifier>::const_iterator it =
ELPP->customFormatSpecifiers()->begin();
4439 it !=
ELPP->customFormatSpecifiers()->end(); ++it) {
4440 std::string fs(it->formatSpecifier());
4444 #endif // !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS)
4454 m_logMessage(std::move(logMessage)),
4455 m_dispatchAction(std::move(dispatchAction)) {
4469 tc->validateFileRolling(m_logMessage.
level(),
ELPP->preRollOutCallback());
4473 for (
const std::pair<std::string, base::type::LogDispatchCallbackPtr>& h
4474 :
ELPP->m_logDispatchCallbacks) {
4475 callback = h.second.get();
4476 if (callback !=
nullptr && callback->
enabled()) {
4477 data.setLogMessage(&m_logMessage);
4478 data.setDispatchAction(m_dispatchAction);
4491 #if defined(ELPP_STL_LOGGING)
4492 namespace workarounds {
4500 template <
typename T,
typename Container>
4501 class IterableContainer {
4503 typedef typename Container::iterator iterator;
4504 typedef typename Container::const_iterator const_iterator;
4505 IterableContainer(
void) {}
4506 virtual ~IterableContainer(
void) {}
4507 iterator begin(
void) {
return getContainer().begin(); }
4508 iterator end(
void) {
return getContainer().end(); }
4510 virtual Container& getContainer(
void) = 0;
4513 template<
typename T,
typename Container = std::vector<T>,
typename Comparator = std::less<
typename Container::value_type>>
4514 class IterablePriorityQueue :
public IterableContainer<T, Container>,
public std::priority_queue<T, Container, Comparator> {
4516 IterablePriorityQueue(std::priority_queue<T, Container, Comparator> queue_) {
4517 std::size_t count_ = 0;
4518 while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) {
4519 this->push(queue_.top());
4524 inline Container& getContainer(
void) {
4529 template<
typename T,
typename Container = std::deque<T>>
4530 class IterableQueue :
public IterableContainer<T, Container>,
public std::queue<T, Container> {
4532 IterableQueue(std::queue<T, Container> queue_) {
4533 std::size_t count_ = 0;
4534 while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) {
4535 this->push(queue_.front());
4540 inline Container& getContainer(
void) {
4545 template<
typename T,
typename Container = std::deque<T>>
4546 class IterableStack :
public IterableContainer<T, Container>,
public std::stack<T, Container> {
4548 IterableStack(std::stack<T, Container> stack_) {
4549 std::size_t count_ = 0;
4550 while (++count_ < base::consts::kMaxLogPerContainer && !stack_.empty()) {
4551 this->push(stack_.top());
4556 inline Container& getContainer(
void) {
4561 #endif // defined(ELPP_STL_LOGGING)
4572 # define ELPP_SIMPLE_LOG(LOG_TYPE)\
4573 inline MessageBuilder& operator<<(LOG_TYPE msg) {\
4574 m_logger->stream() << msg;\
4575 if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {\
4576 m_logger->stream() << " ";\
4602 if (msg ==
nullptr) {
4603 m_logger->stream() << base::consts::kNullPointer;
4606 # if defined(ELPP_UNICODE)
4607 m_logger->stream() <<
msg;
4610 m_logger->stream() << buff_;
4614 m_logger->stream() <<
" ";
4620 m_logger->stream() << OStreamMani;
4623 #define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp) \
4624 template <typename T> \
4625 inline MessageBuilder& operator<<(const temp<T>& template_inst) { \
4626 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
4628 #define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp) \
4629 template <typename T1, typename T2> \
4630 inline MessageBuilder& operator<<(const temp<T1, T2>& template_inst) { \
4631 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
4633 #define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp) \
4634 template <typename T1, typename T2, typename T3> \
4635 inline MessageBuilder& operator<<(const temp<T1, T2, T3>& template_inst) { \
4636 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
4638 #define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp) \
4639 template <typename T1, typename T2, typename T3, typename T4> \
4640 inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4>& template_inst) { \
4641 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
4643 #define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp) \
4644 template <typename T1, typename T2, typename T3, typename T4, typename T5> \
4645 inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4, T5>& template_inst) { \
4646 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
4649 #if defined(ELPP_STL_LOGGING)
4657 template <class T, class Container>
4659 base::workarounds::IterableQueue<T, Container> iterableQueue_ =
4660 static_cast<base::workarounds::IterableQueue<T, Container>
>(queue_);
4661 return writeIterator(iterableQueue_.begin(), iterableQueue_.end(), iterableQueue_.size());
4663 template <
class T,
class Container>
4664 inline MessageBuilder& operator<<(const std::stack<T, Container>& stack_) {
4665 base::workarounds::IterableStack<T, Container> iterableStack_ =
4666 static_cast<base::workarounds::IterableStack<T, Container>
>(stack_);
4667 return writeIterator(iterableStack_.begin(), iterableStack_.end(), iterableStack_.size());
4669 template <
class T,
class Container,
class Comparator>
4670 inline MessageBuilder& operator<<(const std::priority_queue<T, Container, Comparator>& priorityQueue_) {
4671 base::workarounds::IterablePriorityQueue<T, Container, Comparator> iterablePriorityQueue_ =
4672 static_cast<base::workarounds::IterablePriorityQueue<T, Container, Comparator>
>(priorityQueue_);
4673 return writeIterator(iterablePriorityQueue_.begin(), iterablePriorityQueue_.end(), iterablePriorityQueue_.size());
4675 template <
class First,
class Second>
4676 inline MessageBuilder& operator<<(const std::pair<First, Second>& pair_) {
4678 operator << (static_cast<First>(pair_.first));
4680 operator << (static_cast<Second>(pair_.second));
4684 template <std::
size_t Size>
4685 inline MessageBuilder& operator<<(const std::bitset<Size>& bitset_) {
4691 # if defined(ELPP_LOG_STD_ARRAY)
4692 template <
class T, std::
size_t Size>
4693 inline MessageBuilder& operator<<(const std::array<T, Size>& array) {
4694 return writeIterator(array.begin(), array.end(), array.size());
4696 # endif // defined(ELPP_LOG_STD_ARRAY)
4697 # if defined(ELPP_LOG_UNORDERED_MAP)
4700 # endif // defined(ELPP_LOG_UNORDERED_MAP)
4701 # if defined(ELPP_LOG_UNORDERED_SET)
4704 # endif // defined(ELPP_LOG_UNORDERED_SET)
4705 #endif // defined(ELPP_STL_LOGGING)
4706 #if defined(ELPP_QT_LOGGING)
4708 # if defined(ELPP_UNICODE)
4709 m_logger->stream() << msg.toStdWString();
4711 m_logger->stream() << msg.toStdString();
4712 # endif // defined(ELPP_UNICODE)
4722 # if defined(ELPP_UNICODE)
4723 m_logger->stream() << QString::number(msg).toStdWString();
4725 m_logger->stream() << QString::number(msg).toStdString();
4726 # endif // defined(ELPP_UNICODE)
4730 # if defined(ELPP_UNICODE)
4731 m_logger->stream() << QString::number(msg).toStdWString();
4733 m_logger->stream() << QString::number(msg).toStdString();
4734 # endif // defined(ELPP_UNICODE)
4738 m_logger->stream() << msg.toLatin1();
4742 m_logger->stream() << msg.latin1();
4751 template <typename First, typename
Second>
4754 operator << (static_cast<First>(pair_.first));
4756 operator << (static_cast<Second>(pair_.second));
4760 template <
typename K,
typename V>
4763 QList<K> keys = map_.keys();
4764 typename QList<K>::const_iterator begin = keys.begin();
4765 typename QList<K>::const_iterator end = keys.end();
4766 int max_ =
static_cast<int>(base::consts::kMaxLogPerContainer);
4767 for (
int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) {
4769 operator << (static_cast<K>(*begin));
4771 operator << (static_cast<V>(map_.value(*begin)));
4773 m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator :
ELPP_LITERAL(
""));
4781 template <
typename K,
typename V>
4783 operator << (static_cast<QMap<K, V>>(map_));
4786 template <
typename K,
typename V>
4789 QList<K> keys = hash_.keys();
4790 typename QList<K>::const_iterator begin = keys.begin();
4791 typename QList<K>::const_iterator end = keys.end();
4792 int max_ =
static_cast<int>(base::consts::kMaxLogPerContainer);
4793 for (
int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) {
4795 operator << (static_cast<K>(*begin));
4797 operator << (static_cast<V>(hash_.value(*begin)));
4799 m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator :
ELPP_LITERAL(
""));
4807 template <
typename K,
typename V>
4808 inline MessageBuilder& operator<<(const QMultiHash<K, V>& multiHash_) {
4809 operator << (static_cast<QHash<K, V>>(multiHash_));
4812 #endif // defined(ELPP_QT_LOGGING)
4813 #if defined(ELPP_BOOST_LOGGING)
4822 #endif // defined(ELPP_BOOST_LOGGING)
4832 #define MAKE_CONTAINERELPP_FRIENDLY(ContainerType, SizeMethod, ElementInstance) \
4833 el::base::type::ostream_t& operator<<(el::base::type::ostream_t& ss, const ContainerType& container) {\
4834 const el::base::type::char_t* sep = ELPP->hasFlag(el::LoggingFlag::NewLineForContainer) ? \
4835 ELPP_LITERAL("\n ") : ELPP_LITERAL(", ");\
4836 ContainerType::const_iterator elem = container.begin();\
4837 ContainerType::const_iterator endElem = container.end();\
4838 std::size_t size_ = container.SizeMethod; \
4839 ss << ELPP_LITERAL("[");\
4840 for (std::size_t i = 0; elem != endElem && i < el::base::consts::kMaxLogPerContainer; ++i, ++elem) { \
4841 ss << ElementInstance;\
4842 ss << ((i < size_ - 1) ? sep : ELPP_LITERAL(""));\
4844 if (elem != endElem) {\
4845 ss << ELPP_LITERAL("...");\
4847 ss << ELPP_LITERAL("]");\
4850 #if defined(ELPP_WXWIDGETS_LOGGING)
4852 # define ELPP_WX_PTR_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), *(*elem))
4853 # define ELPP_WX_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), (*elem))
4854 # define ELPP_WX_HASH_MAP_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), \
4855 ELPP_LITERAL("(") << elem->first << ELPP_LITERAL(", ") << elem->second << ELPP_LITERAL(")")
4857 # define ELPP_WX_PTR_ENABLED(ContainerType)
4858 # define ELPP_WX_ENABLED(ContainerType)
4859 # define ELPP_WX_HASH_MAP_ENABLED(ContainerType)
4860 #endif // defined(ELPP_WXWIDGETS_LOGGING)
4862 template <
class Class>
4864 #undef ELPP_SIMPLE_LOG
4865 #undef ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG
4866 #undef ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG
4867 #undef ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG
4868 #undef ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG
4869 #undef ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG
4874 template<
class Iterator>
4875 inline MessageBuilder& writeIterator(Iterator begin_, Iterator end_, std::size_t size_) {
4877 for (std::size_t i = 0; begin_ != end_ && i < base::consts::kMaxLogPerContainer; ++i, ++begin_) {
4879 m_logger->stream() << ((i < size_ - 1) ? m_containerLogSeperator :
ELPP_LITERAL(
""));
4881 if (begin_ != end_) {
4886 m_logger->stream() <<
" ";
4901 template <
typename T>
4920 template <
typename T>
4922 #if ELPP_LOGGING_ENABLED
4926 #endif // ELPP_LOGGING_ENABLED
4931 #if ELPP_LOGGING_ENABLED
4935 #endif // ELPP_LOGGING_ENABLED
4948 va_list loggersList;
4949 va_start(loggersList, loggerIds);
4950 const char*
id = loggerIds;
4951 for (
int i = 0; i < count; ++i) {
4953 id = va_arg(loggersList,
const char*);
4955 va_end(loggersList);
4981 ELPP->acquireLock();
4982 if (!
ELPP->registeredLoggers()->has(std::string(base::consts::kDefaultLoggerId))) {
4984 ELPP->registeredLoggers()->get(std::string(base::consts::kDefaultLoggerId));
4986 ELPP->releaseLock();
4988 <<
"Logger [" << loggerId <<
"] is not registered yet!";
5005 #if ELPP_LOGGING_ENABLED
5007 bool firstDispatched =
false;
5012 if (firstDispatched) {
5015 firstDispatched =
true;
5017 logMessage =
m_logger->stream().str();
5042 #endif // ELPP_LOGGING_ENABLED
5057 <<
"Aborting application. Reason: Fatal log at [" <<
m_file <<
":" <<
m_line <<
"]";
5058 std::stringstream reasonStream;
5059 reasonStream <<
"Fatal log at [" <<
m_file <<
":" << m_line <<
"]"
5060 <<
" If you wish to disable 'abort on fatal log' please use "
5061 <<
"el::Helpers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog)";
5062 base::utils::abort(1, reasonStream.str());
5072 base::
Writer(level, file, line, func, dispatchAction, verboseLevel) {
5077 #if ELPP_COMPILER_MSVC
5079 strerror_s(buff, 256, errno);
5080 m_logger->stream() <<
": " << buff <<
" [" << errno <<
"]";
5082 m_logger->stream() <<
": " << strerror(errno) <<
" [" << errno <<
"]";
5089 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED
5090 template <
typename T,
typename...
Args>
5091 void Logger::log_(
Level level,
int vlevel,
const char* s,
const T& value,
const Args&... args) {
5092 base::MessageBuilder b;
5095 if (*s == base::consts::kFormatSpecifierChar) {
5096 if (*(s + 1) == base::consts::kFormatSpecifierChar) {
5099 if (*(s + 1) == base::consts::kFormatSpecifierCharValue) {
5102 log_(level, vlevel, ++s, args...);
5109 ELPP_INTERNAL_ERROR(
"Too many arguments provided. Unable to handle. Please provide more format specifiers",
false);
5111 template <
typename T>
5112 inline void Logger::log_(
Level level,
int vlevel,
const T& log) {
5114 if (
ELPP->vRegistry()->allowed(vlevel, __FILE__)) {
5121 base::Writer(level,
"FILE", 0,
"FUNCTION").construct(
this,
false) <<
log;
5124 template <
typename T,
typename...
Args>
5127 log_(level, 0, s, value, args...);
5129 template <
typename T>
5132 log_(level, 0, log);
5134 # if ELPP_VERBOSE_LOG
5135 template <
typename T,
typename...
Args>
5136 inline void Logger::verbose(
int vlevel,
const char* s,
const T& value,
const Args&... args) {
5140 template <
typename T>
5141 inline void Logger::verbose(
int vlevel,
const T& log) {
5146 template <
typename T,
typename...
Args>
5147 inline void Logger::verbose(
int,
const char*,
const T&,
const Args&...) {
5150 template <
typename T>
5151 inline void Logger::verbose(
int,
const T&) {
5154 # endif // ELPP_VERBOSE_LOG
5155 # define LOGGER_LEVEL_WRITERS(FUNCTION_NAME, LOG_LEVEL)\
5156 template <typename T, typename... Args>\
5157 inline void Logger::FUNCTION_NAME(const char* s, const T& value, const Args&... args) {\
5158 log(LOG_LEVEL, s, value, args...);\
5160 template <typename T>\
5161 inline void Logger::FUNCTION_NAME(const T& value) {\
5162 log(LOG_LEVEL, value);\
5164 # define LOGGER_LEVEL_WRITERS_DISABLED(FUNCTION_NAME, LOG_LEVEL)\
5165 template <typename T, typename... Args>\
5166 inline void Logger::FUNCTION_NAME(const char*, const T&, const Args&...) {\
5169 template <typename T>\
5170 inline void Logger::FUNCTION_NAME(const T&) {\
5178 # endif // ELPP_INFO_LOG
5183 # endif // ELPP_DEBUG_LOG
5184 # if ELPP_WARNING_LOG
5188 # endif // ELPP_WARNING_LOG
5193 # endif // ELPP_ERROR_LOG
5198 # endif // ELPP_FATAL_LOG
5203 # endif // ELPP_TRACE_LOG
5204 # undef LOGGER_LEVEL_WRITERS
5205 # undef LOGGER_LEVEL_WRITERS_DISABLED
5206 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
5207 #if ELPP_COMPILER_MSVC
5208 # define ELPP_VARIADIC_FUNC_MSVC(variadicFunction, variadicArgs) variadicFunction variadicArgs
5209 # define ELPP_VARIADIC_FUNC_MSVC_RUN(variadicFunction, ...) ELPP_VARIADIC_FUNC_MSVC(variadicFunction, (__VA_ARGS__))
5210 # define el_getVALength(...) ELPP_VARIADIC_FUNC_MSVC_RUN(el_resolveVALength, 0, ## __VA_ARGS__,\
5211 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
5213 # if ELPP_COMPILER_CLANG
5214 # define el_getVALength(...) el_resolveVALength(0, __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
5216 # define el_getVALength(...) el_resolveVALength(0, ## __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
5217 # endif // ELPP_COMPILER_CLANG
5218 #endif // ELPP_COMPILER_MSVC
5219 #define el_resolveVALength(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
5220 #define ELPP_WRITE_LOG(writer, level, dispatchAction, ...) \
5221 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
5222 #define ELPP_WRITE_LOG_IF(writer, condition, level, dispatchAction, ...) if (condition) \
5223 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
5224 #define ELPP_WRITE_LOG_EVERY_N(writer, occasion, level, dispatchAction, ...) \
5225 if (ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion)) \
5226 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
5227 #define ELPP_WRITE_LOG_AFTER_N(writer, n, level, dispatchAction, ...) \
5228 if (ELPP->validateAfterNCounter(__FILE__, __LINE__, n)) \
5229 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
5230 #define ELPP_WRITE_LOG_N_TIMES(writer, n, level, dispatchAction, ...) \
5231 if (ELPP->validateNTimesCounter(__FILE__, __LINE__, n)) \
5232 writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
5233 #undef ELPP_CURR_FILE_PERFORMANCE_LOGGER
5234 #if defined(ELPP_PERFORMANCE_LOGGER)
5235 # define ELPP_CURR_FILE_PERFORMANCE_LOGGER ELPP_PERFORMANCE_LOGGER
5237 # define ELPP_CURR_FILE_PERFORMANCE_LOGGER el::base::consts::kPerformanceLoggerId
5246 m_dataType(dataType), m_file(
""), m_line(0), m_func(
"") {}
5247 inline const std::string*
blockName(
void)
const;
5248 inline const struct timeval*
startTime(
void)
const;
5249 inline const struct timeval*
endTime(
void)
const;
5255 inline const char*
file(
void)
const {
return m_file; }
5256 inline unsigned long int line(
void)
const {
return m_line; }
5257 inline const char*
func(
void)
const {
return m_func; }
5259 inline const std::string&
loggerId(
void)
const;
5264 bool m_firstCheckpoint;
5265 std::string m_checkpointId;
5267 unsigned long int m_line;
5284 bool scopedLog =
true,
Level level = base::consts::kPerformanceTrackerDefaultLevel) :
5285 m_blockName(blockName), m_timestampUnit(timestampUnit), m_loggerId(loggerId), m_scopedLog(scopedLog),
5286 m_level(level), m_hasChecked(false), m_lastCheckpointId(std::string()), m_enabled(false) {
5287 #if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
5290 el::Logger* loggerPtr =
ELPP->registeredLoggers()->get(loggerId,
false);
5291 m_enabled = loggerPtr !=
nullptr && loggerPtr->m_typedConfigurations->
performanceTracking(m_level);
5295 #endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
5299 m_blockName(t.m_blockName), m_timestampUnit(t.m_timestampUnit), m_loggerId(t.m_loggerId), m_scopedLog(t.m_scopedLog),
5300 m_level(t.m_level), m_hasChecked(t.m_hasChecked), m_lastCheckpointId(t.m_lastCheckpointId), m_enabled(t.m_enabled),
5301 m_startTime(t.m_startTime), m_endTime(t.m_endTime), m_lastCheckpointTime(t.m_lastCheckpointTime) {
5304 #if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
5312 data.m_formattedTimeTaken = formattedTime;
5314 for (
const std::pair<std::string, base::type::PerformanceTrackingCallbackPtr>& h
5315 :
ELPP->m_performanceTrackingCallbacks) {
5316 callback = h.second.get();
5317 if (callback !=
nullptr && callback->
enabled()) {
5325 #endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING)
5328 void checkpoint(
const std::string&
id = std::string(),
const char* file = __FILE__,
unsigned long int line = __LINE__,
const char* func =
"") {
5329 #if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
5336 data.m_checkpointId =
id;
5340 data.m_formattedTimeTaken = formattedTime;
5342 for (
const std::pair<std::string, base::type::PerformanceTrackingCallbackPtr>& h
5343 :
ELPP->m_performanceTrackingCallbacks) {
5344 callback = h.second.get();
5345 if (callback !=
nullptr && callback->
enabled()) {
5352 m_hasChecked =
true;
5353 m_lastCheckpointId =
id;
5355 #endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
5363 std::string m_blockName;
5365 std::string m_loggerId;
5369 std::string m_lastCheckpointId;
5371 struct timeval m_startTime, m_endTime, m_lastCheckpointTime;
5379 return getFormattedTimeTaken(m_startTime);
5390 startTime, m_timestampUnit), m_timestampUnit);
5394 os << getFormattedTimeTaken();
5429 return const_cast<const std::string*
>(&m_performanceTracker->m_blockName);
5432 return const_cast<const struct timeval*
>(&m_performanceTracker->m_startTime);
5435 return const_cast<const struct timeval*
>(&m_performanceTracker->m_endTime);
5438 return const_cast<const struct timeval*
>(&m_performanceTracker->m_lastCheckpointTime);
5454 m_hex = std::string(hex);
5455 m_addr = std::string(addr);
5488 std::vector<StackTraceEntry>::const_iterator it = st.m_stack.begin();
5489 while (it != st.m_stack.end()) {
5490 os <<
" " << *it++ <<
"\n";
5496 std::vector<StackTraceEntry> m_stack;
5498 void generateNew(
void) {
5502 std::size_t size = backtrace(stack,
kMaxStack);
5503 char** strings = backtrace_symbols(stack, size);
5505 for (std::size_t i =
kStackStart; i < size; ++i) {
5506 char* mangName =
nullptr;
5507 char* hex =
nullptr;
5508 char* addr =
nullptr;
5509 for (
char* c = strings[i]; *c; ++c) {
5523 if (mangName !=
nullptr && hex !=
nullptr && addr !=
nullptr && mangName < hex) {
5528 char* demangName = abi::__cxa_demangle(mangName, 0, 0, &status);
5532 StackTraceEntry entry(i - 1, strings[i], demangName, hex, addr);
5533 m_stack.push_back(entry);
5536 StackTraceEntry entry(i - 1, strings[i], mangName, hex, addr);
5537 m_stack.push_back(entry);
5541 StackTraceEntry entry(i - 1, strings[i]);
5542 m_stack.push_back(entry);
5549 #endif // ELPP_STACKTRACE
5552 static std::string crashReason(
int sig) {
5553 std::stringstream ss;
5554 bool foundReason =
false;
5555 for (
int i = 0; i < base::consts::kCrashSignalsCount; ++i) {
5567 ss <<
"Application has crashed due to unknown signal [" << sig <<
"]";
5572 static void logCrashReason(
int sig,
bool stackTraceIfAvailable, Level level,
const char* logger) {
5573 std::stringstream ss;
5574 ss <<
"CRASH HANDLED; ";
5575 ss << crashReason(sig);
5577 if (stackTraceIfAvailable) {
5578 ss << std::endl <<
" ======= Backtrace: =========" << std::endl << base::debug::StackTrace();
5582 #endif // ELPP_STACKTRACE
5585 static inline void crashAbort(
int sig) {
5586 base::utils::abort(sig);
5591 static inline void defaultCrashHandler(
int sig) {
5592 base::debug::logCrashReason(sig,
true,
Level::Fatal, base::consts::kDefaultLoggerId);
5593 base::debug::crashAbort(sig);
5609 m_handler = cHandler;
5610 #if defined(ELPP_HANDLE_SIGABRT)
5614 #endif // defined(ELPP_HANDLE_SIGABRT)
5615 for (; i < base::consts::kCrashSignalsCount; ++i) {
5626 #define MAKE_LOGGABLE(ClassType, ClassInstance, OutputStreamInstance) \
5627 el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamInstance, const ClassType& ClassInstance)
5628 class SysLogInitializer {
5632 #if defined(ELPP_SYSLOG)
5633 openlog(processIdent,
options, facility);
5638 #endif // defined(ELPP_SYSLOG)
5641 #if defined(ELPP_SYSLOG)
5643 #endif // defined(ELPP_SYSLOG)
5646 #define ELPP_INITIALIZE_SYSLOG(id, opt, fac) el::SysLogInitializer elSyslogInit(id, opt, fac)
5647 class Helpers : base::StaticClass {
5659 static inline void setArgs(
int argc,
char** argv) {
5660 ELPP->setApplicationArguments(argc, argv);
5663 static inline void setArgs(
int argc,
const char** argv) {
5664 ELPP->setApplicationArguments(argc, const_cast<char**>(argv));
5674 static inline void crashAbort(
int sig,
const char* sourceFile =
"",
unsigned int long line = 0) {
5675 std::stringstream ss;
5676 ss << base::debug::crashReason(sig).c_str();
5677 ss <<
" - [Called el::Helpers::crashAbort(" << sig <<
")]";
5678 if (sourceFile !=
nullptr && strlen(sourceFile) > 0) {
5679 ss <<
" - Source: " << sourceFile;
5683 ss <<
" (line number not specified)";
5685 base::utils::abort(sig, ss.str());
5693 Level level =
Level::Fatal,
const char* logger = base::consts::kDefaultLoggerId) {
5694 el::base::debug::logCrashReason(sig, stackTraceIfAvailable, level, logger);
5699 ELPP->setPreRollOutCallback(callback);
5703 ELPP->unsetPreRollOutCallback();
5706 template <
typename T>
5708 return ELPP->installLogDispatchCallback<T>(
id);
5711 template <
typename T>
5713 ELPP->uninstallLogDispatchCallback<T>(
id);
5715 template <
typename T>
5717 return ELPP->logDispatchCallback<T>(
id);
5720 template <
typename T>
5722 return ELPP->installPerformanceTrackingCallback<T>(
id);
5725 template <
typename T>
5727 ELPP->uninstallPerformanceTrackingCallback<T>(
id);
5729 template <
typename T>
5731 return ELPP->performanceTrackingCallback<T>(
id);
5734 template <
typename T>
5737 ELPP->registeredLoggers()->get(el::base::consts::kDefaultLoggerId);
5738 if (logger ==
nullptr) {
5739 return std::string();
5745 #if defined(ELPP_UNICODE)
5746 std::string s = std::string(logger->stream().str().begin(), logger->stream().str().end());
5748 std::string s = logger->stream().str();
5749 #endif // defined(ELPP_UNICODE)
5756 return ELPP->commandLineArgs();
5760 ELPP->installCustomFormatSpecifier(customFormatSpecifier);
5764 return ELPP->uninstallCustomFormatSpecifier(formatSpecifier);
5768 return ELPP->hasCustomFormatSpecifier(formatSpecifier);
5771 if (logger ==
nullptr)
return;
5772 logger->m_typedConfigurations->validateFileRolling(level,
ELPP->preRollOutCallback());
5779 static inline Logger*
getLogger(
const std::string& identity,
bool registerIfNotAvailable =
true) {
5781 return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable);
5787 return ELPP->registeredLoggers()->remove(identity);
5792 return ELPP->registeredLoggers()->has(identity);
5796 if (!logger)
return nullptr;
5806 const std::string& value) {
5808 if (logger ==
nullptr) {
5818 it !=
ELPP->registeredLoggers()->end(); ++it) {
5828 const std::string& value) {
5830 it !=
ELPP->registeredLoggers()->end(); ++it) {
5831 Logger* logger = it->second;
5838 ELPP->registeredLoggers()->setDefaultConfigurations(configurations);
5839 if (reconfigureExistingLoggers) {
5845 return ELPP->registeredLoggers()->defaultConfigurations();
5849 return ELPP->registeredLoggers()->logStreamsReference();
5854 ELPP->registeredLoggers()->defaultConfigurations(),
5855 ELPP->registeredLoggers()->logStreamsReference());
5860 targetList->clear();
5862 it !=
ELPP->registeredLoggers()->list().end(); ++it) {
5863 targetList->push_back(it->first);
5869 std::ifstream gcfStream(globalConfigurationFilePath, std::ifstream::in);
5870 ELPP_ASSERT(gcfStream.is_open(),
"Unable to open global configuration file [" << globalConfigurationFilePath
5871 <<
"] for parsing.");
5872 std::string line = std::string();
5873 std::stringstream ss;
5874 Logger* logger =
nullptr;
5876 ELPP_INTERNAL_INFO(8,
"Configuring logger: '" << logger->
id() <<
"' with configurations \n" << ss.str()
5877 <<
"\n--------------");
5882 while (gcfStream.good()) {
5883 std::getline(gcfStream, line);
5886 if (Configurations::Parser::isComment(line))
continue;
5887 Configurations::Parser::ignoreComments(&line);
5890 if (!ss.str().empty() && logger !=
nullptr) {
5893 ss.str(std::string(
""));
5894 line = line.substr(2);
5896 if (line.size() > 1) {
5904 if (!ss.str().empty() && logger !=
nullptr) {
5913 #if defined(ELPP_DISABLE_CONFIGURATION_FROM_PROGRAM_ARGS)
5920 #endif // defined(ELPP_DISABLE_CONFIGURATION_FROM_PROGRAM_ARGS)
5925 ELPP->registeredLoggers()->flushAll();
5929 ELPP->addFlag(flag);
5933 ELPP->removeFlag(flag);
5937 return ELPP->hasFlag(flag);
5957 ELPP->setLoggingLevel(level);
5961 ELPP->vRegistry()->setLevel(level);
5965 return ELPP->vRegistry()->level();
5969 if (
ELPP->vRegistry()->vModulesEnabled()) {
5970 ELPP->vRegistry()->setModules(modules);
5975 ELPP->vRegistry()->clearModules();
5981 static inline const std::string
version(
void) {
return std::string(
"9.80"); }
5983 static inline const std::string
releaseDate(
void) {
return std::string(
"08-01-2015 0850hrs"); }
5987 #define VLOG_IS_ON(verboseLevel) (ELPP->vRegistry()->allowed(verboseLevel, __FILE__))
5992 #undef ELPP_MIN_UNIT
5993 #if defined(ELPP_PERFORMANCE_MICROSECONDS)
5994 # define ELPP_MIN_UNIT el::base::TimestampUnit::Microsecond
5996 # define ELPP_MIN_UNIT el::base::TimestampUnit::Millisecond
5997 #endif // (defined(ELPP_PERFORMANCE_MICROSECONDS))
6005 #define TIMED_SCOPE(obj, blockname) el::base::PerformanceTracker obj(blockname, ELPP_MIN_UNIT)
6006 #define TIMED_BLOCK(obj, blockName) for (struct { int i; el::base::PerformanceTracker timer; } obj = { 0, \
6007 el::base::PerformanceTracker(blockName, ELPP_MIN_UNIT) }; obj.i < 1; ++obj.i)
6008 #define TIMED_FUNC(obj) TIMED_SCOPE(obj, ELPP_FUNC)
6015 #undef PERFORMANCE_CHECKPOINT
6016 #undef PERFORMANCE_CHECKPOINT_WITH_ID
6017 #define PERFORMANCE_CHECKPOINT(obj) obj.checkpoint(std::string(), __FILE__, __LINE__, ELPP_FUNC)
6018 #define PERFORMANCE_CHECKPOINT_WITH_ID(obj, id) obj.checkpoint(id, __FILE__, __LINE__, ELPP_FUNC)
6020 #undef ELPP_COUNTER_POS
6021 #define ELPP_COUNTER (ELPP->hitCounters()->getCounter(__FILE__, __LINE__))
6023 #define ELPP_COUNTER_POS (ELPP_COUNTER == nullptr ? -1 : ELPP_COUNTER->hitCounts())
6048 #undef CINFO_EVERY_N
6049 #undef CWARNING_EVERY_N
6050 #undef CDEBUG_EVERY_N
6051 #undef CERROR_EVERY_N
6052 #undef CFATAL_EVERY_N
6053 #undef CTRACE_EVERY_N
6054 #undef CVERBOSE_EVERY_N
6055 #undef CINFO_AFTER_N
6056 #undef CWARNING_AFTER_N
6057 #undef CDEBUG_AFTER_N
6058 #undef CERROR_AFTER_N
6059 #undef CFATAL_AFTER_N
6060 #undef CTRACE_AFTER_N
6061 #undef CVERBOSE_AFTER_N
6062 #undef CINFO_N_TIMES
6063 #undef CWARNING_N_TIMES
6064 #undef CDEBUG_N_TIMES
6065 #undef CERROR_N_TIMES
6066 #undef CFATAL_N_TIMES
6067 #undef CTRACE_N_TIMES
6068 #undef CVERBOSE_N_TIMES
6071 # define CINFO(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Info, dispatchAction, __VA_ARGS__)
6073 # define CINFO(writer, dispatchAction, ...) el::base::NullWriter()
6074 #endif // ELPP_INFO_LOG
6075 #if ELPP_WARNING_LOG
6076 # define CWARNING(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Warning, dispatchAction, __VA_ARGS__)
6078 # define CWARNING(writer, dispatchAction, ...) el::base::NullWriter()
6079 #endif // ELPP_WARNING_LOG
6081 # define CDEBUG(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Debug, dispatchAction, __VA_ARGS__)
6083 # define CDEBUG(writer, dispatchAction, ...) el::base::NullWriter()
6084 #endif // ELPP_DEBUG_LOG
6086 # define CERROR(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Error, dispatchAction, __VA_ARGS__)
6088 # define CERROR(writer, dispatchAction, ...) el::base::NullWriter()
6089 #endif // ELPP_ERROR_LOG
6091 # define CFATAL(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Fatal, dispatchAction, __VA_ARGS__)
6093 # define CFATAL(writer, dispatchAction, ...) el::base::NullWriter()
6094 #endif // ELPP_FATAL_LOG
6096 # define CTRACE(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Trace, dispatchAction, __VA_ARGS__)
6098 # define CTRACE(writer, dispatchAction, ...) el::base::NullWriter()
6099 #endif // ELPP_TRACE_LOG
6100 #if ELPP_VERBOSE_LOG
6101 # define CVERBOSE(writer, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel)) writer(\
6102 el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
6104 # define CVERBOSE(writer, vlevel, dispatchAction, ...) el::base::NullWriter()
6105 #endif // ELPP_VERBOSE_LOG
6108 # define CINFO_IF(writer, condition_, dispatchAction, ...) \
6109 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Info, dispatchAction, __VA_ARGS__)
6111 # define CINFO_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
6112 #endif // ELPP_INFO_LOG
6113 #if ELPP_WARNING_LOG
6114 # define CWARNING_IF(writer, condition_, dispatchAction, ...)\
6115 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Warning, dispatchAction, __VA_ARGS__)
6117 # define CWARNING_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
6118 #endif // ELPP_WARNING_LOG
6120 # define CDEBUG_IF(writer, condition_, dispatchAction, ...)\
6121 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Debug, dispatchAction, __VA_ARGS__)
6123 # define CDEBUG_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
6124 #endif // ELPP_DEBUG_LOG
6126 # define CERROR_IF(writer, condition_, dispatchAction, ...)\
6127 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Error, dispatchAction, __VA_ARGS__)
6129 # define CERROR_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
6130 #endif // ELPP_ERROR_LOG
6132 # define CFATAL_IF(writer, condition_, dispatchAction, ...)\
6133 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Fatal, dispatchAction, __VA_ARGS__)
6135 # define CFATAL_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
6136 #endif // ELPP_FATAL_LOG
6138 # define CTRACE_IF(writer, condition_, dispatchAction, ...)\
6139 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Trace, dispatchAction, __VA_ARGS__)
6141 # define CTRACE_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
6142 #endif // ELPP_TRACE_LOG
6143 #if ELPP_VERBOSE_LOG
6144 # define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel) && (condition_)) writer( \
6145 el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
6147 # define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) el::base::NullWriter()
6148 #endif // ELPP_VERBOSE_LOG
6151 # define CINFO_EVERY_N(writer, occasion, dispatchAction, ...)\
6152 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Info, dispatchAction, __VA_ARGS__)
6154 # define CINFO_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
6155 #endif // ELPP_INFO_LOG
6156 #if ELPP_WARNING_LOG
6157 # define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...)\
6158 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Warning, dispatchAction, __VA_ARGS__)
6160 # define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
6161 #endif // ELPP_WARNING_LOG
6163 # define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...)\
6164 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Debug, dispatchAction, __VA_ARGS__)
6166 # define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
6167 #endif // ELPP_DEBUG_LOG
6169 # define CERROR_EVERY_N(writer, occasion, dispatchAction, ...)\
6170 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Error, dispatchAction, __VA_ARGS__)
6172 # define CERROR_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
6173 #endif // ELPP_ERROR_LOG
6175 # define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...)\
6176 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Fatal, dispatchAction, __VA_ARGS__)
6178 # define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
6179 #endif // ELPP_FATAL_LOG
6181 # define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...)\
6182 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Trace, dispatchAction, __VA_ARGS__)
6184 # define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
6185 #endif // ELPP_TRACE_LOG
6186 #if ELPP_VERBOSE_LOG
6187 # define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...)\
6188 CVERBOSE_IF(writer, ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion), vlevel, dispatchAction, __VA_ARGS__)
6190 # define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...) el::base::NullWriter()
6191 #endif // ELPP_VERBOSE_LOG
6194 # define CINFO_AFTER_N(writer, n, dispatchAction, ...)\
6195 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__)
6197 # define CINFO_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
6198 #endif // ELPP_INFO_LOG
6199 #if ELPP_WARNING_LOG
6200 # define CWARNING_AFTER_N(writer, n, dispatchAction, ...)\
6201 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__)
6203 # define CWARNING_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
6204 #endif // ELPP_WARNING_LOG
6206 # define CDEBUG_AFTER_N(writer, n, dispatchAction, ...)\
6207 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__)
6209 # define CDEBUG_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
6210 #endif // ELPP_DEBUG_LOG
6212 # define CERROR_AFTER_N(writer, n, dispatchAction, ...)\
6213 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__)
6215 # define CERROR_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
6216 #endif // ELPP_ERROR_LOG
6218 # define CFATAL_AFTER_N(writer, n, dispatchAction, ...)\
6219 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__)
6221 # define CFATAL_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
6222 #endif // ELPP_FATAL_LOG
6224 # define CTRACE_AFTER_N(writer, n, dispatchAction, ...)\
6225 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__)
6227 # define CTRACE_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
6228 #endif // ELPP_TRACE_LOG
6229 #if ELPP_VERBOSE_LOG
6230 # define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...)\
6231 CVERBOSE_IF(writer, ELPP->validateAfterNCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__)
6233 # define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter()
6234 #endif // ELPP_VERBOSE_LOG
6237 # define CINFO_N_TIMES(writer, n, dispatchAction, ...)\
6238 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__)
6240 # define CINFO_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
6241 #endif // ELPP_INFO_LOG
6242 #if ELPP_WARNING_LOG
6243 # define CWARNING_N_TIMES(writer, n, dispatchAction, ...)\
6244 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__)
6246 # define CWARNING_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
6247 #endif // ELPP_WARNING_LOG
6249 # define CDEBUG_N_TIMES(writer, n, dispatchAction, ...)\
6250 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__)
6252 # define CDEBUG_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
6253 #endif // ELPP_DEBUG_LOG
6255 # define CERROR_N_TIMES(writer, n, dispatchAction, ...)\
6256 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__)
6258 # define CERROR_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
6259 #endif // ELPP_ERROR_LOG
6261 # define CFATAL_N_TIMES(writer, n, dispatchAction, ...)\
6262 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__)
6264 # define CFATAL_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
6265 #endif // ELPP_FATAL_LOG
6267 # define CTRACE_N_TIMES(writer, n, dispatchAction, ...)\
6268 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__)
6270 # define CTRACE_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
6271 #endif // ELPP_TRACE_LOG
6272 #if ELPP_VERBOSE_LOG
6273 # define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...)\
6274 CVERBOSE_IF(writer, ELPP->validateNTimesCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__)
6276 # define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter()
6277 #endif // ELPP_VERBOSE_LOG
6286 #undef CLOG_VERBOSE_IF
6289 #undef CVLOG_EVERY_N
6291 #undef CVLOG_AFTER_N
6293 #undef CVLOG_N_TIMES
6295 #define CLOG(LEVEL, ...)\
6296 C##LEVEL(el::base::Writer, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6297 #define CVLOG(vlevel, ...) CVERBOSE(el::base::Writer, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6299 #define CLOG_IF(condition, LEVEL, ...)\
6300 C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6301 #define CVLOG_IF(condition, vlevel, ...)\
6302 CVERBOSE_IF(el::base::Writer, condition, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6304 #define CLOG_EVERY_N(n, LEVEL, ...)\
6305 C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6306 #define CVLOG_EVERY_N(n, vlevel, ...)\
6307 CVERBOSE_EVERY_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6308 #define CLOG_AFTER_N(n, LEVEL, ...)\
6309 C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6310 #define CVLOG_AFTER_N(n, vlevel, ...)\
6311 CVERBOSE_AFTER_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6312 #define CLOG_N_TIMES(n, LEVEL, ...)\
6313 C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6314 #define CVLOG_N_TIMES(n, vlevel, ...)\
6315 CVERBOSE_N_TIMES(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6330 #undef ELPP_CURR_FILE_LOGGER_ID
6331 #if defined(ELPP_DEFAULT_LOGGER)
6332 # define ELPP_CURR_FILE_LOGGER_ID ELPP_DEFAULT_LOGGER
6334 # define ELPP_CURR_FILE_LOGGER_ID el::base::consts::kDefaultLoggerId
6337 #define ELPP_TRACE CLOG(TRACE, ELPP_CURR_FILE_LOGGER_ID)
6339 #define LOG(LEVEL) CLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6340 #define VLOG(vlevel) CVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID)
6342 #define LOG_IF(condition, LEVEL) CLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6343 #define VLOG_IF(condition, vlevel) CVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6345 #define LOG_EVERY_N(n, LEVEL) CLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6346 #define VLOG_EVERY_N(n, vlevel) CVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6347 #define LOG_AFTER_N(n, LEVEL) CLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6348 #define VLOG_AFTER_N(n, vlevel) CVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6349 #define LOG_N_TIMES(n, LEVEL) CLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6350 #define VLOG_N_TIMES(n, vlevel) CVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6360 #define CPLOG(LEVEL, ...)\
6361 C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6362 #define CPLOG_IF(condition, LEVEL, ...)\
6363 C##LEVEL##_IF(el::base::PErrorWriter, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6364 #define DCPLOG(LEVEL, ...)\
6365 if (ELPP_DEBUG_LOG) C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__)
6366 #define DCPLOG_IF(condition, LEVEL, ...)\
6367 C##LEVEL##_IF(el::base::PErrorWriter, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::NormalLog, __VA_ARGS__)
6368 #define PLOG(LEVEL) CPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6369 #define PLOG_IF(condition, LEVEL) CPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6370 #define DPLOG(LEVEL) DCPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6371 #define DPLOG_IF(condition, LEVEL) DCPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6375 #undef CSYSLOG_EVERY_N
6376 #undef CSYSLOG_AFTER_N
6377 #undef CSYSLOG_N_TIMES
6380 #undef SYSLOG_EVERY_N
6381 #undef SYSLOG_AFTER_N
6382 #undef SYSLOG_N_TIMES
6385 #undef DCSYSLOG_EVERY_N
6386 #undef DCSYSLOG_AFTER_N
6387 #undef DCSYSLOG_N_TIMES
6390 #undef DSYSLOG_EVERY_N
6391 #undef DSYSLOG_AFTER_N
6392 #undef DSYSLOG_N_TIMES
6393 #if defined(ELPP_SYSLOG)
6394 # define CSYSLOG(LEVEL, ...)\
6395 C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__)
6396 # define CSYSLOG_IF(condition, LEVEL, ...)\
6397 C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::SysLog, __VA_ARGS__)
6398 # define CSYSLOG_EVERY_N(n, LEVEL, ...) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
6399 # define CSYSLOG_AFTER_N(n, LEVEL, ...) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
6400 # define CSYSLOG_N_TIMES(n, LEVEL, ...) C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
6401 # define SYSLOG(LEVEL) CSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId)
6402 # define SYSLOG_IF(condition, LEVEL) CSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId)
6403 # define SYSLOG_EVERY_N(n, LEVEL) CSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
6404 # define SYSLOG_AFTER_N(n, LEVEL) CSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
6405 # define SYSLOG_N_TIMES(n, LEVEL) CSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId)
6406 # define DCSYSLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__)
6407 # define DCSYSLOG_IF(condition, LEVEL, ...)\
6408 C##LEVEL##_IF(el::base::Writer, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::SysLog, __VA_ARGS__)
6409 # define DCSYSLOG_EVERY_N(n, LEVEL, ...)\
6410 if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
6411 # define DCSYSLOG_AFTER_N(n, LEVEL, ...)\
6412 if (ELPP_DEBUG_LOG) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
6413 # define DCSYSLOG_N_TIMES(n, LEVEL, ...)\
6414 if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
6415 # define DSYSLOG(LEVEL) DCSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId)
6416 # define DSYSLOG_IF(condition, LEVEL) DCSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId)
6417 # define DSYSLOG_EVERY_N(n, LEVEL) DCSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
6418 # define DSYSLOG_AFTER_N(n, LEVEL) DCSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
6419 # define DSYSLOG_N_TIMES(n, LEVEL) DCSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId)
6421 # define CSYSLOG(LEVEL, ...) el::base::NullWriter()
6422 # define CSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter()
6423 # define CSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter()
6424 # define CSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter()
6425 # define CSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter()
6426 # define SYSLOG(LEVEL) el::base::NullWriter()
6427 # define SYSLOG_IF(condition, LEVEL) el::base::NullWriter()
6428 # define SYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter()
6429 # define SYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter()
6430 # define SYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter()
6431 # define DCSYSLOG(LEVEL, ...) el::base::NullWriter()
6432 # define DCSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter()
6433 # define DCSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter()
6434 # define DCSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter()
6435 # define DCSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter()
6436 # define DSYSLOG(LEVEL) el::base::NullWriter()
6437 # define DSYSLOG_IF(condition, LEVEL) el::base::NullWriter()
6438 # define DSYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter()
6439 # define DSYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter()
6440 # define DSYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter()
6441 #endif // defined(ELPP_SYSLOG)
6450 #undef DCLOG_EVERY_N
6451 #undef DCVLOG_EVERY_N
6452 #undef DCLOG_AFTER_N
6453 #undef DCVLOG_AFTER_N
6454 #undef DCLOG_N_TIMES
6455 #undef DCVLOG_N_TIMES
6457 #define DCLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG(LEVEL, __VA_ARGS__)
6458 #define DCLOG_VERBOSE(vlevel, ...) if (ELPP_DEBUG_LOG) CLOG_VERBOSE(vlevel, __VA_ARGS__)
6459 #define DCVLOG(vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG(vlevel, __VA_ARGS__)
6461 #define DCLOG_IF(condition, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_IF(condition, LEVEL, __VA_ARGS__)
6462 #define DCVLOG_IF(condition, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_IF(condition, vlevel, __VA_ARGS__)
6464 #define DCLOG_EVERY_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_EVERY_N(n, LEVEL, __VA_ARGS__)
6465 #define DCVLOG_EVERY_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_EVERY_N(n, vlevel, __VA_ARGS__)
6466 #define DCLOG_AFTER_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_AFTER_N(n, LEVEL, __VA_ARGS__)
6467 #define DCVLOG_AFTER_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_AFTER_N(n, vlevel, __VA_ARGS__)
6468 #define DCLOG_N_TIMES(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_N_TIMES(n, LEVEL, __VA_ARGS__)
6469 #define DCVLOG_N_TIMES(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_N_TIMES(n, vlevel, __VA_ARGS__)
6479 #undef DVLOG_EVERY_N
6481 #undef DVLOG_AFTER_N
6483 #undef DVLOG_N_TIMES
6485 #define DLOG(LEVEL) DCLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6486 #define DVLOG(vlevel) DCVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID)
6488 #define DLOG_IF(condition, LEVEL) DCLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6489 #define DVLOG_IF(condition, vlevel) DCVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6491 #define DLOG_EVERY_N(n, LEVEL) DCLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6492 #define DVLOG_EVERY_N(n, vlevel) DCVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6493 #define DLOG_AFTER_N(n, LEVEL) DCLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6494 #define DVLOG_AFTER_N(n, vlevel) DCVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6495 #define DLOG_N_TIMES(n, LEVEL) DCLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
6496 #define DVLOG_N_TIMES(n, vlevel) DCVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
6506 #undef CCHECK_BOUNDS
6507 #undef CCHECK_NOTNULL
6508 #undef CCHECK_STRCASEEQ
6509 #undef CCHECK_STRCASENE
6519 #undef CHECK_NOTNULL
6520 #undef CHECK_STRCASEEQ
6521 #undef CHECK_STRCASENE
6522 #define CCHECK(condition, ...) CLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] "
6523 #define CPCHECK(condition, ...) CPLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] "
6524 #define CHECK(condition) CCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
6525 #define PCHECK(condition) CPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
6526 #define CCHECK_EQ(a, b, ...) CCHECK(a == b, __VA_ARGS__)
6527 #define CCHECK_NE(a, b, ...) CCHECK(a != b, __VA_ARGS__)
6528 #define CCHECK_LT(a, b, ...) CCHECK(a < b, __VA_ARGS__)
6529 #define CCHECK_GT(a, b, ...) CCHECK(a > b, __VA_ARGS__)
6530 #define CCHECK_LE(a, b, ...) CCHECK(a <= b, __VA_ARGS__)
6531 #define CCHECK_GE(a, b, ...) CCHECK(a >= b, __VA_ARGS__)
6532 #define CCHECK_BOUNDS(val, min, max, ...) CCHECK(val >= min && val <= max, __VA_ARGS__)
6533 #define CHECK_EQ(a, b) CCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID)
6534 #define CHECK_NE(a, b) CCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID)
6535 #define CHECK_LT(a, b) CCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID)
6536 #define CHECK_GT(a, b) CCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID)
6537 #define CHECK_LE(a, b) CCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID)
6538 #define CHECK_GE(a, b) CCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID)
6539 #define CHECK_BOUNDS(val, min, max) CCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID)
6543 template <
typename T>
6544 static T* checkNotNull(T* ptr,
const char*
name,
const char* loggers, ...) {
6545 CLOG_IF(ptr ==
nullptr, FATAL, loggers) <<
"Check failed: [" << name <<
" != nullptr]";
6551 #define CCHECK_NOTNULL(ptr, ...) el::base::utils::checkNotNull(ptr, #ptr, __VA_ARGS__)
6552 #define CCHECK_STREQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \
6553 << "Check failed: [" << #str1 << " == " << #str2 << "] "
6554 #define CCHECK_STRNE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \
6555 << "Check failed: [" << #str1 << " != " << #str2 << "] "
6556 #define CCHECK_STRCASEEQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \
6557 << "Check failed: [" << #str1 << " == " << #str2 << "] "
6558 #define CCHECK_STRCASENE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \
6559 << "Check failed: [" << #str1 << " != " << #str2 << "] "
6560 #define CHECK_NOTNULL(ptr) CCHECK_NOTNULL(ptr, ELPP_CURR_FILE_LOGGER_ID)
6561 #define CHECK_STREQ(str1, str2) CCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6562 #define CHECK_STRNE(str1, str2) CCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6563 #define CHECK_STRCASEEQ(str1, str2) CCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6564 #define CHECK_STRCASENE(str1, str2) CCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6572 #undef DCCHECK_BOUNDS
6573 #undef DCCHECK_NOTNULL
6574 #undef DCCHECK_STRCASEEQ
6575 #undef DCCHECK_STRCASENE
6584 #undef DCHECK_BOUNDS_
6585 #undef DCHECK_NOTNULL
6586 #undef DCHECK_STRCASEEQ
6587 #undef DCHECK_STRCASENE
6589 #define DCCHECK(condition, ...) if (ELPP_DEBUG_LOG) CCHECK(condition, __VA_ARGS__)
6590 #define DCCHECK_EQ(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_EQ(a, b, __VA_ARGS__)
6591 #define DCCHECK_NE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_NE(a, b, __VA_ARGS__)
6592 #define DCCHECK_LT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LT(a, b, __VA_ARGS__)
6593 #define DCCHECK_GT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GT(a, b, __VA_ARGS__)
6594 #define DCCHECK_LE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LE(a, b, __VA_ARGS__)
6595 #define DCCHECK_GE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GE(a, b, __VA_ARGS__)
6596 #define DCCHECK_BOUNDS(val, min, max, ...) if (ELPP_DEBUG_LOG) CCHECK_BOUNDS(val, min, max, __VA_ARGS__)
6597 #define DCCHECK_NOTNULL(ptr, ...) if (ELPP_DEBUG_LOG) CCHECK_NOTNULL(ptr, __VA_ARGS__)
6598 #define DCCHECK_STREQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STREQ(str1, str2, __VA_ARGS__)
6599 #define DCCHECK_STRNE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRNE(str1, str2, __VA_ARGS__)
6600 #define DCCHECK_STRCASEEQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASEEQ(str1, str2, __VA_ARGS__)
6601 #define DCCHECK_STRCASENE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASENE(str1, str2, __VA_ARGS__)
6602 #define DCPCHECK(condition, ...) if (ELPP_DEBUG_LOG) CPCHECK(condition, __VA_ARGS__)
6603 #define DCHECK(condition) DCCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
6604 #define DCHECK_EQ(a, b) DCCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID)
6605 #define DCHECK_NE(a, b) DCCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID)
6606 #define DCHECK_LT(a, b) DCCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID)
6607 #define DCHECK_GT(a, b) DCCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID)
6608 #define DCHECK_LE(a, b) DCCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID)
6609 #define DCHECK_GE(a, b) DCCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID)
6610 #define DCHECK_BOUNDS(val, min, max) DCCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID)
6611 #define DCHECK_NOTNULL(ptr) DCCHECK_NOTNULL(ptr, ELPP_CURR_FILE_LOGGER_ID)
6612 #define DCHECK_STREQ(str1, str2) DCCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6613 #define DCHECK_STRNE(str1, str2) DCCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6614 #define DCHECK_STRCASEEQ(str1, str2) DCCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6615 #define DCHECK_STRCASENE(str1, str2) DCCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
6616 #define DPCHECK(condition) DCPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
6617 #if defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING)
6618 # define ELPP_USE_DEF_CRASH_HANDLER false
6620 # define ELPP_USE_DEF_CRASH_HANDLER true
6621 #endif // defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING)
6622 #define ELPP_CRASH_HANDLER_INIT
6623 #define ELPP_INIT_EASYLOGGINGPP(val)\
6624 ELPP_INITI_BASIC_DECLR\
6627 el::base::type::StoragePointer elStorage(val);\
6629 el::base::debug::CrashHandler elCrashHandler(false);\
6632 #if ELPP_ASYNC_LOGGING
6633 # define INITIALIZE_EASYLOGGINGPP\
6634 ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()),\
6635 new el::base::AsyncDispatchWorker()))\
6638 # define INITIALIZE_EASYLOGGINGPP\
6639 ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder())))
6640 #endif // ELPP_ASYNC_LOGGING
6641 #define INITIALIZE_NULL_EASYLOGGINGPP\
6642 ELPP_INITI_BASIC_DECLR\
6645 el::base::type::StoragePointer elStorage;\
6647 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\
6650 #define SHARE_EASYLOGGINGPP(initializedStorage)\
6653 el::base::type::StoragePointer elStorage(initializedStorage);\
6655 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\
6658 #if defined(ELPP_UNICODE)
6659 # define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv); std::locale::global(std::locale(""))
6661 # define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv)
6662 #endif // defined(ELPP_UNICODE)
6663 #endif // EASYLOGGINGPP_H
void convertToColoredOutput(base::type::string_t *logLine, Level level)
Definition: easylogging++.h:3359
static bool unregisterLogger(const std::string &identity)
Unregisters logger - use it only when you know what you are doing, you may unregister loggers initial...
Definition: easylogging++.h:5785
struct el::base::consts::@40 kTimeFormats[]
const base::type::string_t & message(void) const
Definition: easylogging++.h:3838
char char_t
Definition: easylogging++.h:460
double value
Definition: easylogging++.h:814
void setArgs(int argc, const char **argv)
Sets arguments and parses them.
Definition: easylogging++.h:1737
void setLogBuilder(const LogBuilderPtr &logBuilder)
Definition: easylogging++.h:3510
const std::string & configurationFile(void) const
Gets configuration file used in parsing this configurations.
Definition: easylogging++.h:2592
Logger * get(const std::string &id, bool forceCreation=true)
Definition: easylogging++.h:3623
struct el::base::consts::@41 kCrashSignals[]
Abstract registry (aka repository) that provides basic interface for pointer repository specified by ...
Definition: easylogging++.h:1814
static ConfigurationType convertFromString(const char *configStr)
Converts from configStr to ConfigurationType.
Definition: easylogging++.h:651
bool toFile(Level level)
Definition: easylogging++.h:2888
void flush(void)
Flushes logger to sync all log files for all levels.
Definition: easylogging++.h:3482
static std::string extractPathFromFilename(const std::string &fullPath, const char *seperator=base::consts::kFilePathSeperator)
Extracts path of filename with leading slash.
Definition: easylogging++.h:1179
void setModules(const char *modules)
Definition: easylogging++.h:3705
optional bool index
Definition: topics.proto:34
A milliseconds width class containing actual width and offset for date/time.
Definition: easylogging++.h:860
const std::string & value(void) const
Gets string based configuration value.
Definition: easylogging++.h:2394
#define ELPP_WRITE_LOG(writer, level, dispatchAction,...)
Definition: easylogging++.h:5220
virtual const_iterator cbegin(void) const ELPP_FINAL
Definition: easylogging++.h:1880
static void uninstallPerformanceTrackingCallback(const std::string &id)
Uninstalls post performance tracking handler.
Definition: easylogging++.h:5726
std::map< std::string, FileStreamPtr > LogStreamsReferenceMap
Definition: easylogging++.h:2853
Parser used internally to parse configurations from file or text.
Definition: easylogging++.h:2652
void unregister(const T_Key &uniqKey)
Unregisters single entry mapped to specified unique key.
Definition: easylogging++.h:1976
Determines whether or not corresponding level and logger of logging is enabled You may disable all lo...
friend std::ostream & operator<<(std::ostream &ss, const StackTraceEntry &si)
Definition: easylogging++.h:5466
Mutex wrapper used when multi-threading is disabled.
Definition: easylogging++.h:1041
static std::string & trim(std::string &str)
Trims string from left and right.
Definition: easylogging++.h:1271
Operating System helper static class used internally. You should not use it.
Definition: easylogging++.h:1418
static Logger * reconfigureLogger(const std::string &identity, ConfigurationType configurationType, const std::string &value)
Reconfigures logger's single configuration.
Definition: easylogging++.h:5805
static void installPreRollOutCallback(const PreRollOutCallback &callback)
Installs pre rollout callback, this callback is triggered when log file is about to be rolled out (ca...
Definition: easylogging++.h:5698
std::fstream fstream_t
Definition: easylogging++.h:463
Callback(void)
Definition: easylogging++.h:3323
Configuration(const Configuration &c)
Definition: easylogging++.h:2360
virtual base::type::string_t build(const LogMessage *logMessage, bool appendNewLine) const =0
SysLogInitializer(const char *processIdent, int options=0, int facility=0)
Definition: easylogging++.h:5631
Determines whether or not performance tracking is enabled.
virtual void releaseLock(void) ELPP_FINAL
Definition: easylogging++.h:1073
Configuration(Level level, ConfigurationType configurationType, const std::string &value)
Full constructor used to sets value of configuration.
Definition: easylogging++.h:2377
Used to find configuration from configuration (pointers) repository. Avoid using it.
Definition: easylogging++.h:2412
const char * m_func
Definition: easylogging++.h:4967
void lock(void)
Definition: easylogging++.h:1044
bool hasParamWithValue(const char *paramKey) const
Returns true if arguments contain paramKey with a value (seperated by '=')
Definition: easylogging++.h:1771
Creates logger automatically when not available.
base::threading::internal::NoScopedLock< base::threading::Mutex > ScopedLock
Definition: easylogging++.h:1067
static void removeFlag(LoggingFlag flag)
Removes logging flag used internally.
Definition: easylogging++.h:5932
bool hasParam(const char *paramKey) const
Return true if arguments has a param (not having a value) i,e without '='.
Definition: easylogging++.h:1780
static void buildStrippedFilename(const char *filename, char buff[], std::size_t limit=base::consts::kSourceFilenameMaxLength)
builds stripped filename and puts it in buff
Definition: easylogging++.h:1191
void flushAll(void)
Definition: easylogging++.h:3663
unsigned long int lineNumber(void) const
Definition: easylogging++.h:3227
void setHandler(const Handler &cHandler)
Definition: easylogging++.h:5608
Container::const_iterator const_iterator
Definition: easylogging++.h:1817
static bool hasFlag(LoggingFlag flag)
Determines whether or not certain flag is active.
Definition: easylogging++.h:5936
void setLoggingLevel(Level level)
Definition: easylogging++.h:4059
Information representing errors in application but application will keep running. ...
tuple app
Definition: mock_server.py:7
virtual ~Logger(void)
Definition: easylogging++.h:3418
static std::string & rtrim(std::string &str)
Trim string from end.
Definition: easylogging++.h:1264
std::string m_demangled
Definition: easylogging++.h:5463
ELPP_EXPORT base::type::StoragePointer elStorage
Definition: easylogging++.h:4166
LogMessage(Level level, const std::string &file, unsigned long int line, const std::string &func, base::type::VerboseLevel verboseLevel, Logger *logger)
Definition: easylogging++.h:3827
NoCopy(void)
Definition: easylogging++.h:482
T_Ptr * get(const T_Key &uniqKey)
Gets pointer from repository. If none found, nullptr is returned.
Definition: easylogging++.h:1985
void flush(Level level, base::type::fstream_t *fs)
Definition: easylogging++.h:3492
static base::type::EnumType castToInt(Level level)
Casts level to int, useful for iterating through enum.
Definition: easylogging++.h:530
Writer & construct(int count, const char *loggerIds,...)
Definition: easylogging++.h:4946
static const base::type::EnumType kMaxValid
Represents maximum valid level. This is used internally and you should not need it.
Definition: easylogging++.h:528
unsigned short EnumType
Definition: easylogging++.h:471
std::ostream ostream_t
Definition: easylogging++.h:464
static const std::string releaseDate(void)
Release date of current version.
Definition: easylogging++.h:5983
std::size_t hitCounts(void) const
Definition: easylogging++.h:3231
bool allowed(base::type::VerboseLevel vlevel, const char *file)
Definition: easylogging++.h:3777
virtual const_iterator cend(void) const ELPP_FINAL
Definition: easylogging++.h:1885
const unsigned long int m_line
Definition: easylogging++.h:4966
MessageBuilder & operator<<(std::ostream &(*OStreamMani)(std::ostream &))
Definition: easylogging++.h:4619
bool validateAfterNCounter(const char *filename, unsigned long int lineNumber, std::size_t n)
Definition: easylogging++.h:3968
virtual ~Configurations(void)
Definition: easylogging++.h:2460
std::vector< std::string > m_loggerIds
Definition: easylogging++.h:4973
LogDispatcher(bool proceed, LogMessage &&logMessage, base::DispatchAction dispatchAction)
Definition: easylogging++.h:4452
Definition: easylogging++.h:3347
bool enabled(Level level) const
Definition: easylogging++.h:3514
friend base::type::ostream_t & operator<<(base::type::ostream_t &os, const RegistryWithPred &sr)
Definition: easylogging++.h:2036
static bool uninstallCustomFormatSpecifier(const char *formatSpecifier)
Uninstalls user defined format specifier and handler.
Definition: easylogging++.h:5763
bool try_lock(void)
Definition: easylogging++.h:1045
Predicate(Level level, ConfigurationType configurationType)
Definition: easylogging++.h:2414
static bool startsWith(const std::string &str, const std::string &start)
Determines whether or not str starts with specified string.
Definition: easylogging++.h:1279
#define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp)
Definition: easylogging++.h:4628
bool validateNTimes(const char *filename, unsigned long int lineNumber, std::size_t n)
Validates counter for hits are <= n, i.e, registers new if does not exist otherwise updates original ...
Definition: easylogging++.h:3296
static const std::size_t kStackStart
Definition: easylogging++.h:5447
Informational events most useful for developers to debug application.
static Level convertFromString(const char *levelStr)
Converts from levelStr to Level.
Definition: easylogging++.h:554
void set(Level level, ConfigurationType configurationType, const std::string &value)
Sets value of configuration for specified level.
Definition: easylogging++.h:2553
base::RegisteredLoggers * registeredLoggers(void) const
Definition: easylogging++.h:3980
static std::string & replaceAll(std::string &str, char replaceWhat, char replaceWith)
Replaces all instances of replaceWhat with 'replaceWith'. Original variable is changed for performanc...
Definition: easylogging++.h:1296
Severe error information that will presumably abort application.
friend base::type::ostream_t & operator<<(base::type::ostream_t &os, const CommandLineArgs &c)
Definition: easylogging++.h:1791
Main entry point of each logging.
Definition: easylogging++.h:4907
static void setDefaultConfigurations(const Configurations &configurations, bool reconfigureExistingLoggers=false)
Sets default configurations. This configuration is used for future (and conditionally for existing) l...
Definition: easylogging++.h:5837
static Level castFromInt(base::type::EnumType l)
Casts int(ushort) to level, useful for iterating through enum.
Definition: easylogging++.h:534
Base of thread safe class, this class is inheritable-only.
Definition: easylogging++.h:1070
bool parseFromFile(const std::string &configurationFile, Configurations *base=nullptr)
Parses configuration from file.
Definition: easylogging++.h:2469
std::shared_ptr< LogBuilder > LogBuilderPtr
Definition: easylogging++.h:3370
static base::type::fstream_t * newFileStream(const std::string &filename)
Creates new out file stream for specified filename.
Definition: easylogging++.h:1087
void setGlobally(ConfigurationType configurationType, const std::string &value)
Sets configuration for all levels.
Definition: easylogging++.h:2579
NullWriter(void)
Definition: easylogging++.h:4894
Handles unexpected crashes.
Definition: easylogging++.h:5596
const std::string & filename(Level level)
Definition: easylogging++.h:2892
Base of Easylogging++ friendly class.
Definition: easylogging++.h:2096
static std::string getEnvironmentVariable(const char *variableName, const char *defaultVal, const char *alternativeBashCommand=nullptr)
Gets environment variable. This is cross-platform and CRT safe (for VC++)
Definition: easylogging++.h:1490
LoggingFlag
Flags used while writing logs. This flags are set by user.
Definition: easylogging++.h:688
Makes sure we have new line for each container log entry.
#define ELPP_STRLEN
Definition: easylogging++.h:454
virtual void log(el::base::type::ostream_t &os) const
Definition: easylogging++.h:2405
Disables comparing performance tracker's checkpoints.
std::string m_hex
Definition: easylogging++.h:5464
static bool termSupportsColor(void)
Whether or not terminal supports colors.
Definition: easylogging++.h:1542
void setFlags(base::type::EnumType flags)
Definition: easylogging++.h:4014
Definition: easylogging++.h:4367
HitCounter(void)
Definition: easylogging++.h:3181
Definition: easylogging++.h:3239
static char * convertAndAddToBuff(std::size_t n, int len, char *buf, const char *bufLim, bool zeroPadded=true)
Definition: easylogging++.h:1374
base::DispatchAction dispatchAction(void) const
Definition: easylogging++.h:3338
Definition: easylogging++.h:3825
virtual ~PErrorWriter(void)
Definition: easylogging++.h:5075
bool hasFlag(LoggingFlag flag) const
Definition: easylogging++.h:4006
NoScopedLock(Mutex &)
Definition: easylogging++.h:1052
virtual ~StackTrace(void)
Definition: easylogging++.h:5480
virtual void registerNew(T_Ptr *ptr) ELPP_FINAL
Definition: easylogging++.h:2068
static const Configurations * defaultConfigurations(void)
Returns current default.
Definition: easylogging++.h:5844
virtual iterator end(void) ELPP_FINAL
Definition: easylogging++.h:1874
static const base::type::EnumType kMinValid
Represents minimum valid level. Useful when iterating through enum.
Definition: easylogging++.h:526
RegistryWithPred(const RegistryWithPred &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
Definition: easylogging++.h:2018
Represents unknown level.
void setArgs(int argc, char **argv)
Sets arguments and parses them.
Definition: easylogging++.h:1741
void resetLocation(const char *filename, unsigned long int lineNumber)
Resets location of current hit counter.
Definition: easylogging++.h:3210
virtual ~Storage(void)
Definition: easylogging++.h:3945
bool toStandardOutput(Level level)
Definition: easylogging++.h:2896
Writer & operator<<(const T &log)
Definition: easylogging++.h:4921
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.
Definition: easylogging++.h:1960
T * performanceTrackingCallback(const std::string &id)
Definition: easylogging++.h:4088
Level
Represents enumeration for severity level used to determine level of logging.
Definition: easylogging++.h:502
AbstractRegistry(AbstractRegistry &&sr)
Move constructor that is useful for base classes.
Definition: easylogging++.h:1823
#define ELPP_INTERNAL_ERROR(msg, pe)
Definition: easylogging++.h:149
RegistryWithPred< T_Ptr, Pred >::iterator iterator
Definition: easylogging++.h:2007
const std::map< std::string, base::type::VerboseLevel > & modules(void) const
Definition: easylogging++.h:3795
void clearModules(void)
Definition: easylogging++.h:3700
static std::string getDateTime(const char *format, const base::MillisecondsWidth *msWidth)
Gets current date and time with milliseconds.
Definition: easylogging++.h:1599
const char * name
Definition: easylogging++.h:827
virtual ~Registry(void)
Definition: easylogging++.h:1955
const char * brief
Definition: easylogging++.h:828
static std::string convertTemplateToStdString(const T &templ)
Converts template to std::string - useful for loggable classes to log containers within log(std::ostr...
Definition: easylogging++.h:5735
static void setCrashHandler(const el::base::debug::CrashHandler::Handler &crashHandler)
Overrides default crash handler and installs custom handler.
Definition: easylogging++.h:5669
T * logDispatchCallback(const std::string &id)
Definition: easylogging++.h:4073
virtual void unregister(T_Ptr *&ptr) ELPP_FINAL
Definition: easylogging++.h:2053
void(* Handler)(int)
Definition: easylogging++.h:5598
bool uninstallCustomFormatSpecifier(const char *formatSpecifier)
Definition: easylogging++.h:4044
virtual ~Configuration(void)
Definition: easylogging++.h:2373
optional string msg
Definition: topics.proto:7
const LogMessage * logMessage(void) const
Definition: easylogging++.h:3337
FormatFlags
Format flags used to determine specifiers that are active for performance improvements.
Definition: easylogging++.h:854
static void setVerboseLevel(base::type::VerboseLevel level)
Sets verbose level on the fly.
Definition: easylogging++.h:5960
bool operator==(const MillisecondsWidth &msWidth)
Definition: easylogging++.h:864
virtual ~Writer(void)
Definition: easylogging++.h:4916
HitCounter(const char *filename, unsigned long int lineNumber)
Definition: easylogging++.h:3187
Writer & construct(Logger *logger, bool needLock=true)
Definition: easylogging++.h:4939
static bool createPath(const std::string &path)
Creates specified path on file system.
Definition: easylogging++.h:1139
Determines log file (full path) to write logs to for correponding level and logger.
virtual ~ThreadSafe(void)
Definition: easylogging++.h:1077
base::RegisteredHitCounters * hitCounters(void) const
Definition: easylogging++.h:3976
Configuration & operator=(const Configuration &c)
Definition: easylogging++.h:2366
void installCustomFormatSpecifier(const CustomFormatSpecifier &customFormatSpecifier)
Definition: easylogging++.h:4036
Writes nothing - Used when certain log is disabled.
Definition: easylogging++.h:4892
int m_width
Definition: easylogging++.h:865
static const base::LogStreamsReferenceMap * logStreamsReference(void)
Returns log stream reference pointer if needed by user.
Definition: easylogging++.h:5848
static bool installPerformanceTrackingCallback(const std::string &id)
Installs post performance tracking callback, this callback is triggered when performance tracking is ...
Definition: easylogging++.h:5721
Container::iterator iterator
Definition: easylogging++.h:1816
static void forEachConfigType(base::type::EnumType *startIndex, const std::function< bool(void)> &fn)
Applies specified function to each configuration type starting from startIndex.
Definition: easylogging++.h:677
static std::size_t getSizeOfFile(base::type::fstream_t *fs)
Gets size of file provided in stream.
Definition: easylogging++.h:1108
Loggers repository.
Definition: easylogging++.h:3603
virtual ~LogBuilder(void)
Definition: easylogging++.h:3357
void setFromArgs(const base::utils::CommandLineArgs *commandLineArgs)
Definition: easylogging++.h:3799
Adds spaces b/w logs that separated by left-shift operator.
virtual ~NoScopedLock(void)
Definition: easylogging++.h:1054
bool hasConfiguration(ConfigurationType configurationType)
Determines whether or not specified configuration type exists in the repository.
Definition: easylogging++.h:2515
Internal helper class that prevent copy constructor for class.
Definition: easylogging++.h:480
String utilities helper class used internally. You should not use it.
Definition: easylogging++.h:1222
CommandLineArgs(int argc, const char **argv)
Definition: easylogging++.h:1729
virtual ~Loggable(void)
Definition: easylogging++.h:2098
Makes sure if -vmodule is used and does not specifies a module, then verbose logging is allowed via t...
void initialize(Logger *logger)
Definition: easylogging++.h:4566
Information that can be highly useful and vary with verbose logging level.
static const std::string getBashOutput(const char *command)
Runs command on terminal and returns the output.
Definition: easylogging++.h:1460
const char * m_file
Definition: easylogging++.h:4965
Determines format of logging corresponding level and logger.
const base::MillisecondsWidth & millisecondsWidth(Level level=Level::Global)
Definition: easylogging++.h:2904
static void setStorage(base::type::StoragePointer storage)
Shares logging repository (base::Storage)
Definition: easylogging++.h:5651
RegisteredLoggers(const LogBuilderPtr &defaultLogBuilder)
Definition: easylogging++.h:3605
Predicate(const char *filename, unsigned long int lineNumber)
Definition: easylogging++.h:3241
Disable VModules extensions.
static void installCustomFormatSpecifier(const CustomFormatSpecifier &customFormatSpecifier)
Installs user defined format specifier and handler.
Definition: easylogging++.h:5759
static Logger * reconfigureLogger(Logger *logger, const Configurations &configurations)
Reconfigures specified logger with new configurations.
Definition: easylogging++.h:5795
#define ELPP
Definition: easylogging++.h:4167
virtual ~AbstractRegistry(void)
Definition: easylogging++.h:1865
static void crashAbort(int sig, const char *sourceFile="", unsigned int long line=0)
Abort due to crash with signal in parameter.
Definition: easylogging++.h:5674
friend el::base::type::ostream_t & operator<<(el::base::type::ostream_t &os, const Loggable &loggable)
Definition: easylogging++.h:2101
static std::vector< std::string > * populateAllLoggerIds(std::vector< std::string > *targetList)
Populates all logger IDs in current repository.
Definition: easylogging++.h:5859
bool validateEveryNCounter(const char *filename, unsigned long int lineNumber, std::size_t occasion)
Definition: easylogging++.h:3964
static void reconfigureAllLoggers(Level level, ConfigurationType configurationType, const std::string &value)
Reconfigures single configuration for all the loggers for specified level.
Definition: easylogging++.h:5827
bool parseFromText(const std::string &configurationsString, Configurations *base=nullptr)
Parse configurations from configuration string.
Definition: easylogging++.h:2491
#define ELPP_ASYNC_LOGGING
Definition: easylogging++.h:220
virtual std::size_t size(void) const ELPP_FINAL
Definition: easylogging++.h:1895
static void gettimeofday(struct timeval *tv)
Cross platform gettimeofday for Windows and unix platform. This can be used to determine current mill...
Definition: easylogging++.h:1568
base::TypedConfigurations * typedConfigurations(void)
Definition: easylogging++.h:3469
void addFlag(LoggingFlag flag)
Definition: easylogging++.h:3998
Writer & operator<<(std::ostream &(*log)(std::ostream &))
Definition: easylogging++.h:4930
A pointer registry mechanism to manage memory and provide search functionalities. (predicate version)...
Definition: easylogging++.h:2005
virtual void deepCopy(const AbstractRegistry< T_Ptr, Container > &)=0
TypedConfigurations(Configurations *configurations, base::LogStreamsReferenceMap *logStreamsReference)
Constructor to initialize (construct) the object off el::Configurations.
Definition: easylogging++.h:2865
base::type::EnumType flags(void) const
Definition: easylogging++.h:4010
#define ELPP_CURR_FILE_PERFORMANCE_LOGGER
Definition: easylogging++.h:5237
bool hasCustomFormatSpecifier(const char *formatSpecifier)
Definition: easylogging++.h:4030
static char * clearBuff(char buff[], std::size_t lim)
Definition: easylogging++.h:1395
static bool hasLogger(const std::string &identity)
Whether or not logger with id is registered.
Definition: easylogging++.h:5790
virtual void log(el::base::type::ostream_t &os) const
Definition: easylogging++.h:3422
static bool cStringCaseEq(const char *s1, const char *s2)
Compares cstring equality (case-insensitive) - uses toupper(char) Dont use strcasecmp because of CRT ...
Definition: easylogging++.h:1353
static void uninstallLogDispatchCallback(const std::string &id)
Uninstalls log dispatch callback.
Definition: easylogging++.h:5712
Registry & operator=(const Registry &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
Definition: easylogging++.h:1947
string id
Definition: requests.proto:15
virtual void handle(const T *handlePtr)=0
Preserves time format and does not convert it to sec, hour etc (performance tracking only) ...
#define ELPP_ASSERT(expr, msg)
Definition: easylogging++.h:120
void clear(void)
Clears repository so that all the configurations are unset.
Definition: easylogging++.h:2584
PErrorWriter(Level level, const char *file, unsigned long int line, const char *func, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog, base::type::VerboseLevel verboseLevel=0)
Definition: easylogging++.h:5069
~ScopedAddFlag(void)
Definition: easylogging++.h:5943
Registry< T_Ptr, T_Key >::const_iterator const_iterator
Definition: easylogging++.h:1932
const base::utils::CommandLineArgs * commandLineArgs(void) const
Definition: easylogging++.h:3994
static base::type::EnumType castToInt(ConfigurationType configurationType)
Casts configuration type to int, useful for iterating through enum.
Definition: easylogging++.h:626
void initializeLogger(const std::string &loggerId, bool lookup=true, bool needLock=true)
Definition: easylogging++.h:4976
static bool cStringEq(const char *s1, const char *s2)
Compares cstring equality - uses strcmp.
Definition: easylogging++.h:1345
Definition: easylogging++.h:5444
bool enabled(void) const
Definition: easylogging++.h:3324
static std::string & toUpper(std::string &str)
Converts string to uppercase.
Definition: easylogging++.h:1339
bool has(const std::string &id)
Definition: easylogging++.h:3650
void setLevel(base::type::VerboseLevel level)
Sets verbose level. Accepted range is 0-9.
Definition: easylogging++.h:3686
Definition: easylogging++.h:3334
HitCounter(const HitCounter &hitCounter)
Definition: easylogging++.h:3193
Static class that contains helper functions for el::ConfigurationType.
Definition: easylogging++.h:619
bool operator!=(const AbstractRegistry< T_Ptr, Container > &other)
Definition: easylogging++.h:1843
Definition: easylogging++.h:5067
const char * filename(void) const
Definition: easylogging++.h:3223
bool isFlushNeeded(Level level)
Definition: easylogging++.h:3502
virtual void unregisterAll(void)=0
Unregisters all the pointers from current repository.
virtual void log(el::base::type::ostream_t &) const =0
static const char * convertToString(ConfigurationType configurationType)
Converts configuration type to associated const char*.
Definition: easylogging++.h:635
static const base::type::EnumType kMinValid
Represents minimum valid configuration type. Useful when iterating through enum.
Definition: easylogging++.h:622
bool installPerformanceTrackingCallback(const std::string &id)
Definition: easylogging++.h:4078
#define ELPP_LITERAL(txt)
Definition: easylogging++.h:453
def build
Definition: wscript:9
std::string s_currentHost
Definition: easylogging++.h:1549
void unsetPreRollOutCallback(void)
Definition: easylogging++.h:4022
bool operator()(const HitCounter *counter)
Definition: easylogging++.h:3245
TypedConfigurations(const TypedConfigurations &other)
Definition: easylogging++.h:2871
static void setArgs(int argc, const char **argv)
Sets application arguments and figures out whats active for logging and whats not.
Definition: easylogging++.h:5663
Storage(const LogBuilderPtr &defaultLogBuilder)
Definition: easylogging++.h:3907
static bool isDigit(char c)
Checks if character is digit. Dont use libc implementation of it to prevent locale issues...
Definition: easylogging++.h:1225
void reconfigure(void)
Reconfigures logger using existing configurations.
Definition: easylogging++.h:3448
Adds flag and removes it when scope goes out.
Definition: easylogging++.h:5940
void unregister(Logger *&logger)
Definition: easylogging++.h:3654
void setEnabled(bool enabled)
Definition: easylogging++.h:3325
A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate vers...
Definition: easylogging++.h:1929
RegistryWithPred & operator=(const RegistryWithPred &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
Definition: easylogging++.h:2028
Definition: easylogging++.h:4563
CrashHandler(const Handler &cHandler)
Definition: easylogging++.h:5605
Configurations(const std::string &configurationFile, bool useDefaultsForRemaining=true, Configurations *base=nullptr)
Constructor used to set configurations using configuration file.
Definition: easylogging++.h:2451
static bool parseFromFile(const std::string &configurationFile, Configurations *sender, Configurations *base=nullptr)
Parses configuration from file.
Definition: easylogging++.h:2661
static std::string currentUser(void)
Gets current username.
Definition: easylogging++.h:1513
#define ELPP_UNUSED(x)
Definition: easylogging++.h:177
tuple Args
Definition: test_command.py:17
Static helpers to deal with loggers and their configurations.
Definition: easylogging++.h:5776
base::VRegistry * vRegistry(void) const
Definition: easylogging++.h:3984
bool installLogDispatchCallback(const std::string &id)
Definition: easylogging++.h:4064
bool validateEveryN(const char *filename, unsigned long int lineNumber, std::size_t n)
Validates counter for every N, i.e, registers new if does not exist otherwise updates original one...
Definition: easylogging++.h:3266
Configurations(void)
Default constructor with empty repository.
Definition: easylogging++.h:2440
ScopedAddFlag(LoggingFlag flag)
Definition: easylogging++.h:5942
base::threading::internal::NoMutex Mutex
Definition: easylogging++.h:1066
std::size_t size(void) const
Returns total number of arguments. This exclude argv[0].
Definition: easylogging++.h:1788
MillisecondsWidth(void)
Definition: easylogging++.h:862
static void flushAll(void)
Flushes all loggers for all levels - Be careful if you dont know how many loggers are registered...
Definition: easylogging++.h:5924
const std::string & parentApplicationName(void) const
Definition: easylogging++.h:3457
friend std::ostream & operator<<(std::ostream &os, const StackTrace &st)
Definition: easylogging++.h:5487
Definition: easylogging++.h:5448
Configurations with data types.
Definition: easylogging++.h:2860
bool performanceTracking(Level level=Level::Global)
Definition: easylogging++.h:2908
static bool isValidId(const std::string &id)
Definition: easylogging++.h:3473
base::type::VerboseLevel verboseLevel(void) const
Definition: easylogging++.h:3836
static void setLoggingLevel(Level level)
Sets hierarchy for logging. Needs to enable logging flag (HierarchicalLogging)
Definition: easylogging++.h:5956
virtual ~TypedConfigurations(void)
Definition: easylogging++.h:2877
static void forEachLevel(base::type::EnumType *startIndex, const std::function< bool(void)> &fn)
Applies specified function to each level starting from startIndex.
Definition: easylogging++.h:577
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.
Definition: easylogging++.h:2044
void setPreRollOutCallback(const PreRollOutCallback &callback)
Definition: easylogging++.h:4018
MessageBuilder & operator<<(const wchar_t *msg)
Definition: easylogging++.h:4601
static void reconfigureAllLoggers(const Configurations &configurations)
Reconfigures all the existing loggers with new configurations.
Definition: easylogging++.h:5816
virtual ~CommandLineArgs(void)
Definition: easylogging++.h:1735
const base::type::char_t * unit
Definition: easylogging++.h:815
void unlock(void)
Definition: easylogging++.h:1046
static const char * convertToString(Level level)
Converts level to associated const char*.
Definition: easylogging++.h:539
def options
Definition: wscript:19
virtual void acquireLock(void) ELPP_FINAL
Definition: easylogging++.h:1072
Specifies milliseconds width. Width can be within range (1-6)
Make terminal output colorful for supported terminals.
HitCounter & operator=(const HitCounter &hitCounter)
Definition: easylogging++.h:3199
Repository for hit counters used across the application.
Definition: easylogging++.h:3262
void removeFlag(LoggingFlag flag)
Definition: easylogging++.h:4002
bool empty(void) const
Returns true if no params available. This exclude argv[0].
Definition: easylogging++.h:1784
#define STRTOK(a, b, c)
Definition: easylogging++.h:202
Logger(const std::string &id, base::LogStreamsReferenceMap *logStreamsReference)
Definition: easylogging++.h:3376
virtual ~SysLogInitializer(void)
Definition: easylogging++.h:5640
ConfigurationType configurationType(void) const
Gets configuration type of current configuration.
Definition: easylogging++.h:2389
tuple logger
Definition: dispatcher.py:13
void validateHitCounts(std::size_t n)
Validates hit counts and resets it if necessary.
Definition: easylogging++.h:3216
Useful when application has potentially harmful situtaions.
Definition: easylogging++.h:1083
static std::string & replaceAll(std::string &str, const std::string &replaceWhat, const std::string &replaceWith)
Replaces all instances of 'replaceWhat' with 'replaceWith'. (String version) Replaces in place...
Definition: easylogging++.h:1306
Writer(Level level, const char *file, unsigned long int line, const char *func, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog, base::type::VerboseLevel verboseLevel=0)
Definition: easylogging++.h:4909
static std::string & ltrim(std::string &str)
Trims string from start.
Definition: easylogging++.h:1257
void handle(const LogDispatchData *data)
Definition: easylogging++.h:4170
int numb
Definition: easylogging++.h:826
std::string string_t
Definition: easylogging++.h:461
When handling crashes by default, detailed crash reason will be logged as well.
DispatchAction
Action to be taken for dispatching.
Definition: easylogging++.h:3316
Enables strict file rolling.
static void clearVModules(void)
Clears vmodules.
Definition: easylogging++.h:5974
static base::TypedConfigurations defaultTypedConfigurations(void)
Default typed configuration based on existing defaultConf.
Definition: easylogging++.h:5852
std::size_t maxLogFileSize(Level level)
Definition: easylogging++.h:2916
static base::type::StoragePointer storage()
Definition: easylogging++.h:5655
static void logCrashReason(int sig, bool stackTraceIfAvailable=false, Level level=Level::Fatal, const char *logger=base::consts::kDefaultLoggerId)
Logs reason of crash as per sig.
Definition: easylogging++.h:5692
static void uninstallPreRollOutCallback(void)
Uninstalls pre rollout callback.
Definition: easylogging++.h:5702
static const base::type::EnumType kMaxValid
Represents maximum valid configuration type. This is used internally and you should not need it...
Definition: easylogging++.h:624
NullWriter & operator<<(const T &)
Definition: easylogging++.h:4902
const char * detail
Definition: easylogging++.h:829
unsigned int m_offset
Definition: easylogging++.h:865
std::vector< StackTraceEntry > & getLatestStack(void)
Definition: easylogging++.h:5483
void setRemainingToDefault(void)
Lets you set the remaining configurations to default.
Definition: easylogging++.h:2627
virtual Container & list(void) ELPP_FINAL
Returns underlying container by reference.
Definition: easylogging++.h:1900
Removes flag and add it when scope goes out.
Definition: easylogging++.h:5948
static T * logDispatchCallback(const std::string &id)
Definition: easylogging++.h:5716
Level level(void) const
Gets level of current configuration.
Definition: easylogging++.h:2384
MessageBuilder & operator<<(const std::string &msg)
Definition: easylogging++.h:4581
Logger(const Logger &logger)
Definition: easylogging++.h:3395
static Logger * reconfigureLogger(const std::string &identity, const Configurations &configurations)
Reconfigures logger with new configurations after looking it up using identity.
Definition: easylogging++.h:5801
LogBuilder * logBuilder(void) const
Definition: easylogging++.h:3506
Flushes log with every log-entry (performance sensative) - Disabled by default.
const Configurations * configurations(void) const
Definition: easylogging++.h:2880
void configure(const Configurations &configurations)
Configures the logger using specified configurations.
Definition: easylogging++.h:3427
static unsigned long long getTimeDifference(const struct timeval &endTime, const struct timeval &startTime, base::TimestampUnit timestampUnit)
Gets time difference in milli/micro second depending on timestampUnit.
Definition: easylogging++.h:1628
Thread-safe Configuration repository.
Definition: easylogging++.h:2437
static void replaceFirstWithEscape(base::type::string_t &str, const base::type::string_t &replaceWhat, const base::type::string_t &replaceWith)
Definition: easylogging++.h:1317
CommandLineArgs(int argc, char **argv)
Definition: easylogging++.h:1732
std::string s_currentUser
Definition: easylogging++.h:1548
#define ELPP_EXPORT
Definition: easylogging++.h:189
Mainly useful to represent current progress of application.
#define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp)
Definition: easylogging++.h:4643
void setValue(const std::string &value)
Set string based configuration value.
Definition: easylogging++.h:2401
bool enabled(Level level)
Definition: easylogging++.h:2884
std::string m_location
Definition: easylogging++.h:5462
void set(Configuration *conf)
Sets single configuration based on other single configuration.
Definition: easylogging++.h:2563
bool validateAfterN(const char *filename, unsigned long int lineNumber, std::size_t n)
Validates counter for hits >= N, i.e, registers new if does not exist otherwise updates original one...
Definition: easylogging++.h:3279
Dispatches log messages.
Definition: easylogging++.h:4450
static char * addToBuff(const char *str, char *buf, const char *bufLim)
Definition: easylogging++.h:1389
static std::string currentHost(void)
Gets current host name or computer name.
Definition: easylogging++.h:1529
static void reconfigureAllLoggers(ConfigurationType configurationType, const std::string &value)
Reconfigures single configuration for all the loggers.
Definition: easylogging++.h:5823
std::shared_ptr< base::Storage > StoragePointer
Definition: easylogging++.h:472
Configurations * configurations(void)
Definition: easylogging++.h:3465
virtual ~RegisteredLoggers(void)
Definition: easylogging++.h:3610
bool operator==(const AbstractRegistry< T_Ptr, Container > &other)
Definition: easylogging++.h:1831
TimestampUnit
Enum to represent timestamp unit.
Definition: easylogging++.h:850
Command line arguments for application if specified using el::Helpers::setArgs(..) or START_EASYLOGGI...
Definition: easylogging++.h:1724
Configurations * defaultConfigurations(void)
Definition: easylogging++.h:3619
PreRollOutCallback & preRollOutCallback(void)
Definition: easylogging++.h:4026
void triggerDispatch(void)
Definition: easylogging++.h:5045
#define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp)
Definition: easylogging++.h:4633
NoMutex(void)
Definition: easylogging++.h:1043
static char * wcharPtrToCharPtr(const wchar_t *line)
Converst wchar* to char* NOTE: Need to free return value after use!
Definition: easylogging++.h:1403
void setDefaultConfigurations(const Configurations &configurations)
Definition: easylogging++.h:3614
base::DispatchAction m_dispatchAction
Definition: easylogging++.h:4972
Definition: easylogging++.h:4168
base::MessageBuilder m_messageBuilder
Definition: easylogging++.h:4971
Specifies number of log entries to hold until we flush pending log data.
bool validateNTimesCounter(const char *filename, unsigned long int lineNumber, std::size_t n)
Definition: easylogging++.h:3972
std::string m_addr
Definition: easylogging++.h:5465
static const std::size_t kMaxStack
Definition: easylogging++.h:5446
static void setVModules(const char *modules)
Sets vmodules as specified (on the fly)
Definition: easylogging++.h:5968
static void addFlag(LoggingFlag flag)
Adds logging flag used internally.
Definition: easylogging++.h:5928
Logger & operator=(const Logger &logger)
Definition: easylogging++.h:3406
Definition: easylogging++.h:3355
static void validateFileRolling(Logger *logger, Level level)
Definition: easylogging++.h:5770
Level level(void) const
Definition: easylogging++.h:3832
Logger * m_logger
Definition: easylogging++.h:4969
int VerboseLevel
Definition: easylogging++.h:473
static void buildBaseFilename(const std::string &fullPath, char buff[], std::size_t limit=base::consts::kSourceFilenameMaxLength, const char *seperator=base::consts::kFilePathSeperator)
builds base filename and puts it in buff
Definition: easylogging++.h:1204
AbstractRegistry(void)
Default constructor.
Definition: easylogging++.h:1820
NullWriter & operator<<(std::ostream &(*)(std::ostream &))
Definition: easylogging++.h:4897
optional bool error
Definition: requests.proto:11
base::debug::CrashHandler elCrashHandler
Definition: easylogging++.h:5625
static const el::base::utils::CommandLineArgs * commandLineArgs(void)
Returns command line arguments (pointer) provided to easylogging++.
Definition: easylogging++.h:5755
bool vModulesEnabled(void)
Whether or not vModules enabled.
Definition: easylogging++.h:3815
void setFromBase(Configurations *base)
Sets configuration based-off an existing configurations.
Definition: easylogging++.h:2501
std::function< void(const char *, std::size_t)> PreRollOutCallback
Definition: easylogging++.h:846
const std::string & func(void) const
Definition: easylogging++.h:3835
~ScopedRemoveFlag(void)
Definition: easylogging++.h:5951
virtual iterator begin(void) ELPP_FINAL
Definition: easylogging++.h:1869
Level m_level
Definition: easylogging++.h:4964
#define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp)
Definition: easylogging++.h:4623
std::size_t m_index
Definition: easylogging++.h:5461
static Logger * getLogger(const std::string &identity, bool registerIfNotAvailable=true)
Gets existing or registers new logger.
Definition: easylogging++.h:5779
Logger(const std::string &id, const Configurations &configurations, base::LogStreamsReferenceMap *logStreamsReference)
Definition: easylogging++.h:3385
StackTraceEntry(std::size_t index, const char *loc, const char *demang, const char *hex, const char *addr)
Definition: easylogging++.h:5450
#define ELPP_COUT
Definition: easylogging++.h:458
void dispatch(void)
Definition: easylogging++.h:4458
base::LogStreamsReferenceMap * logStreamsReference(void)
Definition: easylogging++.h:3659
base::type::VerboseLevel m_verboseLevel
Definition: easylogging++.h:4968
Definition: easylogging++.h:409
static base::type::string_t formatTime(unsigned long long time, base::TimestampUnit timestampUnit)
Formats time to get unit accordingly, units like second if > 1000 or minutes if > 60000 etc...
Definition: easylogging++.h:1611
virtual ~HitCounter(void)
Definition: easylogging++.h:3206
base::type::VerboseLevel level(void) const
Definition: easylogging++.h:3696
VRegistry(base::type::VerboseLevel level, base::type::EnumType *pFlags)
Definition: easylogging++.h:3682
const base::HitCounter * getCounter(const char *filename, unsigned long int lineNumber)
Gets hit counter registered at specified position.
Definition: easylogging++.h:3310
#define ELPP_COUT_LINE(logLine)
Definition: easylogging++.h:469
virtual const Container & list(void) const ELPP_FINAL
Returns underlying container by constant reference.
Definition: easylogging++.h:1905
CommandLineArgs(void)
Definition: easylogging++.h:1726
Generic level that represents all the levels. Useful when setting global configuration for all levels...
static bool configureFromArg(const char *argKey)
Configures loggers using command line arg. Ensure you have already set command line args...
Definition: easylogging++.h:5912
Registry< T_Ptr, T_Key >::iterator iterator
Definition: easylogging++.h:1931
Configuration * get(const T &arg1, const T2 arg2)
Gets pointer from repository with speicifed arguments. Arguments are passed to predicate in order to ...
Definition: easylogging++.h:2075
virtual void registerNew(const T_Key &uniqKey, T_Ptr *ptr) ELPP_FINAL
Registers new registry to repository.
Definition: easylogging++.h:1970
def debug
Print a debug log to stdout.
Definition: ctdPyUtils.py:60
StackTrace(void)
Definition: easylogging++.h:5476
static bool pathExists(const char *path, bool considerFile=false)
Determines whether or not provided path exist in current file system.
Definition: easylogging++.h:1120
bool hasConfiguration(Level level, ConfigurationType configurationType)
Determines whether or not specified configuration type exists for specified level.
Definition: easylogging++.h:2530
Whether or not to write corresponding log to log file.
Represents single configuration that has representing level, configuration type and a string based va...
Definition: easylogging++.h:2358
const base::LogFormat & logFormat(Level level)
Definition: easylogging++.h:2900
Internal helper class that makes all default constructors private.
Definition: easylogging++.h:491
CrashHandler(bool useDefault)
Definition: easylogging++.h:5600
void uninstallLogDispatchCallback(const std::string &id)
Definition: easylogging++.h:4069
#define STRCAT(a, b, len)
Definition: easylogging++.h:204
virtual ~RegistryWithPred(void)
Definition: easylogging++.h:2013
static bool wildCardMatch(const char *str, const char *pattern)
Matches wildcards, '*' and '?' only supported.
Definition: easylogging++.h:1230
StackTraceEntry(std::size_t index, char *loc)
Definition: easylogging++.h:5457
MillisecondsWidth(int width)
Definition: easylogging++.h:863
ScopedRemoveFlag(LoggingFlag flag)
Definition: easylogging++.h:5950
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.
Definition: easylogging++.h:3179
Represents a logger holding ID and configurations we need to write logs.
Definition: easylogging++.h:3374
ConfigurationType
Represents enumeration of ConfigurationType used to configure or access certain aspect of logging...
Definition: easylogging++.h:589
base::type::string_t build(const LogMessage *logMessage, bool appendNewLine) const
Definition: easylogging++.h:4369
Logger * logger(void) const
Definition: easylogging++.h:3837
AbstractRegistry & operator=(AbstractRegistry &&sr)
Assignment move operator.
Definition: easylogging++.h:1856
Registry(const Registry &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
Definition: easylogging++.h:1937
unsigned long int line(void) const
Definition: easylogging++.h:3834
Lock guard wrapper used when multi-threading is disabled.
Definition: easylogging++.h:1050
static void configureFromGlobal(const char *globalConfigurationFilePath)
Sets configurations from global configuration file.
Definition: easylogging++.h:5868
static base::type::VerboseLevel verboseLevel(void)
Gets current verbose level.
Definition: easylogging++.h:5964
static const std::string version(void)
Current version number.
Definition: easylogging++.h:5981
void increment(void)
Definition: easylogging++.h:3235
RegistryWithPred< T_Ptr, Pred >::const_iterator const_iterator
Definition: easylogging++.h:2008
base::type::fstream_t * fileStream(Level level)
Definition: easylogging++.h:2912
static bool contains(const char *str, char c)
Returns true if c exist in str.
Definition: easylogging++.h:1366
void processDispatch()
Definition: easylogging++.h:5004
#define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp)
Definition: easylogging++.h:4638
std::stringstream stringstream_t
Definition: easylogging++.h:462
#define STRCPY(a, b, len)
Definition: easylogging++.h:205
#define CLOG_IF(condition, LEVEL,...)
Definition: easylogging++.h:6299
void uninstallPerformanceTrackingCallback(const std::string &id)
Definition: easylogging++.h:4083
LogDispatchData()
Definition: easylogging++.h:3336
#define ELPP_INTERNAL_INFO(lvl, msg)
Definition: easylogging++.h:163
static bool endsWith(const std::string &str, const std::string &end)
Determines whether or not str ends with specified string.
Definition: easylogging++.h:1287
Static class that contains helper functions for el::Level.
Definition: easylogging++.h:523
std::string const
Definition: Test{{cookiecutter.device_name}}.cpp:209
void setParentApplicationName(const std::string &parentApplicationName)
Definition: easylogging++.h:3461
bool m_proceed
Definition: easylogging++.h:4970
void reinitDeepCopy(const AbstractRegistry< T_Ptr, Container > &sr)
Definition: easylogging++.h:1914
const std::string & file(void) const
Definition: easylogging++.h:3833
optional string name
Definition: topics.proto:50
const std::string & id(void) const
Definition: easylogging++.h:3453
static T * performanceTrackingCallback(const std::string &id)
Definition: easylogging++.h:5730
std::function< const char *(void)> FormatSpecifierValueResolver
Resolving function for format specifier.
Definition: easylogging++.h:2331
#define ELPP_SIMPLE_LOG(LOG_TYPE)
Definition: easylogging++.h:4572
std::shared_ptr< base::type::fstream_t > FileStreamPtr
Definition: easylogging++.h:2852
Enables hierarchical logging.
Registry(void)
Definition: easylogging++.h:1934
static bool parseFromText(const std::string &configurationsString, Configurations *sender, Configurations *base=nullptr)
Parse configurations from configuration string.
Definition: easylogging++.h:2688
#define ELPP_FINAL
Definition: easylogging++.h:213
Definition: easylogging++.h:5978
std::shared_ptr< PerformanceTrackingCallback > PerformanceTrackingCallbackPtr
Definition: easylogging++.h:475
MessageBuilder(void)
Definition: easylogging++.h:4565
ThreadSafe(void)
Definition: easylogging++.h:1076
static bool hasCustomFormatSpecifier(const char *formatSpecifier)
Returns true if custom format specifier is installed.
Definition: easylogging++.h:5767
Supports use of multiple logging in same macro, e.g, CLOG(INFO, "default", "network") ...
Static helpers for developers.
Definition: easylogging++.h:5648
std::size_t logFlushThreshold(Level level)
Definition: easylogging++.h:2920
bool operator()(const Configuration *conf) const
Definition: easylogging++.h:2419
static ConfigurationType castFromInt(base::type::EnumType c)
Casts int(ushort) to configurationt type, useful for iterating through enum.
Definition: easylogging++.h:630
std::shared_ptr< LogDispatchCallback > LogDispatchCallbackPtr
Definition: easylogging++.h:474
Information that can be useful to back-trace certain events - mostly useful than debug logs...
const char * getParamValue(const char *paramKey) const
Returns value of arguments.
Definition: easylogging++.h:1776
RegistryWithPred(void)
Definition: easylogging++.h:2010
virtual base::threading::Mutex & lock(void) ELPP_FINAL
Definition: easylogging++.h:1074
Specifies log file max size.
Represents registries for verbose logging.
Definition: easylogging++.h:3680
void setToDefault(void)
Sets configurations to "factory based" configurations.
Definition: easylogging++.h:2597
static void setArgs(int argc, char **argv)
Sets application arguments and figures out whats active for logging and whats not.
Definition: easylogging++.h:5659
Easylogging++ management storage.
Definition: easylogging++.h:3902
const std::vector< CustomFormatSpecifier > * customFormatSpecifiers(void) const
Definition: easylogging++.h:4055
bool s_termSupportsColor
Definition: easylogging++.h:1550
Allows to disable application abortion when logged using FATAL level.
virtual bool empty(void) const ELPP_FINAL
Definition: easylogging++.h:1890
static bool installLogDispatchCallback(const std::string &id)
Installs post log dispatch callback, this callback is triggered when log is dispatched.
Definition: easylogging++.h:5707