Monero
easylogging++.h
Go to the documentation of this file.
1 //
2 // Bismillah ar-Rahmaan ar-Raheem
3 //
4 // Easylogging++ v9.96.7
5 // Single-header only, cross-platform logging library for C++ applications
6 //
7 // Copyright (c) 2012-2018 Zuhd Web Services
8 // Copyright (c) 2012-2018 @abumusamq
9 //
10 // This library is released under the MIT Licence.
11 // https://github.com/zuhd-org/easyloggingpp/blob/master/LICENSE
12 //
13 // https://zuhd.org
14 // http://muflihun.com
15 //
16 
17 #ifndef EASYLOGGINGPP_H
18 #define EASYLOGGINGPP_H
19 #include "ea_config.h"
20 // Compilers and C++0x/C++11 Evaluation
21 #if __cplusplus >= 201103L
22 # define ELPP_CXX11 1
23 #endif // __cplusplus >= 201103L
24 #if (defined(__GNUC__))
25 # define ELPP_COMPILER_GCC 1
26 #else
27 # define ELPP_COMPILER_GCC 0
28 #endif
29 #if ELPP_COMPILER_GCC
30 # define ELPP_GCC_VERSION (__GNUC__ * 10000 \
31 + __GNUC_MINOR__ * 100 \
32 + __GNUC_PATCHLEVEL__)
33 # if defined(__GXX_EXPERIMENTAL_CXX0X__)
34 # define ELPP_CXX0X 1
35 # endif
36 #endif
37 // Visual C++
38 #if defined(_MSC_VER)
39 # define ELPP_COMPILER_MSVC 1
40 #else
41 # define ELPP_COMPILER_MSVC 0
42 #endif
43 #define ELPP_CRT_DBG_WARNINGS ELPP_COMPILER_MSVC
44 #if ELPP_COMPILER_MSVC
45 # if (_MSC_VER == 1600)
46 # define ELPP_CXX0X 1
47 # elif(_MSC_VER >= 1700)
48 # define ELPP_CXX11 1
49 # endif
50 #endif
51 // Clang++
52 #if (defined(__clang__) && (__clang__ == 1))
53 # define ELPP_COMPILER_CLANG 1
54 #else
55 # define ELPP_COMPILER_CLANG 0
56 #endif
57 #if ELPP_COMPILER_CLANG
58 # if __has_include(<thread>)
59 # include <cstddef> // Make __GLIBCXX__ defined when using libstdc++
60 # if !defined(__GLIBCXX__) || __GLIBCXX__ >= 20150426
61 # define ELPP_CLANG_SUPPORTS_THREAD
62 # endif // !defined(__GLIBCXX__) || __GLIBCXX__ >= 20150426
63 # endif // __has_include(<thread>)
64 #endif
65 #if (defined(__MINGW32__) || defined(__MINGW64__))
66 # define ELPP_MINGW 1
67 #else
68 # define ELPP_MINGW 0
69 #endif
70 #if (defined(__CYGWIN__) && (__CYGWIN__ == 1))
71 # define ELPP_CYGWIN 1
72 #else
73 # define ELPP_CYGWIN 0
74 #endif
75 #if (defined(__INTEL_COMPILER))
76 # define ELPP_COMPILER_INTEL 1
77 #else
78 # define ELPP_COMPILER_INTEL 0
79 #endif
80 // Operating System Evaluation
81 // Windows
82 #if (defined(_WIN32) || defined(_WIN64))
83 # define ELPP_OS_WINDOWS 1
84 #else
85 # define ELPP_OS_WINDOWS 0
86 #endif
87 // Linux
88 #if (defined(__linux) || defined(__linux__))
89 # define ELPP_OS_LINUX 1
90 #else
91 # define ELPP_OS_LINUX 0
92 #endif
93 #if (defined(__APPLE__))
94 # define ELPP_OS_MAC 1
95 #else
96 # define ELPP_OS_MAC 0
97 #endif
98 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
99 # define ELPP_OS_FREEBSD 1
100 #else
101 # define ELPP_OS_FREEBSD 0
102 #endif
103 #if (defined(__OpenBSD__))
104 # define ELPP_OS_OPENBSD 1
105 #else
106 # define ELPP_OS_OPENBSD 0
107 #endif
108 #if (defined(__NetBSD__))
109 # define ELPP_OS_NETBSD 1
110 #else
111 # define ELPP_OS_NETBSD 0
112 #endif
113 #if (defined(__sun))
114 # define ELPP_OS_SOLARIS 1
115 #else
116 # define ELPP_OS_SOLARIS 0
117 #endif
118 #if (defined(_AIX))
119 # define ELPP_OS_AIX 1
120 #else
121 # define ELPP_OS_AIX 0
122 #endif
123 #if (defined(__NetBSD__))
124 # define ELPP_OS_NETBSD 1
125 #else
126 # define ELPP_OS_NETBSD 0
127 #endif
128 #if defined(__EMSCRIPTEN__)
129 # define ELPP_OS_EMSCRIPTEN 1
130 #else
131 # define ELPP_OS_EMSCRIPTEN 0
132 #endif
133 #if (defined(__DragonFly__))
134 # define ELPP_OS_DRAGONFLY 1
135 #else
136 # define ELPP_OS_DRAGONFLY 0
137 #endif
138 // Unix
139 #if ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_NETBSD || ELPP_OS_SOLARIS || ELPP_OS_AIX || ELPP_OS_EMSCRIPTEN || ELPP_OS_DRAGONFLY || ELPP_OS_OPENBSD) && (!ELPP_OS_WINDOWS))
140 # define ELPP_OS_UNIX 1
141 #else
142 # define ELPP_OS_UNIX 0
143 #endif
144 #if (defined(__ANDROID__))
145 # define ELPP_OS_ANDROID 1
146 #else
147 # define ELPP_OS_ANDROID 0
148 #endif
149 // Evaluating Cygwin as *nix OS
150 #if !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN
151 # undef ELPP_OS_UNIX
152 # undef ELPP_OS_LINUX
153 # define ELPP_OS_UNIX 1
154 # define ELPP_OS_LINUX 1
155 #endif // !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN
156 #if !defined(ELPP_INTERNAL_DEBUGGING_OUT_INFO)
157 # define ELPP_INTERNAL_DEBUGGING_OUT_INFO std::cout
158 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
159 #if !defined(ELPP_INTERNAL_DEBUGGING_OUT_ERROR)
160 # define ELPP_INTERNAL_DEBUGGING_OUT_ERROR std::cerr
161 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
162 #if !defined(ELPP_INTERNAL_DEBUGGING_ENDL)
163 # define ELPP_INTERNAL_DEBUGGING_ENDL std::endl
164 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
165 #if !defined(ELPP_INTERNAL_DEBUGGING_MSG)
166 # define ELPP_INTERNAL_DEBUGGING_MSG(msg) msg
167 #endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT)
168 // Internal Assertions and errors
169 #if !defined(ELPP_DISABLE_ASSERT)
170 # if (defined(ELPP_DEBUG_ASSERT_FAILURE))
171 # define ELPP_ASSERT(expr, msg) if (!(expr)) { \
172 std::stringstream internalInfoStream; internalInfoStream << msg; \
173 ELPP_INTERNAL_DEBUGGING_OUT_ERROR \
174 << "EASYLOGGING++ ASSERTION FAILED (LINE: " << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" \
175 << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" << ELPP_INTERNAL_DEBUGGING_ENDL; base::utils::abort(1, \
176 "ELPP Assertion failure, please define ELPP_DEBUG_ASSERT_FAILURE"); }
177 # else
178 # define ELPP_ASSERT(expr, msg) if (!(expr)) { \
179 std::stringstream internalInfoStream; internalInfoStream << msg; \
180 ELPP_INTERNAL_DEBUGGING_OUT_ERROR\
181 << "ASSERTION FAILURE FROM EASYLOGGING++ (LINE: " \
182 << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" \
183 << ELPP_INTERNAL_DEBUGGING_ENDL; }
184 # endif // (defined(ELPP_DEBUG_ASSERT_FAILURE))
185 #else
186 # define ELPP_ASSERT(x, y)
187 #endif //(!defined(ELPP_DISABLE_ASSERT)
188 #if ELPP_COMPILER_MSVC
189 # define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \
190 { char buff[256]; strerror_s(buff, 256, errno); \
191 ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << buff << " [" << errno << "]";} (void)0
192 #else
193 # define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \
194 ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << strerror(errno) << " [" << errno << "]"; (void)0
195 #endif // ELPP_COMPILER_MSVC
196 #if defined(ELPP_DEBUG_ERRORS)
197 # if !defined(ELPP_INTERNAL_ERROR)
198 # define ELPP_INTERNAL_ERROR(msg, pe) { \
199 std::stringstream internalInfoStream; internalInfoStream << "<ERROR> " << msg; \
200 ELPP_INTERNAL_DEBUGGING_OUT_ERROR \
201 << "ERROR FROM EASYLOGGING++ (LINE: " << __LINE__ << ") " \
202 << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << ELPP_INTERNAL_DEBUGGING_ENDL; \
203 if (pe) { ELPP_INTERNAL_DEBUGGING_OUT_ERROR << " "; ELPP_INTERNAL_DEBUGGING_WRITE_PERROR; }} (void)0
204 # endif
205 #else
206 # undef ELPP_INTERNAL_INFO
207 # define ELPP_INTERNAL_ERROR(msg, pe)
208 #endif // defined(ELPP_DEBUG_ERRORS)
209 #if (defined(ELPP_DEBUG_INFO))
210 # if !(defined(ELPP_INTERNAL_INFO_LEVEL))
211 # define ELPP_INTERNAL_INFO_LEVEL 9
212 # endif // !(defined(ELPP_INTERNAL_INFO_LEVEL))
213 # if !defined(ELPP_INTERNAL_INFO)
214 # define ELPP_INTERNAL_INFO(lvl, msg) { if (lvl <= ELPP_INTERNAL_INFO_LEVEL) { \
215 std::stringstream internalInfoStream; internalInfoStream << "<INFO> " << msg; \
216 ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) \
217 << ELPP_INTERNAL_DEBUGGING_ENDL; }}
218 # endif
219 #else
220 # undef ELPP_INTERNAL_INFO
221 # define ELPP_INTERNAL_INFO(lvl, msg)
222 #endif // (defined(ELPP_DEBUG_INFO))
223 #if (defined(ELPP_FEATURE_ALL)) || (defined(ELPP_FEATURE_CRASH_LOG))
224 # if (ELPP_COMPILER_GCC && !ELPP_MINGW && !ELPP_OS_OPENBSD && !ELPP_OS_NETBSD && !ELPP_OS_ANDROID && !ELPP_OS_EMSCRIPTEN)
225 # define ELPP_STACKTRACE 1
226 # else
227 # define ELPP_STACKTRACE 0
228 # ifdef EASYLOGGING_CC
229 # if ELPP_COMPILER_MSVC
230 # pragma message("Stack trace not available for this compiler")
231 # else
232 # warning "Stack trace not available for this compiler";
233 # endif // ELPP_COMPILER_MSVC
234 # endif
235 # endif // ELPP_COMPILER_GCC
236 #else
237 # define ELPP_STACKTRACE 0
238 #endif // (defined(ELPP_FEATURE_ALL)) || (defined(ELPP_FEATURE_CRASH_LOG))
239 // Miscellaneous macros
240 #define ELPP_UNUSED(x) (void)x
241 #if ELPP_OS_UNIX
242 // Log file permissions for unix-based systems
243 # define ELPP_LOG_PERMS S_IRUSR | S_IWUSR | S_IXUSR | S_IWGRP | S_IRGRP | S_IXGRP | S_IWOTH | S_IXOTH
244 #endif // ELPP_OS_UNIX
245 #if defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC
246 # if defined(ELPP_EXPORT_SYMBOLS)
247 # define ELPP_EXPORT __declspec(dllexport)
248 # else
249 # define ELPP_EXPORT __declspec(dllimport)
250 # endif // defined(ELPP_EXPORT_SYMBOLS)
251 #else
252 # define ELPP_EXPORT
253 #endif // defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC
254 // Some special functions that are VC++ specific
255 #undef STRTOK
256 #undef STRERROR
257 #undef STRCAT
258 #undef STRCPY
259 #if ELPP_CRT_DBG_WARNINGS
260 # define STRTOK(a, b, c) strtok_s(a, b, c)
261 # define STRERROR(a, b, c) strerror_s(a, b, c)
262 # define STRCAT(a, b, len) strcat_s(a, len, b)
263 # define STRCPY(a, b, len) strcpy_s(a, len, b)
264 #else
265 # define STRTOK(a, b, c) strtok(a, b)
266 # define STRERROR(a, b, c) strerror(c)
267 # define STRCAT(a, b, len) strcat(a, b)
268 # define STRCPY(a, b, len) strcpy(a, b)
269 #endif
270 // Compiler specific support evaluations
271 #if (ELPP_MINGW && !defined(ELPP_FORCE_USE_STD_THREAD))
272 # define ELPP_USE_STD_THREADING 0
273 #else
274 # if ((ELPP_COMPILER_CLANG && defined(ELPP_CLANG_SUPPORTS_THREAD)) || \
275  (!ELPP_COMPILER_CLANG && defined(ELPP_CXX11)) || \
276  defined(ELPP_FORCE_USE_STD_THREAD))
277 # define ELPP_USE_STD_THREADING 1
278 # else
279 # define ELPP_USE_STD_THREADING 0
280 # endif
281 #endif
282 #undef ELPP_FINAL
283 #if ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702)
284 # define ELPP_FINAL
285 #else
286 # define ELPP_FINAL final
287 #endif // ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702)
288 #if defined(ELPP_EXPERIMENTAL_ASYNC)
289 # define ELPP_ASYNC_LOGGING 1
290 #else
291 # define ELPP_ASYNC_LOGGING 0
292 #endif // defined(ELPP_EXPERIMENTAL_ASYNC)
293 #if defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING
294 # define ELPP_THREADING_ENABLED 1
295 #else
296 # define ELPP_THREADING_ENABLED 0
297 #endif // defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING
298 // Function macro ELPP_FUNC
299 #undef ELPP_FUNC
300 #if ELPP_COMPILER_MSVC // Visual C++
301 # define ELPP_FUNC __FUNCSIG__
302 #elif ELPP_COMPILER_GCC // GCC
303 # define ELPP_FUNC __PRETTY_FUNCTION__
304 #elif ELPP_COMPILER_INTEL // Intel C++
305 # define ELPP_FUNC __PRETTY_FUNCTION__
306 #elif ELPP_COMPILER_CLANG // Clang++
307 # define ELPP_FUNC __PRETTY_FUNCTION__
308 #else
309 # if defined(__func__)
310 # define ELPP_FUNC __func__
311 # else
312 # define ELPP_FUNC ""
313 # endif // defined(__func__)
314 #endif // defined(_MSC_VER)
315 #undef ELPP_VARIADIC_TEMPLATES_SUPPORTED
316 // Keep following line commented until features are fixed
317 #define ELPP_VARIADIC_TEMPLATES_SUPPORTED \
318 (ELPP_COMPILER_GCC || ELPP_COMPILER_CLANG || ELPP_COMPILER_INTEL || (ELPP_COMPILER_MSVC && _MSC_VER >= 1800))
319 // Logging Enable/Disable macros
320 #ifdef ELPP_DISABLE_LOGS
321 # define ELPP_LOGGING_ENABLED 0
322 #else
323 # define ELPP_LOGGING_ENABLED 1
324 #endif
325 #if (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED))
326 # define ELPP_DEBUG_LOG 1
327 #else
328 # define ELPP_DEBUG_LOG 0
329 #endif // (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED))
330 #if (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED))
331 # define ELPP_INFO_LOG 1
332 #else
333 # define ELPP_INFO_LOG 0
334 #endif // (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED))
335 #if (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED))
336 # define ELPP_WARNING_LOG 1
337 #else
338 # define ELPP_WARNING_LOG 0
339 #endif // (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED))
340 #if (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED))
341 # define ELPP_ERROR_LOG 1
342 #else
343 # define ELPP_ERROR_LOG 0
344 #endif // (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED))
345 #if (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED))
346 # define ELPP_FATAL_LOG 1
347 #else
348 # define ELPP_FATAL_LOG 0
349 #endif // (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED))
350 #if (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED))
351 # define ELPP_TRACE_LOG 1
352 #else
353 # define ELPP_TRACE_LOG 0
354 #endif // (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED))
355 #if (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED))
356 # define ELPP_VERBOSE_LOG 1
357 #else
358 # define ELPP_VERBOSE_LOG 0
359 #endif // (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED))
360 #if (!(ELPP_CXX0X || ELPP_CXX11))
361 # error "C++0x (or higher) support not detected! (Is `-std=c++11' missing?)"
362 #endif // (!(ELPP_CXX0X || ELPP_CXX11))
363 // Headers
364 #if defined(ELPP_SYSLOG)
365 # include <syslog.h>
366 #endif // defined(ELPP_SYSLOG)
367 #include <climits>
368 #include <ctime>
369 #include <cstring>
370 #include <cstdlib>
371 #include <cctype>
372 #include <cwchar>
373 #include <csignal>
374 #include <cerrno>
375 #include <cstdarg>
376 #if defined(ELPP_UNICODE)
377 # include <locale>
378 # if ELPP_OS_WINDOWS
379 # include <codecvt>
380 # endif // ELPP_OS_WINDOWS
381 #endif // defined(ELPP_UNICODE)
382 #if ELPP_STACKTRACE
383 # include <cxxabi.h>
384 # include <execinfo.h>
385 #endif // ELPP_STACKTRACE
386 #if ELPP_OS_ANDROID
387 # include <sys/system_properties.h>
388 #endif // ELPP_OS_ANDROID
389 #if ELPP_OS_UNIX
390 # include <sys/stat.h>
391 # include <sys/time.h>
392 #elif ELPP_OS_WINDOWS
393 # include <direct.h>
394 # include <windows.h>
395 # if defined(WIN32_LEAN_AND_MEAN)
396 # if defined(ELPP_WINSOCK2)
397 # include <winsock2.h>
398 # else
399 # include <winsock.h>
400 # endif // defined(ELPP_WINSOCK2)
401 # endif // defined(WIN32_LEAN_AND_MEAN)
402 #endif // ELPP_OS_UNIX
403 #include <string>
404 #include <vector>
405 #include <map>
406 #include <unordered_map>
407 #include <utility>
408 #include <functional>
409 #include <algorithm>
410 #include <fstream>
411 #include <iostream>
412 #include <sstream>
413 #include <memory>
414 #include <type_traits>
415 #if ELPP_THREADING_ENABLED
416 # if ELPP_USE_STD_THREADING
417 # include <mutex>
418 # include <thread>
419 # else
420 # if ELPP_OS_UNIX
421 # include <pthread.h>
422 # endif // ELPP_OS_UNIX
423 # endif // ELPP_USE_STD_THREADING
424 #endif // ELPP_THREADING_ENABLED
425 #if ELPP_ASYNC_LOGGING
426 # if defined(ELPP_NO_SLEEP_FOR)
427 # include <unistd.h>
428 # endif // defined(ELPP_NO_SLEEP_FOR)
429 # include <thread>
430 # include <queue>
431 # include <condition_variable>
432 #endif // ELPP_ASYNC_LOGGING
433 #if defined(ELPP_STL_LOGGING)
434 // For logging STL based templates
435 # include <list>
436 # include <queue>
437 # include <deque>
438 # include <set>
439 # include <bitset>
440 # include <stack>
441 # if defined(ELPP_LOG_STD_ARRAY)
442 # include <array>
443 # endif // defined(ELPP_LOG_STD_ARRAY)
444 # if defined(ELPP_LOG_UNORDERED_SET)
445 # include <unordered_set>
446 # endif // defined(ELPP_UNORDERED_SET)
447 #endif // defined(ELPP_STL_LOGGING)
448 #if defined(ELPP_QT_LOGGING)
449 // For logging Qt based classes & templates
450 # include <QString>
451 # include <QByteArray>
452 # include <QVector>
453 # include <QList>
454 # include <QPair>
455 # include <QMap>
456 # include <QQueue>
457 # include <QSet>
458 # include <QLinkedList>
459 # include <QHash>
460 # include <QMultiHash>
461 # include <QStack>
462 #endif // defined(ELPP_QT_LOGGING)
463 #if defined(ELPP_BOOST_LOGGING)
464 // For logging boost based classes & templates
465 # include <boost/container/vector.hpp>
466 # include <boost/container/stable_vector.hpp>
467 # include <boost/container/list.hpp>
468 # include <boost/container/deque.hpp>
469 # include <boost/container/map.hpp>
470 # include <boost/container/flat_map.hpp>
471 # include <boost/container/set.hpp>
472 # include <boost/container/flat_set.hpp>
473 #endif // defined(ELPP_BOOST_LOGGING)
474 #if defined(ELPP_WXWIDGETS_LOGGING)
475 // For logging wxWidgets based classes & templates
476 # include <wx/vector.h>
477 #endif // defined(ELPP_WXWIDGETS_LOGGING)
478 #if defined(ELPP_UTC_DATETIME)
479 # define elpptime_r gmtime_r
480 # define elpptime_s gmtime_s
481 # define elpptime gmtime
482 #else
483 # define elpptime_r localtime_r
484 # define elpptime_s localtime_s
485 # define elpptime localtime
486 #endif // defined(ELPP_UTC_DATETIME)
487 // Forward declarations
488 namespace el {
489 class Logger;
490 class LogMessage;
491 class PerformanceTrackingData;
492 class Loggers;
493 class Helpers;
494 template <typename T> class Callback;
495 class LogDispatchCallback;
498 class LogDispatchData;
499 namespace base {
500 class Storage;
501 class RegisteredLoggers;
502 class PerformanceTracker;
503 class MessageBuilder;
504 class Writer;
505 class PErrorWriter;
506 class LogDispatcher;
507 class DefaultLogBuilder;
508 class DefaultLogDispatchCallback;
509 #if ELPP_ASYNC_LOGGING
510 class AsyncLogDispatchCallback;
511 class AsyncDispatchWorker;
512 #endif // ELPP_ASYNC_LOGGING
513 class DefaultPerformanceTrackingCallback;
514 } // namespace base
515 } // namespace el
517 namespace el {
519 namespace base {
521 namespace type {
522 #undef ELPP_LITERAL
523 #undef ELPP_STRLEN
524 #undef ELPP_COUT
525 #if defined(ELPP_UNICODE)
526 # define ELPP_LITERAL(txt) L##txt
527 # define ELPP_STRLEN wcslen
528 # if defined ELPP_CUSTOM_COUT
529 # define ELPP_COUT ELPP_CUSTOM_COUT
530 # else
531 # define ELPP_COUT std::wcout
532 # endif // defined ELPP_CUSTOM_COUT
533 typedef wchar_t char_t;
534 typedef std::wstring string_t;
535 typedef std::wstringstream stringstream_t;
536 typedef std::wfstream fstream_t;
537 typedef std::wostream ostream_t;
538 #else
539 # define ELPP_LITERAL(txt) txt
540 # define ELPP_STRLEN strlen
541 # if defined ELPP_CUSTOM_COUT
542 # define ELPP_COUT ELPP_CUSTOM_COUT
543 # else
544 # define ELPP_COUT std::cout
545 # endif // defined ELPP_CUSTOM_COUT
546 typedef char char_t;
548 typedef std::stringstream stringstream_t;
549 typedef std::fstream fstream_t;
550 typedef std::ostream ostream_t;
551 #endif // defined(ELPP_UNICODE)
552 #if defined(ELPP_CUSTOM_COUT_LINE)
553 # define ELPP_COUT_LINE(logLine) ELPP_CUSTOM_COUT_LINE(logLine)
554 #else
555 # define ELPP_COUT_LINE(logLine) logLine << std::flush
556 #endif // defined(ELPP_CUSTOM_COUT_LINE)
557 typedef unsigned int EnumType;
558 typedef unsigned short VerboseLevel;
559 typedef unsigned long int LineNumber;
561 typedef std::shared_ptr<LogDispatchCallback> LogDispatchCallbackPtr;
562 typedef std::shared_ptr<PerformanceTrackingCallback> PerformanceTrackingCallbackPtr;
563 typedef std::shared_ptr<LoggerRegistrationCallback> LoggerRegistrationCallbackPtr;
564 typedef std::unique_ptr<el::base::PerformanceTracker> PerformanceTrackerPtr;
565 } // namespace type
569 class NoCopy {
570  protected:
571  NoCopy(void) {}
572  private:
573  NoCopy(const NoCopy&);
574  NoCopy& operator=(const NoCopy&);
575 };
580 class StaticClass {
581  private:
582  StaticClass(void);
583  StaticClass(const StaticClass&);
585 };
586 } // namespace base
593  Global = 1,
595  Trace = 2,
597  Debug = 4,
599  Fatal = 8,
601  Error = 16,
603  Warning = 32,
605  Verbose = 64,
607  Info = 128,
609  Unknown = 1010
610 };
612  Default,
613  Red,
614  Green,
615  Yellow,
616  Blue,
617  Magenta,
618  Cyan,
619 };
620 } // namespace el
621 namespace std {
622 template<> struct hash<el::Level> {
623  public:
624  std::size_t operator()(const el::Level& l) const {
625  return hash<el::base::type::EnumType> {}(static_cast<el::base::type::EnumType>(l));
626  }
627 };
628 }
629 namespace el {
632  public:
639  return static_cast<base::type::EnumType>(level);
640  }
643  return static_cast<Level>(l);
644  }
647  static const char* convertToString(Level level);
651  static Level convertFromStringPrefix(const char* levelStr);
655  static Level convertFromString(const char* levelStr);
660  static void forEachLevel(base::type::EnumType* startIndex, const std::function<bool(void)>& fn);
661 };
667  Enabled = 1,
669  ToFile = 2,
672  ToStandardOutput = 4,
674  Format = 8,
676  Filename = 16,
678  SubsecondPrecision = 32,
684  PerformanceTracking = 64,
689  MaxLogFileSize = 128,
691  LogFlushThreshold = 256,
693  Unknown = 1010
694 };
697  public:
704  return static_cast<base::type::EnumType>(configurationType);
705  }
708  return static_cast<ConfigurationType>(c);
709  }
712  static const char* convertToString(ConfigurationType configurationType);
716  static ConfigurationType convertFromString(const char* configStr);
722  static inline void forEachConfigType(base::type::EnumType* startIndex, const std::function<bool(void)>& fn);
723 };
736  ImmediateFlush = 16,
742  MultiLoggerSupport = 128,
746  DisableVModules = 512,
750  HierarchicalLogging = 2048,
754  AutoSpacing = 8192,
756  FixedTimeFormat = 16384,
757  // @brief Ignore SIGINT or crash
758  IgnoreSigInt = 32768,
759 };
760 namespace base {
762 namespace consts {
763 static const char kFormatSpecifierCharValue = 'v';
764 static const char kFormatSpecifierChar = '%';
765 static const unsigned int kMaxLogPerCounter = 100000;
766 static const unsigned int kMaxLogPerContainer = 100;
767 static const unsigned int kDefaultSubsecondPrecision = 3;
768 
769 #ifdef ELPP_DEFAULT_LOGGER
770 static const char* kDefaultLoggerId = ELPP_DEFAULT_LOGGER;
771 #else
772 static const char* kDefaultLoggerId = "default";
773 #endif
774 
775 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
776 #ifdef ELPP_DEFAULT_PERFORMANCE_LOGGER
777 static const char* kPerformanceLoggerId = ELPP_DEFAULT_PERFORMANCE_LOGGER;
778 #else
779 static const char* kPerformanceLoggerId = "performance";
780 #endif // ELPP_DEFAULT_PERFORMANCE_LOGGER
781 #endif
782 
783 #if defined(ELPP_SYSLOG)
784 static const char* kSysLogLoggerId = "syslog";
785 #endif // defined(ELPP_SYSLOG)
786 
787 #if ELPP_OS_WINDOWS
788 static const char* kFilePathSeperator = "\\";
789 #else
790 static const char* kFilePathSeperator = "/";
791 #endif // ELPP_OS_WINDOWS
792 
793 static const std::size_t kSourceFilenameMaxLength = 100;
794 static const std::size_t kSourceLineMaxLength = 10;
796 const struct {
797  double value;
799 } kTimeFormats[] = {
800  { 1000.0f, ELPP_LITERAL("us") },
801  { 1000.0f, ELPP_LITERAL("ms") },
802  { 60.0f, ELPP_LITERAL("seconds") },
803  { 60.0f, ELPP_LITERAL("minutes") },
804  { 24.0f, ELPP_LITERAL("hours") },
805  { 7.0f, ELPP_LITERAL("days") }
806 };
807 static const int kTimeFormatsCount = sizeof(kTimeFormats) / sizeof(kTimeFormats[0]);
808 const struct {
809  int numb;
810  const char* name;
811  const char* brief;
812  const char* detail;
813 } kCrashSignals[] = {
814  // NOTE: Do not re-order, if you do please check CrashHandler(bool) constructor and CrashHandler::setHandler(..)
815  {
816  SIGABRT, "SIGABRT", "Abnormal termination",
817  "Program was abnormally terminated."
818  },
819  {
820  SIGFPE, "SIGFPE", "Erroneous arithmetic operation",
821  "Arithemetic operation issue such as division by zero or operation resulting in overflow."
822  },
823  {
824  SIGILL, "SIGILL", "Illegal instruction",
825  "Generally due to a corruption in the code or to an attempt to execute data."
826  },
827  {
828  SIGSEGV, "SIGSEGV", "Invalid access to memory",
829  "Program is trying to read an invalid (unallocated, deleted or corrupted) or inaccessible memory."
830  },
831  {
832  SIGINT, "SIGINT", "Interactive attention signal",
833  "Interruption generated (generally) by user or operating system."
834  },
835 };
836 static const int kCrashSignalsCount = sizeof(kCrashSignals) / sizeof(kCrashSignals[0]);
837 } // namespace consts
838 } // namespace base
839 typedef std::function<void(const char*, std::size_t)> PreRollOutCallback;
840 namespace base {
841 static inline void defaultPreRollOutCallback(const char*, std::size_t) {}
844  Microsecond = 0, Millisecond = 1, Second = 2, Minute = 3, Hour = 4, Day = 5
845 };
848  DateTime = 1 << 1,
849  LoggerId = 1 << 2,
850  File = 1 << 3,
851  Line = 1 << 4,
852  Location = 1 << 5,
853  Function = 1 << 6,
854  User = 1 << 7,
855  Host = 1 << 8,
856  LogMessage = 1 << 9,
857  VerboseLevel = 1 << 10,
858  AppName = 1 << 11,
859  ThreadId = 1 << 12,
860  Level = 1 << 13,
861  FileBase = 1 << 14,
862  LevelShort = 1 << 15
863 };
866  public:
869  }
870  explicit SubsecondPrecision(int width) {
871  init(width);
872  }
873  bool operator==(const SubsecondPrecision& ssPrec) {
874  return m_width == ssPrec.m_width && m_offset == ssPrec.m_offset;
875  }
876  int m_width;
877  unsigned int m_offset;
878  private:
879  void init(int width);
880 };
884 namespace utils {
886 template <typename T>
887 static
890  if (pointer == nullptr)
891  return;
892  delete pointer;
893  pointer = nullptr;
894 }
897 namespace bitwise {
898 template <typename Enum>
899 static inline base::type::EnumType And(Enum e, base::type::EnumType flag) {
900  return static_cast<base::type::EnumType>(flag) & static_cast<base::type::EnumType>(e);
901 }
902 template <typename Enum>
903 static inline base::type::EnumType Not(Enum e, base::type::EnumType flag) {
904  return static_cast<base::type::EnumType>(flag) & ~(static_cast<base::type::EnumType>(e));
905 }
906 template <typename Enum>
907 static inline base::type::EnumType Or(Enum e, base::type::EnumType flag) {
908  return static_cast<base::type::EnumType>(flag) | static_cast<base::type::EnumType>(e);
909 }
910 } // namespace bitwise
911 template <typename Enum>
912 static inline void addFlag(Enum e, base::type::EnumType* flag) {
913  *flag = base::utils::bitwise::Or<Enum>(e, *flag);
914 }
915 template <typename Enum>
916 static inline void removeFlag(Enum e, base::type::EnumType* flag) {
917  *flag = base::utils::bitwise::Not<Enum>(e, *flag);
918 }
919 template <typename Enum>
920 static inline bool hasFlag(Enum e, base::type::EnumType flag) {
921  return base::utils::bitwise::And<Enum>(e, flag) > 0x0;
922 }
923 } // namespace utils
924 namespace threading {
925 #if ELPP_THREADING_ENABLED
926 # if !ELPP_USE_STD_THREADING
927 namespace internal {
930  public:
931  Mutex(void) {
932 # if ELPP_OS_UNIX
933  pthread_mutexattr_t attr;
934  pthread_mutexattr_init(&attr);
935  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
936  pthread_mutex_init(&m_underlyingMutex, &attr);
937  pthread_mutexattr_destroy(&attr);
938 # elif ELPP_OS_WINDOWS
939  InitializeCriticalSection(&m_underlyingMutex);
940 # endif // ELPP_OS_UNIX
941  }
942 
943  virtual ~Mutex(void) {
944 # if ELPP_OS_UNIX
945  pthread_mutex_destroy(&m_underlyingMutex);
946 # elif ELPP_OS_WINDOWS
947  DeleteCriticalSection(&m_underlyingMutex);
948 # endif // ELPP_OS_UNIX
949  }
950 
951  inline void lock(void) {
952 # if ELPP_OS_UNIX
953  pthread_mutex_lock(&m_underlyingMutex);
954 # elif ELPP_OS_WINDOWS
955  EnterCriticalSection(&m_underlyingMutex);
956 # endif // ELPP_OS_UNIX
957  }
958 
959  inline bool try_lock(void) {
960 # if ELPP_OS_UNIX
961  return (pthread_mutex_trylock(&m_underlyingMutex) == 0);
962 # elif ELPP_OS_WINDOWS
963  return TryEnterCriticalSection(&m_underlyingMutex);
964 # endif // ELPP_OS_UNIX
965  }
966 
967  inline void unlock(void) {
968 # if ELPP_OS_UNIX
969  pthread_mutex_unlock(&m_underlyingMutex);
970 # elif ELPP_OS_WINDOWS
971  LeaveCriticalSection(&m_underlyingMutex);
972 # endif // ELPP_OS_UNIX
973  }
974 
975  private:
976 # if ELPP_OS_UNIX
977  pthread_mutex_t m_underlyingMutex;
978 # elif ELPP_OS_WINDOWS
979  CRITICAL_SECTION m_underlyingMutex;
980 # endif // ELPP_OS_UNIX
981 };
983 template <typename M>
985  public:
986  explicit ScopedLock(M& mutex) {
987  m_mutex = &mutex;
988  m_mutex->lock();
989  }
990 
991  virtual ~ScopedLock(void) {
992  m_mutex->unlock();
993  }
994  private:
996  ScopedLock(void);
997 };
998 } // namespace internal
1001 # else
1002 typedef std::recursive_mutex Mutex;
1003 typedef std::lock_guard<base::threading::Mutex> ScopedLock;
1004 # endif // !ELPP_USE_STD_THREADING
1005 #else
1006 namespace internal {
1008 class NoMutex : base::NoCopy {
1009  public:
1010  NoMutex(void) {}
1011  inline void lock(void) {}
1012  inline bool try_lock(void) {
1013  return true;
1014  }
1015  inline void unlock(void) {}
1016 };
1018 template <typename Mutex>
1019 class NoScopedLock : base::NoCopy {
1020  public:
1021  explicit NoScopedLock(Mutex&) {
1022  }
1023  virtual ~NoScopedLock(void) {
1024  }
1025  private:
1026  NoScopedLock(void);
1027 };
1028 } // namespace internal
1029 typedef base::threading::internal::NoMutex Mutex;
1030 typedef base::threading::internal::NoScopedLock<base::threading::Mutex> ScopedLock;
1031 #endif // ELPP_THREADING_ENABLED
1032 class ThreadSafe {
1034  public:
1035  virtual inline void acquireLock(void) ELPP_FINAL { m_mutex.lock(); }
1036  virtual inline void releaseLock(void) ELPP_FINAL { m_mutex.unlock(); }
1037  virtual inline base::threading::Mutex& lock(void) ELPP_FINAL { return m_mutex; }
1038  protected:
1039  ThreadSafe(void) {}
1040  virtual ~ThreadSafe(void) {}
1041  private:
1043 };
1044 
1045 #if ELPP_THREADING_ENABLED
1046 # if !ELPP_USE_STD_THREADING
1047 static std::string getCurrentThreadId(void) {
1049  std::stringstream ss;
1050 # if (ELPP_OS_WINDOWS)
1051  ss << GetCurrentThreadId();
1052 # endif // (ELPP_OS_WINDOWS)
1053  return ss.str();
1054 }
1055 # else
1056 static std::string getCurrentThreadId(void) {
1058  std::stringstream ss;
1059  char prev_fill = ss.fill(' ');
1060  auto prev_flags = ss.flags(std::ios::hex);
1061  //ss.setf(std::ios::hex);
1062  auto prev_width = ss.width(16);
1063  ss << std::this_thread::get_id();
1064  ss.fill(prev_fill);
1065  ss.flags(prev_flags);
1066  ss.width(prev_width);
1067  return ss.str();
1068 }
1069 # endif // !ELPP_USE_STD_THREADING
1070 #else
1071 static inline std::string getCurrentThreadId(void) {
1072  return std::string();
1073 }
1074 #endif // ELPP_THREADING_ENABLED
1075 } // namespace threading
1076 namespace utils {
1078  public:
1081  static base::type::fstream_t* newFileStream(const std::string& filename);
1082 
1084  static std::size_t getSizeOfFile(base::type::fstream_t* fs);
1085 
1087  static bool pathExists(const char* path, bool considerFile = false);
1088 
1091  static bool createPath(const std::string& path);
1093  static std::string extractPathFromFilename(const std::string& fullPath,
1094  const char* seperator = base::consts::kFilePathSeperator);
1096  static void buildStrippedFilename(const char* filename, char buff[], const std::string &commonPrefix = NULL,
1097  std::size_t limit = base::consts::kSourceFilenameMaxLength);
1099  static void buildBaseFilename(const std::string& fullPath, char buff[],
1100  std::size_t limit = base::consts::kSourceFilenameMaxLength,
1101  const char* seperator = base::consts::kFilePathSeperator);
1102 };
1105  public:
1107  static inline bool isDigit(char c) {
1108  return c >= '0' && c <= '9';
1109  }
1110 
1112  static bool wildCardMatch(const char* str, const char* pattern);
1113 
1114  static std::string& ltrim(std::string& str);
1115  static std::string& rtrim(std::string& str);
1116  static std::string& trim(std::string& str);
1117 
1122  static bool startsWith(const std::string& str, const std::string& start);
1123 
1128  static bool endsWith(const std::string& str, const std::string& end);
1129 
1135  static std::string& replaceAll(std::string& str, char replaceWhat, char replaceWith);
1136 
1142  static std::string& replaceAll(std::string& str, const std::string& replaceWhat,
1143  const std::string& replaceWith);
1144 
1145  static void replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat,
1146  const base::type::string_t& replaceWith);
1147 #if defined(ELPP_UNICODE)
1148  static void replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat,
1149  const std::string& replaceWith);
1150 #endif // defined(ELPP_UNICODE)
1151  static std::string& toUpper(std::string& str);
1155 
1157  static bool cStringEq(const char* s1, const char* s2);
1158 
1161  static bool cStringCaseEq(const char* s1, const char* s2);
1162 
1164  static bool contains(const char* str, char c);
1165 
1166  static char* convertAndAddToBuff(std::size_t n, int len, char* buf, const char* bufLim, bool zeroPadded = true);
1167  static char* addToBuff(const char* str, char* buf, const char* bufLim);
1168  static char* clearBuff(char buff[], std::size_t lim);
1169 
1172  static char* wcharPtrToCharPtr(const wchar_t* line);
1173 };
1176  public:
1177 #if ELPP_OS_WINDOWS
1178  static const char* getWindowsEnvironmentVariable(const char* varname);
1183 #endif // ELPP_OS_WINDOWS
1184 #if ELPP_OS_ANDROID
1185  static std::string getProperty(const char* prop);
1187 
1189  static std::string getDeviceName(void);
1190 #endif // ELPP_OS_ANDROID
1191 
1197  static const std::string getBashOutput(const char* command);
1198 
1204  static std::string getEnvironmentVariable(const char* variableName, const char* defaultVal,
1205  const char* alternativeBashCommand = nullptr);
1207  static std::string currentUser(void);
1208 
1212  static std::string currentHost(void);
1214  static bool termSupportsColor(void);
1215 };
1218  public:
1223  static void gettimeofday(struct timeval* tv);
1224 
1229  static std::string getDateTime(const char* format, const base::SubsecondPrecision* ssPrec);
1230 
1232  static std::string timevalToString(struct timeval tval, const char* format,
1233  const el::base::SubsecondPrecision* ssPrec);
1234 
1236  static base::type::string_t formatTime(unsigned long long time, base::TimestampUnit timestampUnit);
1237 
1239  static unsigned long long getTimeDifference(const struct timeval& endTime, const struct timeval& startTime,
1240  base::TimestampUnit timestampUnit);
1241 
1242 
1243  static struct ::tm* buildTimeInfo(struct timeval* currTime, struct ::tm* timeInfo);
1244  private:
1245  static char* parseFormat(char* buf, std::size_t bufSz, const char* format, const struct tm* tInfo,
1246  std::size_t msec, const base::SubsecondPrecision* ssPrec);
1247 };
1250  public:
1252  setArgs(0, static_cast<char**>(nullptr));
1253  }
1254  CommandLineArgs(int argc, const char** argv) {
1255  setArgs(argc, argv);
1256  }
1257  CommandLineArgs(int argc, char** argv) {
1258  setArgs(argc, argv);
1259  }
1260  virtual ~CommandLineArgs(void) {}
1262  inline void setArgs(int argc, const char** argv) {
1263  setArgs(argc, const_cast<char**>(argv));
1264  }
1266  void setArgs(int argc, char** argv);
1268  bool hasParamWithValue(const char* paramKey) const;
1271  const char* getParamValue(const char* paramKey) const;
1273  bool hasParam(const char* paramKey) const;
1275  bool empty(void) const;
1277  std::size_t size(void) const;
1279 
1280  private:
1281  int m_argc;
1282  char** m_argv;
1283  std::unordered_map<std::string, std::string> m_paramsWithValue;
1284  std::vector<std::string> m_params;
1285 };
1292 template <typename T_Ptr, typename Container>
1294  public:
1295  typedef typename Container::iterator iterator;
1296  typedef typename Container::const_iterator const_iterator;
1297 
1300 
1303  if (this == &sr) {
1304  return;
1305  }
1306  unregisterAll();
1307  m_list = std::move(sr.m_list);
1308  }
1309 
1311  if (size() != other.size()) {
1312  return false;
1313  }
1314  for (std::size_t i = 0; i < m_list.size(); ++i) {
1315  if (m_list.at(i) != other.m_list.at(i)) {
1316  return false;
1317  }
1318  }
1319  return true;
1320  }
1321 
1323  if (size() != other.size()) {
1324  return true;
1325  }
1326  for (std::size_t i = 0; i < m_list.size(); ++i) {
1327  if (m_list.at(i) != other.m_list.at(i)) {
1328  return true;
1329  }
1330  }
1331  return false;
1332  }
1333 
1336  if (this == &sr) {
1337  return *this;
1338  }
1339  unregisterAll();
1340  m_list = std::move(sr.m_list);
1341  return *this;
1342  }
1343 
1344  virtual ~AbstractRegistry(void) {
1345  }
1346 
1348  virtual inline iterator begin(void) ELPP_FINAL {
1349  return m_list.begin();
1350  }
1351 
1353  virtual inline iterator end(void) ELPP_FINAL {
1354  return m_list.end();
1355  }
1356 
1357 
1359  virtual inline const_iterator cbegin(void) const ELPP_FINAL {
1360  return m_list.cbegin();
1361  }
1362 
1364  virtual inline const_iterator cend(void) const ELPP_FINAL {
1365  return m_list.cend();
1366  }
1367 
1369  virtual inline bool empty(void) const ELPP_FINAL {
1370  return m_list.empty();
1371  }
1372 
1374  virtual inline std::size_t size(void) const ELPP_FINAL {
1375  return m_list.size();
1376  }
1377 
1379  virtual inline Container& list(void) ELPP_FINAL {
1380  return m_list;
1381  }
1382 
1384  virtual inline const Container& list(void) const ELPP_FINAL {
1385  return m_list;
1386  }
1387 
1389  virtual void unregisterAll(void) = 0;
1390 
1391  protected:
1392  virtual void deepCopy(const AbstractRegistry<T_Ptr, Container>&) = 0;
1394  unregisterAll();
1395  deepCopy(sr);
1396  }
1397 
1398  private:
1399  Container m_list;
1400 };
1401 
1407 template <typename T_Ptr, typename T_Key = const char*>
1408 class Registry : public AbstractRegistry<T_Ptr, std::unordered_map<T_Key, T_Ptr*>> {
1409  public:
1412 
1413  Registry(void) {}
1414 
1416  Registry(const Registry& sr) : AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>() {
1417  if (this == &sr) {
1418  return;
1419  }
1420  this->reinitDeepCopy(sr);
1421  }
1422 
1427  if (this == &sr) {
1428  return *this;
1429  }
1430  this->reinitDeepCopy(sr);
1431  return *this;
1432  }
1433 
1434  virtual ~Registry(void) {
1435  unregisterAll();
1436  }
1437 
1438  protected:
1439  virtual void unregisterAll(void) ELPP_FINAL {
1440  if (!this->empty()) {
1441  for (auto&& curr : this->list()) {
1442  base::utils::safeDelete(curr.second);
1443  }
1444  this->list().clear();
1445  }
1446  }
1447 
1449  virtual void registerNew(const T_Key& uniqKey, T_Ptr* ptr) ELPP_FINAL {
1450  unregister(uniqKey);
1451  this->list().insert(std::make_pair(uniqKey, ptr));
1452  }
1453 
1455  void unregister(const T_Key& uniqKey) {
1456  T_Ptr* existing = get(uniqKey);
1457  if (existing != nullptr) {
1458  this->list().erase(uniqKey);
1459  base::utils::safeDelete(existing);
1460  }
1461  }
1462 
1464  T_Ptr* get(const T_Key& uniqKey) {
1465  iterator it = this->list().find(uniqKey);
1466  return it == this->list().end()
1467  ? nullptr
1468  : it->second;
1469  }
1470 
1471  private:
1472  virtual void deepCopy(const AbstractRegistry<T_Ptr, std::unordered_map<T_Key, T_Ptr*>>& sr) ELPP_FINAL {
1473  for (const_iterator it = sr.cbegin(); it != sr.cend(); ++it) {
1474  registerNew(it->first, new T_Ptr(*it->second));
1475  }
1476  }
1477 };
1478 
1483 template <typename T_Ptr, typename Pred>
1484 class RegistryWithPred : public AbstractRegistry<T_Ptr, std::vector<T_Ptr*>> {
1485  public:
1488 
1490  }
1491 
1492  virtual ~RegistryWithPred(void) {
1493  unregisterAll();
1494  }
1495 
1497  RegistryWithPred(const RegistryWithPred& sr) : AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>() {
1498  if (this == &sr) {
1499  return;
1500  }
1501  this->reinitDeepCopy(sr);
1502  }
1503 
1508  if (this == &sr) {
1509  return *this;
1510  }
1511  this->reinitDeepCopy(sr);
1512  return *this;
1513  }
1514 
1516  for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) {
1517  os << ELPP_LITERAL(" ") << **it << ELPP_LITERAL("\n");
1518  }
1519  return os;
1520  }
1521 
1522  protected:
1523  virtual void unregisterAll(void) ELPP_FINAL {
1524  if (!this->empty()) {
1525  for (auto&& curr : this->list()) {
1527  }
1528  this->list().clear();
1529  }
1530  }
1531 
1532  virtual void unregister(T_Ptr*& ptr) ELPP_FINAL {
1533  if (ptr) {
1534  iterator iter = this->begin();
1535  for (; iter != this->end(); ++iter) {
1536  if (ptr == *iter) {
1537  break;
1538  }
1539  }
1540  if (iter != this->end() && *iter != nullptr) {
1541  this->list().erase(iter);
1542  base::utils::safeDelete(*iter);
1543  }
1544  }
1545  }
1546 
1547  virtual inline void registerNew(T_Ptr* ptr) ELPP_FINAL {
1548  this->list().push_back(ptr);
1549  }
1550 
1553  template <typename T, typename T2>
1554  T_Ptr* get(const T& arg1, const T2 arg2) {
1555  iterator iter = std::find_if(this->list().begin(), this->list().end(), Pred(arg1, arg2));
1556  if (iter != this->list().end() && *iter != nullptr) {
1557  return *iter;
1558  }
1559  return nullptr;
1560  }
1561 
1562  private:
1563  virtual void deepCopy(const AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>& sr) {
1564  for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) {
1565  registerNew(new T_Ptr(**it));
1566  }
1567  }
1568 };
1569 class Utils {
1570  public:
1571  template <typename T, typename TPtr>
1572  static bool installCallback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
1573  if (mapT->find(id) == mapT->end()) {
1574  mapT->insert(std::make_pair(id, TPtr(new T())));
1575  return true;
1576  }
1577  return false;
1578  }
1579 
1580  template <typename T, typename TPtr>
1581  static void uninstallCallback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
1582  if (mapT->find(id) != mapT->end()) {
1583  mapT->erase(id);
1584  }
1585  }
1586 
1587  template <typename T, typename TPtr>
1588  static T* callback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
1589  typename std::unordered_map<std::string, TPtr>::iterator iter = mapT->find(id);
1590  if (iter != mapT->end()) {
1591  return static_cast<T*>(iter->second.get());
1592  }
1593  return nullptr;
1594  }
1595 };
1596 } // namespace utils
1597 } // namespace base
1601 class Loggable {
1602  public:
1603  virtual ~Loggable(void) {}
1604  virtual void log(el::base::type::ostream_t&) const = 0;
1605  private:
1607  loggable.log(os);
1608  return os;
1609  }
1610 };
1611 namespace base {
1613 class LogFormat : public Loggable {
1614  public:
1615  LogFormat(void);
1617  LogFormat(const LogFormat& logFormat);
1618  LogFormat(LogFormat&& logFormat);
1619  LogFormat& operator=(const LogFormat& logFormat);
1620  virtual ~LogFormat(void) {}
1621  bool operator==(const LogFormat& other);
1622 
1626 
1627  inline Level level(void) const {
1628  return m_level;
1629  }
1630 
1631  inline const base::type::string_t& userFormat(void) const {
1632  return m_userFormat;
1633  }
1634 
1635  inline const base::type::string_t& format(void) const {
1636  return m_format;
1637  }
1638 
1639  inline const std::string& dateTimeFormat(void) const {
1640  return m_dateTimeFormat;
1641  }
1642 
1643  inline base::type::EnumType flags(void) const {
1644  return m_flags;
1645  }
1646 
1647  inline bool hasFlag(base::FormatFlags flag) const {
1648  return base::utils::hasFlag(flag, m_flags);
1649  }
1650 
1651  virtual void log(el::base::type::ostream_t& os) const {
1652  os << m_format;
1653  }
1654 
1655  protected:
1659  virtual void updateDateFormat(std::size_t index, base::type::string_t& currFormat) ELPP_FINAL;
1660 
1662  virtual void updateFormatSpec(void) ELPP_FINAL;
1663 
1664  inline void addFlag(base::FormatFlags flag) {
1665  base::utils::addFlag(flag, &m_flags);
1666  }
1667 
1668  private:
1676  friend class el::Logger; // To resolve loggerId format specifier easily
1677 };
1678 } // namespace base
1680 typedef std::function<std::string(const LogMessage*)> FormatSpecifierValueResolver;
1685  public:
1688  inline const char* formatSpecifier(void) const {
1689  return m_formatSpecifier;
1690  }
1691  inline const FormatSpecifierValueResolver& resolver(void) const {
1692  return m_resolver;
1693  }
1694  inline bool operator==(const char* formatSpecifier) {
1695  return strcmp(m_formatSpecifier, formatSpecifier) == 0;
1696  }
1697 
1698  private:
1699  const char* m_formatSpecifier;
1701 };
1711 class Configuration : public Loggable {
1712  public:
1713  Configuration(const Configuration& c);
1715 
1716  virtual ~Configuration(void) {
1717  }
1718 
1721 
1723  inline Level level(void) const {
1724  return m_level;
1725  }
1726 
1729  return m_configurationType;
1730  }
1731 
1733  inline const std::string& value(void) const {
1734  return m_value;
1735  }
1736 
1740  inline void setValue(const std::string& value) {
1741  m_value = value;
1742  }
1743 
1744  virtual void log(el::base::type::ostream_t& os) const;
1745 
1747  class Predicate {
1748  public:
1750 
1751  bool operator()(const Configuration* conf) const;
1752 
1753  private:
1756  };
1757 
1758  private:
1762 };
1763 
1767 class Configurations : public base::utils::RegistryWithPred<Configuration, Configuration::Predicate> {
1768  public:
1770  Configurations(void);
1771 
1778  Configurations(const std::string& configurationFile, bool useDefaultsForRemaining = true,
1779  Configurations* base = nullptr);
1780 
1781  virtual ~Configurations(void) {
1782  }
1783 
1791 
1800  bool parseFromText(const std::string& configurationsString, Configurations* base = nullptr);
1801 
1805 
1810  bool hasConfiguration(ConfigurationType configurationType);
1811 
1815  bool hasConfiguration(Level level, ConfigurationType configurationType);
1816 
1829  void set(Level level, ConfigurationType configurationType, const std::string& value);
1830 
1833  void set(Configuration* conf);
1834 
1835  inline Configuration* get(Level level, ConfigurationType configurationType) {
1836  base::threading::ScopedLock scopedLock(lock());
1837  return RegistryWithPred<Configuration, Configuration::Predicate>::get(level, configurationType);
1838  }
1839 
1844  inline void setGlobally(ConfigurationType configurationType, const std::string& value) {
1845  setGlobally(configurationType, value, false);
1846  }
1847 
1849  inline void clear(void) {
1850  base::threading::ScopedLock scopedLock(lock());
1851  unregisterAll();
1852  }
1853 
1857  inline const std::string& configurationFile(void) const {
1858  return m_configurationFile;
1859  }
1860 
1862  void setToDefault(void);
1863 
1871  void setRemainingToDefault(void);
1872 
1878  public:
1886  static bool parseFromFile(const std::string& configurationFile, Configurations* sender,
1887  Configurations* base = nullptr);
1888 
1899  static bool parseFromText(const std::string& configurationsString, Configurations* sender,
1900  Configurations* base = nullptr);
1901 
1902  private:
1903  friend class el::Loggers;
1904  static void ignoreComments(std::string* line);
1905  static bool isLevel(const std::string& line);
1906  static bool isComment(const std::string& line);
1907  static inline bool isConfig(const std::string& line);
1908  static bool parseLine(std::string* line, std::string* currConfigStr, std::string* currLevelStr, Level* currLevel,
1909  Configurations* conf);
1910  };
1911 
1912  private:
1915  friend class el::Loggers;
1916 
1918  void unsafeSetIfNotExist(Level level, ConfigurationType configurationType, const std::string& value);
1919 
1921  void unsafeSet(Level level, ConfigurationType configurationType, const std::string& value);
1922 
1925  void setGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel);
1926 
1929  void unsafeSetGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel);
1930 };
1931 
1932 namespace base {
1933 typedef std::shared_ptr<base::type::fstream_t> FileStreamPtr;
1934 typedef std::unordered_map<std::string, FileStreamPtr> LogStreamsReferenceMap;
1942  public:
1947 
1949 
1950  virtual ~TypedConfigurations(void) {
1951  }
1952 
1953  const Configurations* configurations(void) const {
1954  return m_configurations;
1955  }
1956 
1957  bool enabled(Level level);
1958  bool toFile(Level level);
1959  const std::string& filename(Level level);
1960  bool toStandardOutput(Level level);
1961  const base::LogFormat& logFormat(Level level);
1964  bool performanceTracking(Level level = Level::Global);
1966  std::size_t maxLogFileSize(Level level);
1967  std::size_t logFlushThreshold(Level level);
1968 
1969  private:
1971  std::unordered_map<Level, bool> m_enabledMap;
1972  std::unordered_map<Level, bool> m_toFileMap;
1973  std::unordered_map<Level, std::string> m_filenameMap;
1974  std::unordered_map<Level, bool> m_toStandardOutputMap;
1975  std::unordered_map<Level, base::LogFormat> m_logFormatMap;
1976  std::unordered_map<Level, base::SubsecondPrecision> m_subsecondPrecisionMap;
1977  std::unordered_map<Level, bool> m_performanceTrackingMap;
1978  std::unordered_map<Level, base::FileStreamPtr> m_fileStreamMap;
1979  std::unordered_map<Level, std::size_t> m_maxLogFileSizeMap;
1980  std::unordered_map<Level, std::size_t> m_logFlushThresholdMap;
1982 
1983  friend class el::Helpers;
1985  friend class el::base::Writer;
1988 
1989  template <typename Conf_T>
1990  inline Conf_T getConfigByVal(Level level, const std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
1991  base::threading::ScopedLock scopedLock(lock());
1992  return unsafeGetConfigByVal(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
1993  }
1994 
1995  template <typename Conf_T>
1996  inline Conf_T& getConfigByRef(Level level, std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
1997  base::threading::ScopedLock scopedLock(lock());
1998  return unsafeGetConfigByRef(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
1999  }
2000 
2001  template <typename Conf_T>
2002  Conf_T unsafeGetConfigByVal(Level level, const std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
2003  ELPP_UNUSED(confName);
2004  typename std::unordered_map<Level, Conf_T>::const_iterator it = confMap->find(level);
2005  if (it == confMap->end()) {
2006  try {
2007  return confMap->at(Level::Global);
2008  } catch (...) {
2009  ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level ["
2010  << LevelHelper::convertToString(level) << "]"
2011  << std::endl << "Please ensure you have properly configured logger.", false);
2012  return Conf_T();
2013  }
2014  }
2015  return it->second;
2016  }
2017 
2018  template <typename Conf_T>
2019  Conf_T& unsafeGetConfigByRef(Level level, std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
2020  ELPP_UNUSED(confName);
2021  typename std::unordered_map<Level, Conf_T>::iterator it = confMap->find(level);
2022  if (it == confMap->end()) {
2023  try {
2024  return confMap->at(Level::Global);
2025  } catch (...) {
2026  ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level ["
2027  << LevelHelper::convertToString(level) << "]"
2028  << std::endl << "Please ensure you have properly configured logger.", false);
2029  throw; // The exception has to be rethrown, to abort a branch leading to UB.
2030  }
2031  }
2032  return it->second;
2033  }
2034 
2035  template <typename Conf_T>
2036  void setValue(Level level, const Conf_T& value, std::unordered_map<Level, Conf_T>* confMap,
2037  bool includeGlobalLevel = true) {
2038  // If map is empty and we are allowed to add into generic level (Level::Global), do it!
2039  if (confMap->empty() && includeGlobalLevel) {
2040  confMap->insert(std::make_pair(Level::Global, value));
2041  return;
2042  }
2043  // If same value exist in generic level already, dont add it to explicit level
2044  typename std::unordered_map<Level, Conf_T>::iterator it = confMap->find(Level::Global);
2045  if (it != confMap->end() && it->second == value) {
2046  return;
2047  }
2048  // Now make sure we dont double up values if we really need to add it to explicit level
2049  it = confMap->find(level);
2050  if (it == confMap->end()) {
2051  // Value not found for level, add new
2052  confMap->insert(std::make_pair(level, value));
2053  } else {
2054  // Value found, just update value
2055  confMap->at(level) = value;
2056  }
2057  }
2058 
2060  unsigned long getULong(std::string confVal);
2062  void insertFile(Level level, const std::string& fullFilename);
2063  bool unsafeValidateFileRolling(Level level, const PreRollOutCallback& preRollOutCallback);
2064 
2065  inline bool validateFileRolling(Level level, const PreRollOutCallback& preRollOutCallback) {
2066  base::threading::ScopedLock scopedLock(lock());
2067  return unsafeValidateFileRolling(level, preRollOutCallback);
2068  }
2069 };
2071 class HitCounter {
2072  public:
2073  HitCounter(void) :
2074  m_filename(""),
2075  m_lineNumber(0),
2076  m_hitCounts(0) {
2077  }
2078 
2082  m_hitCounts(0) {
2083  }
2084 
2085  HitCounter(const HitCounter& hitCounter) :
2086  m_filename(hitCounter.m_filename),
2087  m_lineNumber(hitCounter.m_lineNumber),
2088  m_hitCounts(hitCounter.m_hitCounts) {
2089  }
2090 
2091  HitCounter& operator=(const HitCounter& hitCounter) {
2092  if (&hitCounter != this) {
2093  m_filename = hitCounter.m_filename;
2094  m_lineNumber = hitCounter.m_lineNumber;
2095  m_hitCounts = hitCounter.m_hitCounts;
2096  }
2097  return *this;
2098  }
2099 
2100  virtual ~HitCounter(void) {
2101  }
2102 
2105  m_filename = filename;
2107  }
2108 
2110  inline void validateHitCounts(std::size_t n) {
2112  m_hitCounts = (n >= 1 ? base::consts::kMaxLogPerCounter % n : 0);
2113  }
2114  ++m_hitCounts;
2115  }
2116 
2117  inline const char* filename(void) const {
2118  return m_filename;
2119  }
2120 
2121  inline base::type::LineNumber lineNumber(void) const {
2122  return m_lineNumber;
2123  }
2124 
2125  inline std::size_t hitCounts(void) const {
2126  return m_hitCounts;
2127  }
2128 
2129  inline void increment(void) {
2130  ++m_hitCounts;
2131  }
2132 
2133  class Predicate {
2134  public:
2136  : m_filename(filename),
2138  }
2139  inline bool operator()(const HitCounter* counter) {
2140  return ((counter != nullptr) &&
2141  (strcmp(counter->m_filename, m_filename) == 0) &&
2142  (counter->m_lineNumber == m_lineNumber));
2143  }
2144 
2145  private:
2146  const char* m_filename;
2148  };
2149 
2150  private:
2151  const char* m_filename;
2153  std::size_t m_hitCounts;
2154 };
2156 class RegisteredHitCounters : public base::utils::RegistryWithPred<base::HitCounter, base::HitCounter::Predicate> {
2157  public:
2160  bool validateEveryN(const char* filename, base::type::LineNumber lineNumber, std::size_t n);
2161 
2164  bool validateAfterN(const char* filename, base::type::LineNumber lineNumber, std::size_t n);
2165 
2168  bool validateNTimes(const char* filename, base::type::LineNumber lineNumber, std::size_t n);
2169 
2171  inline const base::HitCounter* getCounter(const char* filename, base::type::LineNumber lineNumber) {
2172  base::threading::ScopedLock scopedLock(lock());
2173  return get(filename, lineNumber);
2174  }
2175 };
2178  None = 1, NormalLog = 2, SysLog = 4, FileOnlyLog = 8,
2179 };
2180 } // namespace base
2181 template <typename T>
2182 class Callback : protected base::threading::ThreadSafe {
2183  public:
2185  inline bool enabled(void) const {
2186  return m_enabled;
2187  }
2188  inline void setEnabled(bool enabled) {
2189  base::threading::ScopedLock scopedLock(lock());
2190  m_enabled = enabled;
2191  }
2192  protected:
2193  virtual void handle(const T* handlePtr) = 0;
2194  private:
2196 };
2198  public:
2200  inline const LogMessage* logMessage(void) const {
2201  return m_logMessage;
2202  }
2204  return m_dispatchAction;
2205  }
2208  }
2211  }
2212  private:
2215  friend class base::LogDispatcher;
2216 
2217 };
2218 class LogDispatchCallback : public Callback<LogDispatchData> {
2219  protected:
2220  virtual void handle(const LogDispatchData* data);
2222  private:
2223  friend class base::LogDispatcher;
2224  std::unordered_map<std::string, std::unique_ptr<base::threading::Mutex>> m_fileLocks;
2226 };
2227 class PerformanceTrackingCallback : public Callback<PerformanceTrackingData> {
2228  private:
2230 };
2231 class LoggerRegistrationCallback : public Callback<Logger> {
2232  private:
2234 };
2236  public:
2237  LogBuilder() : m_termSupportsColor(base::utils::OS::termSupportsColor()) {}
2238  virtual ~LogBuilder(void) {
2239  ELPP_INTERNAL_INFO(3, "Destroying log builder...")
2240  }
2241  virtual base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const = 0;
2242  void convertToColoredOutput(base::type::string_t* logLine, Level level, Color color);
2243  void setColor(Color color, bool bright);
2244  private:
2247 };
2248 typedef std::shared_ptr<LogBuilder> LogBuilderPtr;
2253  public:
2254  Logger(const std::string& id, base::LogStreamsReferenceMap* logStreamsReference);
2255  Logger(const std::string& id, const Configurations& configurations, base::LogStreamsReferenceMap* logStreamsReference);
2256  Logger(const Logger& logger);
2257  Logger& operator=(const Logger& logger);
2258 
2259  virtual ~Logger(void) {
2261  }
2262 
2263  virtual inline void log(el::base::type::ostream_t& os) const {
2264  os << m_id.c_str();
2265  }
2266 
2269 
2271  void reconfigure(void);
2272 
2273  inline const std::string& id(void) const {
2274  return m_id;
2275  }
2276 
2277  inline const std::string& parentApplicationName(void) const {
2278  return m_parentApplicationName;
2279  }
2280 
2283  }
2284 
2286  return &m_configurations;
2287  }
2288 
2290  return m_typedConfigurations;
2291  }
2292 
2293  static bool isValidId(const std::string& id);
2294 
2296  void flush(void);
2297 
2298  void flush(Level level, base::type::fstream_t* fs);
2299 
2300  inline bool isFlushNeeded(Level level) {
2301  return ++m_unflushedCount.find(level)->second >= m_typedConfigurations->logFlushThreshold(level);
2302  }
2303 
2304  inline LogBuilder* logBuilder(void) const {
2305  return m_logBuilder.get();
2306  }
2307 
2310  }
2311 
2312  inline bool enabled(Level level) const {
2313  return m_typedConfigurations->enabled(level);
2314  }
2315 
2316 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED
2317 # define LOGGER_LEVEL_WRITERS_SIGNATURES(FUNCTION_NAME)\
2318 template <typename T, typename... Args>\
2319 inline void FUNCTION_NAME(const char*, const T&, const Args&...);\
2320 template <typename T>\
2321 inline void FUNCTION_NAME(const T&);
2322 
2323  template <typename T, typename... Args>
2324  inline void verbose(int, const char*, const T&, const Args&...);
2325 
2326  template <typename T>
2327  inline void verbose(int, const T&);
2328 
2329  LOGGER_LEVEL_WRITERS_SIGNATURES(info)
2330  LOGGER_LEVEL_WRITERS_SIGNATURES(debug)
2331  LOGGER_LEVEL_WRITERS_SIGNATURES(warn)
2332  LOGGER_LEVEL_WRITERS_SIGNATURES(error)
2333  LOGGER_LEVEL_WRITERS_SIGNATURES(fatal)
2334  LOGGER_LEVEL_WRITERS_SIGNATURES(trace)
2335 # undef LOGGER_LEVEL_WRITERS_SIGNATURES
2336 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
2337  private:
2344  std::unordered_map<Level, unsigned int> m_unflushedCount;
2347 
2348  friend class el::LogMessage;
2349  friend class el::Loggers;
2350  friend class el::Helpers;
2354  friend class el::base::Writer;
2356  friend class el::base::Storage;
2359 
2360  Logger(void);
2361 
2362 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED
2363  template <typename T, typename... Args>
2364  void log_(Level, int, const char*, const T&, const Args&...);
2365 
2366  template <typename T>
2367  inline void log_(Level, int, const T&);
2368 
2369  template <typename T, typename... Args>
2370  void log(Level, const char*, const T&, const Args&...);
2371 
2372  template <typename T>
2373  inline void log(Level, const T&);
2374 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
2375 
2376  void initUnflushedCount(void);
2377 
2379  return m_stream;
2380  }
2381 
2382  void resolveLoggerFormatSpec(void) const;
2383 };
2384 namespace base {
2386 class RegisteredLoggers : public base::utils::Registry<Logger, std::string> {
2387  public:
2388  explicit RegisteredLoggers(const LogBuilderPtr& defaultLogBuilder);
2389 
2390  virtual ~RegisteredLoggers(void) {
2391  unsafeFlushAll();
2392  }
2393 
2394  inline void setDefaultConfigurations(const Configurations& configurations) {
2395  base::threading::ScopedLock scopedLock(lock());
2396  m_defaultConfigurations.setFromBase(const_cast<Configurations*>(&configurations));
2397  }
2398 
2400  return &m_defaultConfigurations;
2401  }
2402 
2403  Logger* get(const std::string& id, bool forceCreation = true);
2404 
2405  template <typename T>
2407  return base::utils::Utils::installCallback<T, base::type::LoggerRegistrationCallbackPtr>(id,
2409  }
2410 
2411  template <typename T>
2413  base::utils::Utils::uninstallCallback<T, base::type::LoggerRegistrationCallbackPtr>(id, &m_loggerRegistrationCallbacks);
2414  }
2415 
2416  template <typename T>
2418  return base::utils::Utils::callback<T, base::type::LoggerRegistrationCallbackPtr>(id, &m_loggerRegistrationCallbacks);
2419  }
2420 
2421  bool remove(const std::string& id);
2422 
2423  inline bool has(const std::string& id) {
2424  return get(id, false) != nullptr;
2425  }
2426 
2427  inline void unregister(Logger*& logger) {
2428  base::threading::ScopedLock scopedLock(lock());
2430  }
2431 
2433  return &m_logStreamsReference;
2434  }
2435 
2436  inline void flushAll(void) {
2437  base::threading::ScopedLock scopedLock(lock());
2438  unsafeFlushAll();
2439  }
2440 
2441  inline void setDefaultLogBuilder(LogBuilderPtr& logBuilderPtr) {
2442  base::threading::ScopedLock scopedLock(lock());
2443  m_defaultLogBuilder = logBuilderPtr;
2444  }
2445 
2446  private:
2450  std::unordered_map<std::string, base::type::LoggerRegistrationCallbackPtr> m_loggerRegistrationCallbacks;
2451  friend class el::base::Storage;
2452 
2453  void unsafeFlushAll(void);
2454 };
2457  public:
2459 
2462 
2463  inline base::type::VerboseLevel level(void) const {
2464  return m_level;
2465  }
2466 
2467  void clearCategories(void);
2468 
2469  inline void clearModules(void) {
2470  base::threading::ScopedLock scopedLock(lock());
2471  m_modules.clear();
2472  }
2473 
2474  void setCategories(const char* categories, bool clear = true);
2475 
2477 
2478  void setModules(const char* modules);
2479 
2480  bool priority_allowed(int priority, const std::string &category);
2481  bool allowed(Level level, const std::string &category);
2482 
2483  bool allowed(base::type::VerboseLevel vlevel, const char* file);
2484 
2485  inline const std::unordered_map<std::string, base::type::VerboseLevel>& modules(void) const {
2486  return m_modules;
2487  }
2488 
2489  void setFromArgs(const base::utils::CommandLineArgs* commandLineArgs);
2490 
2492  inline bool vModulesEnabled(void) {
2494  }
2495 
2498  }
2499 
2500  inline const std::string &getFilenameCommonPrefix() const {
2501  return m_filenameCommonPrefix;
2502  }
2503 
2504  private:
2507  std::unordered_map<std::string, base::type::VerboseLevel> m_modules;
2508  std::vector<std::pair<std::string, Level>> m_categories;
2509  std::map<std::string, int> m_cached_allowed_categories;
2512 };
2513 } // namespace base
2514 class LogMessage {
2515  public:
2519  m_verboseLevel(verboseLevel), m_logger(logger), m_message(msg ? *msg : logger->stream().str()) {
2520  }
2521  inline Level level(void) const {
2522  return m_level;
2523  }
2524  inline Color color(void) const {
2525  return m_color;
2526  }
2527  inline const std::string& file(void) const {
2528  return m_file;
2529  }
2530  inline base::type::LineNumber line(void) const {
2531  return m_line;
2532  }
2533  inline const std::string& func(void) const {
2534  return m_func;
2535  }
2537  return m_verboseLevel;
2538  }
2539  inline Logger* logger(void) const {
2540  return m_logger;
2541  }
2542  inline const base::type::string_t& message(void) const {
2543  return m_message;
2544  }
2545  private:
2554 };
2555 namespace base {
2556 #if ELPP_ASYNC_LOGGING
2557 class AsyncLogItem {
2558  public:
2559  explicit AsyncLogItem(const LogMessage& logMessage, const LogDispatchData& data, const base::type::string_t& logLine)
2560  : m_logMessage(logMessage), m_dispatchData(data), m_logLine(logLine) {}
2561  virtual ~AsyncLogItem() {}
2562  inline LogMessage* logMessage(void) {
2563  return &m_logMessage;
2564  }
2565  inline LogDispatchData* data(void) {
2566  return &m_dispatchData;
2567  }
2568  inline base::type::string_t logLine(void) {
2569  return m_logLine;
2570  }
2571  private:
2572  LogMessage m_logMessage;
2573  LogDispatchData m_dispatchData;
2574  base::type::string_t m_logLine;
2575 };
2576 class AsyncLogQueue : public base::threading::ThreadSafe {
2577  public:
2578  virtual ~AsyncLogQueue() {
2579  ELPP_INTERNAL_INFO(6, "~AsyncLogQueue");
2580  }
2581 
2582  inline AsyncLogItem next(void) {
2583  base::threading::ScopedLock scopedLock(lock());
2584  AsyncLogItem result = m_queue.front();
2585  m_queue.pop();
2586  return result;
2587  }
2588 
2589  inline void push(const AsyncLogItem& item) {
2590  base::threading::ScopedLock scopedLock(lock());
2591  m_queue.push(item);
2592  }
2593  inline void pop(void) {
2594  base::threading::ScopedLock scopedLock(lock());
2595  m_queue.pop();
2596  }
2597  inline AsyncLogItem front(void) {
2598  base::threading::ScopedLock scopedLock(lock());
2599  return m_queue.front();
2600  }
2601  inline bool empty(void) {
2602  base::threading::ScopedLock scopedLock(lock());
2603  return m_queue.empty();
2604  }
2605  private:
2606  std::queue<AsyncLogItem> m_queue;
2607 };
2608 class IWorker {
2609  public:
2610  virtual ~IWorker() {}
2611  virtual void start() = 0;
2612 };
2613 #endif // ELPP_ASYNC_LOGGING
2614 class Storage : base::NoCopy, public base::threading::ThreadSafe {
2616  public:
2617 #if ELPP_ASYNC_LOGGING
2618  Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker);
2619 #else
2620  explicit Storage(const LogBuilderPtr& defaultLogBuilder);
2621 #endif // ELPP_ASYNC_LOGGING
2622 
2623  virtual ~Storage(void);
2624 
2625  inline bool validateEveryNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t occasion) {
2626  return hitCounters()->validateEveryN(filename, lineNumber, occasion);
2627  }
2628 
2629  inline bool validateAfterNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
2630  return hitCounters()->validateAfterN(filename, lineNumber, n);
2631  }
2632 
2633  inline bool validateNTimesCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
2634  return hitCounters()->validateNTimes(filename, lineNumber, n);
2635  }
2636 
2638  return m_registeredHitCounters;
2639  }
2640 
2642  return m_registeredLoggers;
2643  }
2644 
2645  inline base::VRegistry* vRegistry(void) const {
2646  return m_vRegistry;
2647  }
2648 
2649 #if ELPP_ASYNC_LOGGING
2650  inline base::AsyncLogQueue* asyncLogQueue(void) const {
2651  return m_asyncLogQueue;
2652  }
2653 #endif // ELPP_ASYNC_LOGGING
2654 
2655  inline const base::utils::CommandLineArgs* commandLineArgs(void) const {
2656  return &m_commandLineArgs;
2657  }
2658 
2659  inline void addFlag(LoggingFlag flag) {
2660  base::utils::addFlag(flag, &m_flags);
2661  }
2662 
2663  inline void removeFlag(LoggingFlag flag) {
2665  }
2666 
2667  inline bool hasFlag(LoggingFlag flag) const {
2668  return base::utils::hasFlag(flag, m_flags);
2669  }
2670 
2671  inline base::type::EnumType flags(void) const {
2672  return m_flags;
2673  }
2674 
2676  m_flags = flags;
2677  }
2678 
2679  inline void setPreRollOutCallback(const PreRollOutCallback& callback) {
2680  m_preRollOutCallback = callback;
2681  }
2682 
2683  inline void unsetPreRollOutCallback(void) {
2685  }
2686 
2688  return m_preRollOutCallback;
2689  }
2690 
2691  bool hasCustomFormatSpecifier(const char* formatSpecifier);
2692  void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier);
2693  bool uninstallCustomFormatSpecifier(const char* formatSpecifier);
2694 
2695  const std::vector<CustomFormatSpecifier>* customFormatSpecifiers(void) const {
2696  return &m_customFormatSpecifiers;
2697  }
2698 
2701  }
2702 
2703  inline void setLoggingLevel(Level level) {
2704  m_loggingLevel = level;
2705  }
2706 
2707  template <typename T>
2708  inline bool installLogDispatchCallback(const std::string& id) {
2709  return base::utils::Utils::installCallback<T, base::type::LogDispatchCallbackPtr>(id, &m_logDispatchCallbacks);
2710  }
2711 
2712  template <typename T>
2714  base::utils::Utils::uninstallCallback<T, base::type::LogDispatchCallbackPtr>(id, &m_logDispatchCallbacks);
2715  }
2716  template <typename T>
2717  inline T* logDispatchCallback(const std::string& id) {
2718  return base::utils::Utils::callback<T, base::type::LogDispatchCallbackPtr>(id, &m_logDispatchCallbacks);
2719  }
2720 
2721 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
2722  template <typename T>
2723  inline bool installPerformanceTrackingCallback(const std::string& id) {
2724  return base::utils::Utils::installCallback<T, base::type::PerformanceTrackingCallbackPtr>(id,
2726  }
2727 
2728  template <typename T>
2729  inline void uninstallPerformanceTrackingCallback(const std::string& id) {
2730  base::utils::Utils::uninstallCallback<T, base::type::PerformanceTrackingCallbackPtr>(id,
2732  }
2733 
2734  template <typename T>
2735  inline T* performanceTrackingCallback(const std::string& id) {
2736  return base::utils::Utils::callback<T, base::type::PerformanceTrackingCallbackPtr>(id, &m_performanceTrackingCallbacks);
2737  }
2738 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
2739 
2741  inline void setThreadName(const std::string& name) {
2742  if (name.empty()) return;
2745  }
2746 
2747  inline std::string getThreadName(const std::string& threadId) {
2749  std::unordered_map<std::string, std::string>::const_iterator it = m_threadNames.find(threadId);
2750  if (it == m_threadNames.end()) {
2751  return threadId;
2752  }
2753  return it->second;
2754  }
2755 
2757 
2758  private:
2763 #if ELPP_ASYNC_LOGGING
2764  base::AsyncLogQueue* m_asyncLogQueue;
2765  base::IWorker* m_asyncDispatchWorker;
2766 #endif // ELPP_ASYNC_LOGGING
2769  std::unordered_map<std::string, base::type::LogDispatchCallbackPtr> m_logDispatchCallbacks;
2770  std::unordered_map<std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
2771  std::unordered_map<std::string, std::string> m_threadNames;
2772  std::vector<CustomFormatSpecifier> m_customFormatSpecifiers;
2776 
2777  friend class el::Helpers;
2779  friend class el::LogBuilder;
2781  friend class el::base::Writer;
2784 
2785  void setApplicationArguments(int argc, char** argv);
2786 
2787  inline void setApplicationArguments(int argc, const char** argv) {
2788  setApplicationArguments(argc, const_cast<char**>(argv));
2789  }
2790 };
2792 #define ELPP el::base::Storage::getELPP()
2794  protected:
2795  void handle(const LogDispatchData* data);
2796  private:
2798  void dispatch(base::type::string_t&& rawLinePrefix, base::type::string_t&& rawLinePayload, base::type::string_t&& logLine);
2799 };
2800 #if ELPP_ASYNC_LOGGING
2801 class AsyncLogDispatchCallback : public LogDispatchCallback {
2802  protected:
2803  void handle(const LogDispatchData* data);
2804 };
2805 class AsyncDispatchWorker : public base::IWorker, public base::threading::ThreadSafe {
2806  public:
2807  AsyncDispatchWorker();
2808  virtual ~AsyncDispatchWorker();
2809 
2810  bool clean(void);
2811  void emptyQueue(void);
2812  virtual void start(void);
2813  void handle(AsyncLogItem* logItem);
2814  void run(void);
2815 
2816  void setContinueRunning(bool value) {
2817  base::threading::ScopedLock scopedLock(m_continueRunningLock);
2818  m_continueRunning = value;
2819  }
2820 
2821  bool continueRunning(void) const {
2822  return m_continueRunning;
2823  }
2824  private:
2825  std::condition_variable cv;
2826  bool m_continueRunning;
2827  base::threading::Mutex m_continueRunningLock;
2828 };
2829 #endif // ELPP_ASYNC_LOGGING
2830 } // namespace base
2831 namespace base {
2833  public:
2834  base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const;
2835 };
2838  public:
2839  LogDispatcher(bool proceed, LogMessage* logMessage, base::DispatchAction dispatchAction) :
2840  m_proceed(proceed),
2841  m_logMessage(logMessage),
2842  m_dispatchAction(std::move(dispatchAction)) {
2843  }
2844 
2845  void dispatch(void);
2846 
2847  private:
2851 };
2852 #if defined(ELPP_STL_LOGGING)
2853 namespace workarounds {
2861 template <typename T, typename Container>
2862 class IterableContainer {
2863  public:
2864  typedef typename Container::iterator iterator;
2865  typedef typename Container::const_iterator const_iterator;
2866  IterableContainer(void) {}
2867  virtual ~IterableContainer(void) {}
2868  iterator begin(void) {
2869  return getContainer().begin();
2870  }
2871  iterator end(void) {
2872  return getContainer().end();
2873  }
2874  private:
2875  virtual Container& getContainer(void) = 0;
2876 };
2878 template<typename T, typename Container = std::vector<T>, typename Comparator = std::less<typename Container::value_type>>
2879 class IterablePriorityQueue : public IterableContainer<T, Container>,
2880  public std::priority_queue<T, Container, Comparator> {
2881  public:
2882  IterablePriorityQueue(std::priority_queue<T, Container, Comparator> queue_) {
2883  std::size_t count_ = 0;
2884  while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) {
2885  this->push(queue_.top());
2886  queue_.pop();
2887  }
2888  }
2889  private:
2890  inline Container& getContainer(void) {
2891  return this->c;
2892  }
2893 };
2895 template<typename T, typename Container = std::deque<T>>
2896 class IterableQueue : public IterableContainer<T, Container>, public std::queue<T, Container> {
2897  public:
2898  IterableQueue(std::queue<T, Container> queue_) {
2899  std::size_t count_ = 0;
2900  while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) {
2901  this->push(queue_.front());
2902  queue_.pop();
2903  }
2904  }
2905  private:
2906  inline Container& getContainer(void) {
2907  return this->c;
2908  }
2909 };
2911 template<typename T, typename Container = std::deque<T>>
2912 class IterableStack : public IterableContainer<T, Container>, public std::stack<T, Container> {
2913  public:
2914  IterableStack(std::stack<T, Container> stack_) {
2915  std::size_t count_ = 0;
2916  while (++count_ < base::consts::kMaxLogPerContainer && !stack_.empty()) {
2917  this->push(stack_.top());
2918  stack_.pop();
2919  }
2920  }
2921  private:
2922  inline Container& getContainer(void) {
2923  return this->c;
2924  }
2925 };
2926 } // namespace workarounds
2927 #endif // defined(ELPP_STL_LOGGING)
2928 // Log message builder
2930  public:
2932  void initialize(Logger* logger);
2933 
2934 # define ELPP_SIMPLE_LOG(LOG_TYPE)\
2935 MessageBuilder& operator<<(LOG_TYPE msg) {\
2936 m_logger->stream() << msg;\
2937 if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {\
2938 m_logger->stream() << " ";\
2939 }\
2940 return *this;\
2941 }
2942 
2943  inline MessageBuilder& operator<<(const std::string& msg) {
2944  return operator<<(msg.c_str());
2945  }
2946  ELPP_SIMPLE_LOG(char)
2947  ELPP_SIMPLE_LOG(bool)
2948  ELPP_SIMPLE_LOG(signed short)
2949  ELPP_SIMPLE_LOG(unsigned short)
2950  ELPP_SIMPLE_LOG(signed int)
2951  ELPP_SIMPLE_LOG(unsigned int)
2952  ELPP_SIMPLE_LOG(signed long)
2953  ELPP_SIMPLE_LOG(unsigned long)
2954  ELPP_SIMPLE_LOG(float)
2955  ELPP_SIMPLE_LOG(double)
2956  ELPP_SIMPLE_LOG(char*)
2957  ELPP_SIMPLE_LOG(const char*)
2958  ELPP_SIMPLE_LOG(const void*)
2959  ELPP_SIMPLE_LOG(long double)
2960  inline MessageBuilder& operator<<(const std::wstring& msg) {
2961  return operator<<(msg.c_str());
2962  }
2963  MessageBuilder& operator<<(const wchar_t* msg);
2964  // ostream manipulators
2965  inline MessageBuilder& operator<<(std::ostream& (*OStreamMani)(std::ostream&)) {
2966  m_logger->stream() << OStreamMani;
2967  return *this;
2968  }
2969 #define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp) \
2970 template <typename T> \
2971 inline MessageBuilder& operator<<(const temp<T>& template_inst) { \
2972 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2973 }
2974 #define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp) \
2975 template <typename T1, typename T2> \
2976 inline MessageBuilder& operator<<(const temp<T1, T2>& template_inst) { \
2977 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2978 }
2979 #define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp) \
2980 template <typename T1, typename T2, typename T3> \
2981 inline MessageBuilder& operator<<(const temp<T1, T2, T3>& template_inst) { \
2982 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2983 }
2984 #define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp) \
2985 template <typename T1, typename T2, typename T3, typename T4> \
2986 inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4>& template_inst) { \
2987 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2988 }
2989 #define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp) \
2990 template <typename T1, typename T2, typename T3, typename T4, typename T5> \
2991 inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4, T5>& template_inst) { \
2992 return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2993 }
2994 
2995 #if defined(ELPP_STL_LOGGING)
3003  template <class T, class Container>
3004  inline MessageBuilder& operator<<(const std::queue<T, Container>& queue_) {
3005  base::workarounds::IterableQueue<T, Container> iterableQueue_ =
3006  static_cast<base::workarounds::IterableQueue<T, Container> >(queue_);
3007  return writeIterator(iterableQueue_.begin(), iterableQueue_.end(), iterableQueue_.size());
3008  }
3009  template <class T, class Container>
3010  inline MessageBuilder& operator<<(const std::stack<T, Container>& stack_) {
3011  base::workarounds::IterableStack<T, Container> iterableStack_ =
3012  static_cast<base::workarounds::IterableStack<T, Container> >(stack_);
3013  return writeIterator(iterableStack_.begin(), iterableStack_.end(), iterableStack_.size());
3014  }
3015  template <class T, class Container, class Comparator>
3016  inline MessageBuilder& operator<<(const std::priority_queue<T, Container, Comparator>& priorityQueue_) {
3017  base::workarounds::IterablePriorityQueue<T, Container, Comparator> iterablePriorityQueue_ =
3018  static_cast<base::workarounds::IterablePriorityQueue<T, Container, Comparator> >(priorityQueue_);
3019  return writeIterator(iterablePriorityQueue_.begin(), iterablePriorityQueue_.end(), iterablePriorityQueue_.size());
3020  }
3021  template <class First, class Second>
3022  MessageBuilder& operator<<(const std::pair<First, Second>& pair_) {
3023  m_logger->stream() << ELPP_LITERAL("(");
3024  operator << (static_cast<First>(pair_.first));
3025  m_logger->stream() << ELPP_LITERAL(", ");
3026  operator << (static_cast<Second>(pair_.second));
3027  m_logger->stream() << ELPP_LITERAL(")");
3028  return *this;
3029  }
3030  template <std::size_t Size>
3031  MessageBuilder& operator<<(const std::bitset<Size>& bitset_) {
3032  m_logger->stream() << ELPP_LITERAL("[");
3033  operator << (bitset_.to_string());
3034  m_logger->stream() << ELPP_LITERAL("]");
3035  return *this;
3036  }
3037 # if defined(ELPP_LOG_STD_ARRAY)
3038  template <class T, std::size_t Size>
3039  inline MessageBuilder& operator<<(const std::array<T, Size>& array) {
3040  return writeIterator(array.begin(), array.end(), array.size());
3041  }
3042 # endif // defined(ELPP_LOG_STD_ARRAY)
3043 # if defined(ELPP_LOG_UNORDERED_MAP)
3044  ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_map)
3045  ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_multimap)
3046 # endif // defined(ELPP_LOG_UNORDERED_MAP)
3047 # if defined(ELPP_LOG_UNORDERED_SET)
3048  ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_set)
3049  ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_multiset)
3050 # endif // defined(ELPP_LOG_UNORDERED_SET)
3051 #endif // defined(ELPP_STL_LOGGING)
3052 #if defined(ELPP_QT_LOGGING)
3053  inline MessageBuilder& operator<<(const QString& msg) {
3054 # if defined(ELPP_UNICODE)
3055  m_logger->stream() << msg.toStdWString();
3056 # else
3057  m_logger->stream() << msg.toStdString();
3058 # endif // defined(ELPP_UNICODE)
3059  return *this;
3060  }
3061  inline MessageBuilder& operator<<(const QByteArray& msg) {
3062  return operator << (QString(msg));
3063  }
3064  inline MessageBuilder& operator<<(const QStringRef& msg) {
3065  return operator<<(msg.toString());
3066  }
3067  inline MessageBuilder& operator<<(qint64 msg) {
3068 # if defined(ELPP_UNICODE)
3069  m_logger->stream() << QString::number(msg).toStdWString();
3070 # else
3071  m_logger->stream() << QString::number(msg).toStdString();
3072 # endif // defined(ELPP_UNICODE)
3073  return *this;
3074  }
3075  inline MessageBuilder& operator<<(quint64 msg) {
3076 # if defined(ELPP_UNICODE)
3077  m_logger->stream() << QString::number(msg).toStdWString();
3078 # else
3079  m_logger->stream() << QString::number(msg).toStdString();
3080 # endif // defined(ELPP_UNICODE)
3081  return *this;
3082  }
3083  inline MessageBuilder& operator<<(QChar msg) {
3084  m_logger->stream() << msg.toLatin1();
3085  return *this;
3086  }
3087  inline MessageBuilder& operator<<(const QLatin1String& msg) {
3088  m_logger->stream() << msg.latin1();
3089  return *this;
3090  }
3097  template <typename First, typename Second>
3098  MessageBuilder& operator<<(const QPair<First, Second>& pair_) {
3099  m_logger->stream() << ELPP_LITERAL("(");
3100  operator << (static_cast<First>(pair_.first));
3101  m_logger->stream() << ELPP_LITERAL(", ");
3102  operator << (static_cast<Second>(pair_.second));
3103  m_logger->stream() << ELPP_LITERAL(")");
3104  return *this;
3105  }
3106  template <typename K, typename V>
3107  MessageBuilder& operator<<(const QMap<K, V>& map_) {
3108  m_logger->stream() << ELPP_LITERAL("[");
3109  QList<K> keys = map_.keys();
3110  typename QList<K>::const_iterator begin = keys.begin();
3111  typename QList<K>::const_iterator end = keys.end();
3112  int max_ = static_cast<int>(base::consts::kMaxLogPerContainer); // to prevent warning
3113  for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) {
3114  m_logger->stream() << ELPP_LITERAL("(");
3115  operator << (static_cast<K>(*begin));
3116  m_logger->stream() << ELPP_LITERAL(", ");
3117  operator << (static_cast<V>(map_.value(*begin)));
3118  m_logger->stream() << ELPP_LITERAL(")");
3119  m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator : ELPP_LITERAL(""));
3120  }
3121  if (begin != end) {
3122  m_logger->stream() << ELPP_LITERAL("...");
3123  }
3124  m_logger->stream() << ELPP_LITERAL("]");
3125  return *this;
3126  }
3127  template <typename K, typename V>
3128  inline MessageBuilder& operator<<(const QMultiMap<K, V>& map_) {
3129  operator << (static_cast<QMap<K, V>>(map_));
3130  return *this;
3131  }
3132  template <typename K, typename V>
3133  MessageBuilder& operator<<(const QHash<K, V>& hash_) {
3134  m_logger->stream() << ELPP_LITERAL("[");
3135  QList<K> keys = hash_.keys();
3136  typename QList<K>::const_iterator begin = keys.begin();
3137  typename QList<K>::const_iterator end = keys.end();
3138  int max_ = static_cast<int>(base::consts::kMaxLogPerContainer); // prevent type warning
3139  for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) {
3140  m_logger->stream() << ELPP_LITERAL("(");
3141  operator << (static_cast<K>(*begin));
3142  m_logger->stream() << ELPP_LITERAL(", ");
3143  operator << (static_cast<V>(hash_.value(*begin)));
3144  m_logger->stream() << ELPP_LITERAL(")");
3145  m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator : ELPP_LITERAL(""));
3146  }
3147  if (begin != end) {
3148  m_logger->stream() << ELPP_LITERAL("...");
3149  }
3150  m_logger->stream() << ELPP_LITERAL("]");
3151  return *this;
3152  }
3153  template <typename K, typename V>
3154  inline MessageBuilder& operator<<(const QMultiHash<K, V>& multiHash_) {
3155  operator << (static_cast<QHash<K, V>>(multiHash_));
3156  return *this;
3157  }
3158 #endif // defined(ELPP_QT_LOGGING)
3159 #if defined(ELPP_BOOST_LOGGING)
3160  ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::vector)
3161  ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::stable_vector)
3162  ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::list)
3163  ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::deque)
3164  ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::map)
3165  ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::flat_map)
3167  ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(boost::container::flat_set)
3168 #endif // defined(ELPP_BOOST_LOGGING)
3169 
3178 #define MAKE_CONTAINERELPP_FRIENDLY(ContainerType, SizeMethod, ElementInstance) \
3179 el::base::type::ostream_t& operator<<(el::base::type::ostream_t& ss, const ContainerType& container) {\
3180 const el::base::type::char_t* sep = ELPP->hasFlag(el::LoggingFlag::NewLineForContainer) ? \
3181 ELPP_LITERAL("\n ") : ELPP_LITERAL(", ");\
3182 ContainerType::const_iterator elem = container.begin();\
3183 ContainerType::const_iterator endElem = container.end();\
3184 std::size_t size_ = container.SizeMethod; \
3185 ss << ELPP_LITERAL("[");\
3186 for (std::size_t i = 0; elem != endElem && i < el::base::consts::kMaxLogPerContainer; ++i, ++elem) { \
3187 ss << ElementInstance;\
3188 ss << ((i < size_ - 1) ? sep : ELPP_LITERAL(""));\
3189 }\
3190 if (elem != endElem) {\
3191 ss << ELPP_LITERAL("...");\
3192 }\
3193 ss << ELPP_LITERAL("]");\
3194 return ss;\
3195 }
3196 #if defined(ELPP_WXWIDGETS_LOGGING)
3198 # define ELPP_WX_PTR_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), *(*elem))
3199 # define ELPP_WX_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), (*elem))
3200 # define ELPP_WX_HASH_MAP_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), \
3201 ELPP_LITERAL("(") << elem->first << ELPP_LITERAL(", ") << elem->second << ELPP_LITERAL(")")
3202 #else
3203 # define ELPP_WX_PTR_ENABLED(ContainerType)
3204 # define ELPP_WX_ENABLED(ContainerType)
3205 # define ELPP_WX_HASH_MAP_ENABLED(ContainerType)
3206 #endif // defined(ELPP_WXWIDGETS_LOGGING)
3207  // Other classes
3208  template <class Class>
3209  ELPP_SIMPLE_LOG(const Class&)
3210 #undef ELPP_SIMPLE_LOG
3211 #undef ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG
3212 #undef ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG
3213 #undef ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG
3214 #undef ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG
3215 #undef ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG
3216  private:
3219 
3220  template<class Iterator>
3221  MessageBuilder& writeIterator(Iterator begin_, Iterator end_, std::size_t size_) {
3222  m_logger->stream() << ELPP_LITERAL("[");
3223  for (std::size_t i = 0; begin_ != end_ && i < base::consts::kMaxLogPerContainer; ++i, ++begin_) {
3224  operator << (*begin_);
3225  m_logger->stream() << ((i < size_ - 1) ? m_containerLogSeperator : ELPP_LITERAL(""));
3226  }
3227  if (begin_ != end_) {
3228  m_logger->stream() << ELPP_LITERAL("...");
3229  }
3230  m_logger->stream() << ELPP_LITERAL("]");
3231  if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {
3232  m_logger->stream() << " ";
3233  }
3234  return *this;
3235  }
3236 };
3239  public:
3240  NullWriter(void) {}
3241 
3242  // Null manipulator
3243  inline NullWriter& operator<<(std::ostream& (*)(std::ostream&)) {
3244  return *this;
3245  }
3246 
3247  template <typename T>
3248  inline NullWriter& operator<<(const T&) {
3249  return *this;
3250  }
3251 
3252  inline operator bool() {
3253  return true;
3254  }
3255 };
3258  public:
3259  Writer(Level level, Color color, const char* file, base::type::LineNumber line,
3260  const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog,
3261  base::type::VerboseLevel verboseLevel = 0) :
3262  m_msg(nullptr), m_level(level), m_color(color), m_file(file), m_line(line), m_func(func), m_verboseLevel(verboseLevel),
3263  m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction), m_sync(ELPP->lock()) {
3264  }
3265 
3267  m_msg(msg), m_level(msg != nullptr ? msg->level() : Level::Unknown),
3268  m_line(0), m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction), m_sync(ELPP->lock()) {
3269  }
3270 
3271  virtual ~Writer(void) {
3272  processDispatch();
3273  }
3274 
3275  template <typename T>
3278 #if ELPP_LOGGING_ENABLED
3279  if (m_proceed) {
3280  m_messageBuilder << log;
3281  }
3282 #endif // ELPP_LOGGING_ENABLED
3283  return *this;
3284  }
3285 
3286  template <typename T>
3288  operator<<(const T& log) {
3289 #if ELPP_LOGGING_ENABLED
3290  if (m_proceed) {
3291  m_messageBuilder << log;
3292  }
3293 #endif // ELPP_LOGGING_ENABLED
3294  return *this;
3295  }
3296 
3297  inline Writer& operator<<(std::ostream& (*log)(std::ostream&)) {
3298 #if ELPP_LOGGING_ENABLED
3299  if (m_proceed) {
3300  m_messageBuilder << log;
3301  }
3302 #endif // ELPP_LOGGING_ENABLED
3303  return *this;
3304  }
3305 
3306  inline operator bool() {
3307  return true;
3308  }
3309 
3310  Writer& construct(Logger* logger, bool needLock = true);
3311  Writer& construct(int count, const char* loggerIds, ...);
3312  Writer& construct(const char *loggerId);
3313  protected:
3317  const char* m_file;
3319  const char* m_func;
3325  std::vector<std::string> m_loggerIds;
3327  friend class el::Helpers;
3328 
3329  void initializeLogger(const std::string& loggerId, bool lookup = true, bool needLock = true);
3330  void initializeLogger(Logger *logger, bool needLock = true);
3331  void processDispatch();
3332  void triggerDispatch(void);
3333 };
3334 class PErrorWriter : public base::Writer {
3335  public:
3336  PErrorWriter(Level level, Color color, const char* file, base::type::LineNumber line,
3337  const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog,
3338  base::type::VerboseLevel verboseLevel = 0) :
3339  base::Writer(level, color, file, line, func, dispatchAction, verboseLevel) {
3340  }
3341 
3342  virtual ~PErrorWriter(void);
3343 };
3344 } // namespace base
3345 // Logging from Logger class. Why this is here? Because we have Storage and Writer class available
3346 #if ELPP_VARIADIC_TEMPLATES_SUPPORTED
3347 template <typename T, typename... Args>
3348 void Logger::log_(Level level, int vlevel, const char* s, const T& value, const Args&... args) {
3349  base::MessageBuilder b;
3350  b.initialize(this);
3351  while (*s) {
3353  if (*(s + 1) == base::consts::kFormatSpecifierChar) {
3354  ++s;
3355  } else {
3357  ++s;
3358  b << value;
3359  log_(level, vlevel, ++s, args...);
3360  return;
3361  }
3362  }
3363  }
3364  b << *s++;
3365  }
3366  ELPP_INTERNAL_ERROR("Too many arguments provided. Unable to handle. Please provide more format specifiers", false);
3367 }
3368 template <typename T>
3369 void Logger::log_(Level level, int vlevel, const T& log) {
3370  if (level == Level::Verbose) {
3371  if (ELPP->vRegistry()->allowed(vlevel, __FILE__)) {
3372  base::Writer(Level::Verbose, Color::Default, "FILE", 0, "FUNCTION",
3373  base::DispatchAction::NormalLog, vlevel).construct(this, false) << log;
3374  } else {
3375  stream().str(ELPP_LITERAL(""));
3376  releaseLock();
3377  }
3378  } else {
3379  base::Writer(level, Color::Default, "FILE", 0, "FUNCTION").construct(this, false) << log;
3380  }
3381 }
3382 template <typename T, typename... Args>
3383 inline void Logger::log(Level level, const char* s, const T& value, const Args&... args) {
3384  acquireLock(); // released in Writer!
3385  log_(level, 0, s, value, args...);
3386 }
3387 template <typename T>
3388 inline void Logger::log(Level level, const T& log) {
3389  acquireLock(); // released in Writer!
3390  log_(level, 0, log);
3391 }
3392 # if ELPP_VERBOSE_LOG
3393 template <typename T, typename... Args>
3394 inline void Logger::verbose(int vlevel, const char* s, const T& value, const Args&... args) {
3395  acquireLock(); // released in Writer!
3396  log_(el::Level::Verbose, vlevel, s, value, args...);
3397 }
3398 template <typename T>
3399 inline void Logger::verbose(int vlevel, const T& log) {
3400  acquireLock(); // released in Writer!
3401  log_(el::Level::Verbose, vlevel, log);
3402 }
3403 # else
3404 template <typename T, typename... Args>
3405 inline void Logger::verbose(int, const char*, const T&, const Args&...) {
3406  return;
3407 }
3408 template <typename T>
3409 inline void Logger::verbose(int, const T&) {
3410  return;
3411 }
3412 # endif // ELPP_VERBOSE_LOG
3413 # define LOGGER_LEVEL_WRITERS(FUNCTION_NAME, LOG_LEVEL)\
3414 template <typename T, typename... Args>\
3415 inline void Logger::FUNCTION_NAME(const char* s, const T& value, const Args&... args) {\
3416 log(LOG_LEVEL, s, value, args...);\
3417 }\
3418 template <typename T>\
3419 inline void Logger::FUNCTION_NAME(const T& value) {\
3420 log(LOG_LEVEL, value);\
3421 }
3422 # define LOGGER_LEVEL_WRITERS_DISABLED(FUNCTION_NAME, LOG_LEVEL)\
3423 template <typename T, typename... Args>\
3424 inline void Logger::FUNCTION_NAME(const char*, const T&, const Args&...) {\
3425 return;\
3426 }\
3427 template <typename T>\
3428 inline void Logger::FUNCTION_NAME(const T&) {\
3429 return;\
3430 }
3431 
3432 # if ELPP_INFO_LOG
3433 LOGGER_LEVEL_WRITERS(info, Level::Info)
3434 # else
3435 LOGGER_LEVEL_WRITERS_DISABLED(info, Level::Info)
3436 # endif // ELPP_INFO_LOG
3437 # if ELPP_DEBUG_LOG
3438 LOGGER_LEVEL_WRITERS(debug, Level::Debug)
3439 # else
3440 LOGGER_LEVEL_WRITERS_DISABLED(debug, Level::Debug)
3441 # endif // ELPP_DEBUG_LOG
3442 # if ELPP_WARNING_LOG
3443 LOGGER_LEVEL_WRITERS(warn, Level::Warning)
3444 # else
3445 LOGGER_LEVEL_WRITERS_DISABLED(warn, Level::Warning)
3446 # endif // ELPP_WARNING_LOG
3447 # if ELPP_ERROR_LOG
3448 LOGGER_LEVEL_WRITERS(error, Level::Error)
3449 # else
3450 LOGGER_LEVEL_WRITERS_DISABLED(error, Level::Error)
3451 # endif // ELPP_ERROR_LOG
3452 # if ELPP_FATAL_LOG
3453 LOGGER_LEVEL_WRITERS(fatal, Level::Fatal)
3454 # else
3455 LOGGER_LEVEL_WRITERS_DISABLED(fatal, Level::Fatal)
3456 # endif // ELPP_FATAL_LOG
3457 # if ELPP_TRACE_LOG
3458 LOGGER_LEVEL_WRITERS(trace, Level::Trace)
3459 # else
3460 LOGGER_LEVEL_WRITERS_DISABLED(trace, Level::Trace)
3461 # endif // ELPP_TRACE_LOG
3462 # undef LOGGER_LEVEL_WRITERS
3463 # undef LOGGER_LEVEL_WRITERS_DISABLED
3464 #endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
3465 #if ELPP_COMPILER_MSVC
3466 # define ELPP_VARIADIC_FUNC_MSVC(variadicFunction, variadicArgs) variadicFunction variadicArgs
3467 # define ELPP_VARIADIC_FUNC_MSVC_RUN(variadicFunction, ...) ELPP_VARIADIC_FUNC_MSVC(variadicFunction, (__VA_ARGS__))
3468 # define el_getVALength(...) ELPP_VARIADIC_FUNC_MSVC_RUN(el_resolveVALength, 0, ## __VA_ARGS__,\
3469 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
3470 #else
3471 # if ELPP_COMPILER_CLANG
3472 # define el_getVALength(...) el_resolveVALength(0, __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
3473 # else
3474 # define el_getVALength(...) el_resolveVALength(0, ## __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
3475 # endif // ELPP_COMPILER_CLANG
3476 #endif // ELPP_COMPILER_MSVC
3477 #define el_resolveVALength(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
3478 #define ELPP_WRITE_LOG(writer, level, dispatchAction, ...) \
3479 writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3480 #define ELPP_WRITE_LOG_IF(writer, condition, level, dispatchAction, ...) if (condition) \
3481 writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3482 #define ELPP_WRITE_LOG_EVERY_N(writer, occasion, level, dispatchAction, ...) \
3483 ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion) && \
3484 writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3485 #define ELPP_WRITE_LOG_AFTER_N(writer, n, level, dispatchAction, ...) \
3486 ELPP->validateAfterNCounter(__FILE__, __LINE__, n) && \
3487 writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3488 #define ELPP_WRITE_LOG_N_TIMES(writer, n, level, dispatchAction, ...) \
3489 ELPP->validateNTimesCounter(__FILE__, __LINE__, n) && \
3490 writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3491 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3492 class PerformanceTrackingData {
3493  public:
3494  enum class DataType : base::type::EnumType {
3495  Checkpoint = 1, Complete = 2
3496  };
3497  // Do not use constructor, will run into multiple definition error, use init(PerformanceTracker*)
3498  explicit PerformanceTrackingData(DataType dataType) : m_performanceTracker(nullptr),
3499  m_dataType(dataType), m_firstCheckpoint(false), m_file(""), m_line(0), m_func("") {}
3500  inline const std::string* blockName(void) const;
3501  inline const struct timeval* startTime(void) const;
3502  inline const struct timeval* endTime(void) const;
3503  inline const struct timeval* lastCheckpointTime(void) const;
3504  inline const base::PerformanceTracker* performanceTracker(void) const {
3505  return m_performanceTracker;
3506  }
3507  inline PerformanceTrackingData::DataType dataType(void) const {
3508  return m_dataType;
3509  }
3510  inline bool firstCheckpoint(void) const {
3511  return m_firstCheckpoint;
3512  }
3513  inline std::string checkpointId(void) const {
3514  return m_checkpointId;
3515  }
3516  inline const char* file(void) const {
3517  return m_file;
3518  }
3519  inline base::type::LineNumber line(void) const {
3520  return m_line;
3521  }
3522  inline const char* func(void) const {
3523  return m_func;
3524  }
3525  inline const base::type::string_t* formattedTimeTaken() const {
3526  return &m_formattedTimeTaken;
3527  }
3528  inline const std::string& loggerId(void) const;
3529  private:
3530  base::PerformanceTracker* m_performanceTracker;
3531  base::type::string_t m_formattedTimeTaken;
3532  PerformanceTrackingData::DataType m_dataType;
3533  bool m_firstCheckpoint;
3534  std::string m_checkpointId;
3535  const char* m_file;
3536  base::type::LineNumber m_line;
3537  const char* m_func;
3538  inline void init(base::PerformanceTracker* performanceTracker, bool firstCheckpoint = false) {
3539  m_performanceTracker = performanceTracker;
3540  m_firstCheckpoint = firstCheckpoint;
3541  }
3542 
3543  friend class el::base::PerformanceTracker;
3544 };
3545 namespace base {
3548 class PerformanceTracker : public base::threading::ThreadSafe, public Loggable {
3549  public:
3550  PerformanceTracker(const std::string& blockName,
3552  const std::string& loggerId = std::string(el::base::consts::kPerformanceLoggerId),
3553  bool scopedLog = true, Level level = base::consts::kPerformanceTrackerDefaultLevel);
3555  PerformanceTracker(const PerformanceTracker& t) :
3556  m_blockName(t.m_blockName), m_timestampUnit(t.m_timestampUnit), m_loggerId(t.m_loggerId), m_scopedLog(t.m_scopedLog),
3557  m_level(t.m_level), m_hasChecked(t.m_hasChecked), m_lastCheckpointId(t.m_lastCheckpointId), m_enabled(t.m_enabled),
3558  m_startTime(t.m_startTime), m_endTime(t.m_endTime), m_lastCheckpointTime(t.m_lastCheckpointTime) {
3559  }
3560  virtual ~PerformanceTracker(void);
3562  void checkpoint(const std::string& id = std::string(), const char* file = __FILE__,
3563  base::type::LineNumber line = __LINE__,
3564  const char* func = "");
3565  inline Level level(void) const {
3566  return m_level;
3567  }
3568  private:
3569  std::string m_blockName;
3570  base::TimestampUnit m_timestampUnit;
3571  std::string m_loggerId;
3572  bool m_scopedLog;
3573  Level m_level;
3574  bool m_hasChecked;
3575  std::string m_lastCheckpointId;
3576  bool m_enabled;
3577  struct timeval m_startTime, m_endTime, m_lastCheckpointTime;
3578 
3579  PerformanceTracker(void);
3580 
3581  friend class el::PerformanceTrackingData;
3582  friend class base::DefaultPerformanceTrackingCallback;
3583 
3584  const inline base::type::string_t getFormattedTimeTaken() const {
3585  return getFormattedTimeTaken(m_startTime);
3586  }
3587 
3588  const base::type::string_t getFormattedTimeTaken(struct timeval startTime) const;
3589 
3590  virtual inline void log(el::base::type::ostream_t& os) const {
3591  os << getFormattedTimeTaken();
3592  }
3593 };
3594 class DefaultPerformanceTrackingCallback : public PerformanceTrackingCallback {
3595  protected:
3596  void handle(const PerformanceTrackingData* data) {
3597  m_data = data;
3599  if (m_data->dataType() == PerformanceTrackingData::DataType::Complete) {
3600  ss << ELPP_LITERAL("Executed [") << m_data->blockName()->c_str() << ELPP_LITERAL("] in [") <<
3601  *m_data->formattedTimeTaken() << ELPP_LITERAL("]");
3602  } else {
3603  ss << ELPP_LITERAL("Performance checkpoint");
3604  if (!m_data->checkpointId().empty()) {
3605  ss << ELPP_LITERAL(" [") << m_data->checkpointId().c_str() << ELPP_LITERAL("]");
3606  }
3607  ss << ELPP_LITERAL(" for block [") << m_data->blockName()->c_str() << ELPP_LITERAL("] : [") <<
3608  *m_data->performanceTracker();
3610  && m_data->performanceTracker()->m_hasChecked) {
3611  ss << ELPP_LITERAL(" ([") << *m_data->formattedTimeTaken() << ELPP_LITERAL("] from ");
3612  if (m_data->performanceTracker()->m_lastCheckpointId.empty()) {
3613  ss << ELPP_LITERAL("last checkpoint");
3614  } else {
3615  ss << ELPP_LITERAL("checkpoint '") << m_data->performanceTracker()->m_lastCheckpointId.c_str() << ELPP_LITERAL("'");
3616  }
3617  ss << ELPP_LITERAL(")]");
3618  } else {
3619  ss << ELPP_LITERAL("]");
3620  }
3621  }
3622  el::base::Writer(m_data->performanceTracker()->level(), m_data->file(), m_data->line(), m_data->func()).construct(1,
3623  m_data->loggerId().c_str()) << ss.str();
3624  }
3625  private:
3626  const PerformanceTrackingData* m_data;
3627 };
3628 } // namespace base
3629 inline const std::string* PerformanceTrackingData::blockName() const {
3630  return const_cast<const std::string*>(&m_performanceTracker->m_blockName);
3631 }
3632 inline const struct timeval* PerformanceTrackingData::startTime() const {
3633  return const_cast<const struct timeval*>(&m_performanceTracker->m_startTime);
3634 }
3635 inline const struct timeval* PerformanceTrackingData::endTime() const {
3636  return const_cast<const struct timeval*>(&m_performanceTracker->m_endTime);
3637 }
3638 inline const struct timeval* PerformanceTrackingData::lastCheckpointTime() const {
3639  return const_cast<const struct timeval*>(&m_performanceTracker->m_lastCheckpointTime);
3640 }
3641 inline const std::string& PerformanceTrackingData::loggerId(void) const {
3642  return m_performanceTracker->m_loggerId;
3643 }
3644 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3645 namespace base {
3647 namespace debug {
3648 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3649 class StackTrace : base::NoCopy {
3650  public:
3651  static const unsigned int kMaxStack = 64;
3652  static const unsigned int kStackStart = 2; // We want to skip c'tor and StackTrace::generateNew()
3653  class StackTraceEntry {
3654  public:
3655  StackTraceEntry(std::size_t index, const std::string& loc, const std::string& demang, const std::string& hex,
3656  const std::string& addr);
3657  StackTraceEntry(std::size_t index, const std::string& loc) :
3658  m_index(index),
3659  m_location(loc) {
3660  }
3661  std::size_t m_index;
3662  std::string m_location;
3663  std::string m_demangled;
3664  std::string m_hex;
3665  std::string m_addr;
3666  friend std::ostream& operator<<(std::ostream& ss, const StackTraceEntry& si);
3667 
3668  private:
3669  StackTraceEntry(void);
3670  };
3671 
3672  StackTrace(void) {
3673  generateNew();
3674  }
3675 
3676  virtual ~StackTrace(void) {
3677  }
3678 
3679  inline std::vector<StackTraceEntry>& getLatestStack(void) {
3680  return m_stack;
3681  }
3682 
3683  friend std::ostream& operator<<(std::ostream& os, const StackTrace& st);
3684 
3685  private:
3686  std::vector<StackTraceEntry> m_stack;
3687 
3688  void generateNew(void);
3689 };
3691 class CrashHandler : base::NoCopy {
3692  public:
3693  typedef void (*Handler)(int);
3694 
3695  explicit CrashHandler(bool useDefault);
3696  explicit CrashHandler(const Handler& cHandler) {
3697  setHandler(cHandler);
3698  }
3699  void setHandler(const Handler& cHandler);
3700 
3701  private:
3702  Handler m_handler;
3703 };
3704 #else
3706  public:
3707  explicit CrashHandler(bool) {}
3708 };
3709 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3710 } // namespace debug
3711 } // namespace base
3712 extern base::debug::CrashHandler elCrashHandler;
3713 #define MAKE_LOGGABLE(ClassType, ClassInstance, OutputStreamInstance) \
3714 el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamInstance, const ClassType& ClassInstance)
3715 class SysLogInitializer {
3717  public:
3718  SysLogInitializer(const char* processIdent, int options = 0, int facility = 0) {
3719 #if defined(ELPP_SYSLOG)
3720  openlog(processIdent, options, facility);
3721 #else
3722  ELPP_UNUSED(processIdent);
3723  ELPP_UNUSED(options);
3724  ELPP_UNUSED(facility);
3725 #endif // defined(ELPP_SYSLOG)
3726  }
3727  virtual ~SysLogInitializer(void) {
3728 #if defined(ELPP_SYSLOG)
3729  closelog();
3730 #endif // defined(ELPP_SYSLOG)
3731  }
3732 };
3733 #define ELPP_INITIALIZE_SYSLOG(id, opt, fac) el::SysLogInitializer elSyslogInit(id, opt, fac)
3734 class Helpers : base::StaticClass {
3736  public:
3739  ELPP = storage;
3740  }
3743  return ELPP;
3744  }
3746  static inline void setArgs(int argc, char** argv) {
3747  ELPP->setApplicationArguments(argc, argv);
3748  }
3750  static inline void setArgs(int argc, const char** argv) {
3751  ELPP->setApplicationArguments(argc, const_cast<char**>(argv));
3752  }
3754  static inline void setThreadName(const std::string& name) {
3755  ELPP->setThreadName(name);
3756  }
3757  static inline std::string getThreadName() {
3758  return ELPP->getThreadName(base::threading::getCurrentThreadId());
3759  }
3760 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3761  static inline void setCrashHandler(const el::base::debug::CrashHandler::Handler& crashHandler) {
3765  el::elCrashHandler.setHandler(crashHandler);
3766  }
3769  static void crashAbort(int sig, const char* sourceFile = "", unsigned int long line = 0);
3775  static void logCrashReason(int sig, bool stackTraceIfAvailable = false,
3776  Level level = Level::Fatal, const char* logger = base::consts::kDefaultLoggerId);
3777 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3778  static inline void installPreRollOutCallback(const PreRollOutCallback& callback) {
3781  ELPP->setPreRollOutCallback(callback);
3782  }
3784  static inline void uninstallPreRollOutCallback(void) {
3785  ELPP->unsetPreRollOutCallback();
3786  }
3788  template <typename T>
3789  static inline bool installLogDispatchCallback(const std::string& id) {
3790  return ELPP->installLogDispatchCallback<T>(id);
3791  }
3793  template <typename T>
3794  static inline void uninstallLogDispatchCallback(const std::string& id) {
3795  ELPP->uninstallLogDispatchCallback<T>(id);
3796  }
3797  template <typename T>
3798  static inline T* logDispatchCallback(const std::string& id) {
3799  return ELPP->logDispatchCallback<T>(id);
3800  }
3801 #if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3802  template <typename T>
3804  static inline bool installPerformanceTrackingCallback(const std::string& id) {
3805  return ELPP->installPerformanceTrackingCallback<T>(id);
3806  }
3808  template <typename T>
3809  static inline void uninstallPerformanceTrackingCallback(const std::string& id) {
3810  ELPP->uninstallPerformanceTrackingCallback<T>(id);
3811  }
3812  template <typename T>
3813  static inline T* performanceTrackingCallback(const std::string& id) {
3814  return ELPP->performanceTrackingCallback<T>(id);
3815  }
3816 #endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3817  template <typename T>
3820  el::Logger* logger =
3821  ELPP->registeredLoggers()->get(el::base::consts::kDefaultLoggerId);
3822  if (logger == nullptr) {
3823  return std::string();
3824  }
3826  b.initialize(logger);
3827  logger->acquireLock();
3828  b << templ;
3829 #if defined(ELPP_UNICODE)
3830  std::string s = std::string(logger->stream().str().begin(), logger->stream().str().end());
3831 #else
3832  std::string s = logger->stream().str();
3833 #endif // defined(ELPP_UNICODE)
3834  logger->stream().str(ELPP_LITERAL(""));
3835  logger->releaseLock();
3836  return s;
3837  }
3840  return ELPP->commandLineArgs();
3841  }
3844  static inline void reserveCustomFormatSpecifiers(std::size_t size) {
3845  ELPP->m_customFormatSpecifiers.reserve(size);
3846  }
3848  static inline void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier) {
3849  ELPP->installCustomFormatSpecifier(customFormatSpecifier);
3850  }
3852  static inline bool uninstallCustomFormatSpecifier(const char* formatSpecifier) {
3853  return ELPP->uninstallCustomFormatSpecifier(formatSpecifier);
3854  }
3856  static inline bool hasCustomFormatSpecifier(const char* formatSpecifier) {
3857  return ELPP->hasCustomFormatSpecifier(formatSpecifier);
3858  }
3859  static inline void validateFileRolling(Logger* logger, Level level) {
3860  if (ELPP == nullptr || logger == nullptr) return;
3861  logger->m_typedConfigurations->validateFileRolling(level, ELPP->preRollOutCallback());
3862  }
3863 };
3866  public:
3868  static bool allowed(Level leve, const char* cat);
3870  static Logger* getLogger(const std::string& identity, bool registerIfNotAvailable = true);
3872  static void setDefaultLogBuilder(el::LogBuilderPtr& logBuilderPtr);
3874  template <typename T>
3875  static inline bool installLoggerRegistrationCallback(const std::string& id) {
3876  return ELPP->registeredLoggers()->installLoggerRegistrationCallback<T>(id);
3877  }
3879  template <typename T>
3880  static inline void uninstallLoggerRegistrationCallback(const std::string& id) {
3881  ELPP->registeredLoggers()->uninstallLoggerRegistrationCallback<T>(id);
3882  }
3883  template <typename T>
3884  static inline T* loggerRegistrationCallback(const std::string& id) {
3885  return ELPP->registeredLoggers()->loggerRegistrationCallback<T>(id);
3886  }
3889  static bool unregisterLogger(const std::string& identity);
3891  static bool hasLogger(const std::string& identity);
3893  static Logger* reconfigureLogger(Logger* logger, const Configurations& configurations);
3895  static Logger* reconfigureLogger(const std::string& identity, const Configurations& configurations);
3897  static Logger* reconfigureLogger(const std::string& identity, ConfigurationType configurationType,
3898  const std::string& value);
3900  static void reconfigureAllLoggers(const Configurations& configurations);
3902  static inline void reconfigureAllLoggers(ConfigurationType configurationType, const std::string& value) {
3903  reconfigureAllLoggers(Level::Global, configurationType, value);
3904  }
3906  static void reconfigureAllLoggers(Level level, ConfigurationType configurationType,
3907  const std::string& value);
3909  static void setDefaultConfigurations(const Configurations& configurations,
3910  bool reconfigureExistingLoggers = false);
3912  static const Configurations* defaultConfigurations(void);
3919  static std::vector<std::string>* populateAllLoggerIds(std::vector<std::string>* targetList);
3921  static void configureFromGlobal(const char* globalConfigurationFilePath);
3926  static bool configureFromArg(const char* argKey);
3928  static void flushAll(void);
3930  static inline void addFlag(LoggingFlag flag) {
3931  ELPP->addFlag(flag);
3932  }
3934  static inline void removeFlag(LoggingFlag flag) {
3935  ELPP->removeFlag(flag);
3936  }
3938  static inline bool hasFlag(LoggingFlag flag) {
3939  return ELPP->hasFlag(flag);
3940  }
3943  public:
3946  }
3949  }
3950  private:
3952  };
3955  public:
3958  }
3961  }
3962  private:
3964  };
3966  static void setLoggingLevel(Level level) {
3967  ELPP->setLoggingLevel(level);
3968  }
3970  static void setVerboseLevel(base::type::VerboseLevel level);
3974  static void setVModules(const char* modules);
3976  static void setCategories(const char* categories, bool clear = true);
3978  static std::string getCategories();
3980  static void clearVModules(void);
3982  static void clearCategories(void);
3984  static void setFilenameCommonPrefix(const std::string &prefix);
3986  static const std::string &getFilenameCommonPrefix();
3987 };
3989  public:
3991  static const std::string version(void);
3992 
3994  static const std::string releaseDate(void);
3995 };
3996 } // namespace el
3997 #undef VLOG_IS_ON
3998 #define VLOG_IS_ON(verboseLevel) (ELPP->vRegistry()->allowed(verboseLevel, __FILE__))
4000 #undef TIMED_BLOCK
4001 #undef TIMED_SCOPE
4002 #undef TIMED_SCOPE_IF
4003 #undef TIMED_FUNC
4004 #undef TIMED_FUNC_IF
4005 #undef ELPP_MIN_UNIT
4006 #if defined(ELPP_PERFORMANCE_MICROSECONDS)
4007 # define ELPP_MIN_UNIT el::base::TimestampUnit::Microsecond
4008 #else
4009 # define ELPP_MIN_UNIT el::base::TimestampUnit::Millisecond
4010 #endif // (defined(ELPP_PERFORMANCE_MICROSECONDS))
4011 // Note: Do not surround this definition with null macro because of obj instance
4018 #define TIMED_SCOPE_IF(obj, blockname, condition) el::base::type::PerformanceTrackerPtr obj( condition ? \
4019  new el::base::PerformanceTracker(blockname, ELPP_MIN_UNIT) : nullptr )
4020 #define TIMED_SCOPE(obj, blockname) TIMED_SCOPE_IF(obj, blockname, true)
4021 #define TIMED_BLOCK(obj, blockName) for (struct { int i; el::base::type::PerformanceTrackerPtr timer; } obj = { 0, \
4022  el::base::type::PerformanceTrackerPtr(new el::base::PerformanceTracker(blockName, ELPP_MIN_UNIT)) }; obj.i < 1; ++obj.i)
4023 #define TIMED_FUNC_IF(obj,condition) TIMED_SCOPE_IF(obj, ELPP_FUNC, condition)
4030 #define TIMED_FUNC(obj) TIMED_SCOPE(obj, ELPP_FUNC)
4031 #undef PERFORMANCE_CHECKPOINT
4032 #undef PERFORMANCE_CHECKPOINT_WITH_ID
4033 #define PERFORMANCE_CHECKPOINT(obj) obj->checkpoint(std::string(), __FILE__, __LINE__, ELPP_FUNC)
4034 #define PERFORMANCE_CHECKPOINT_WITH_ID(obj, id) obj->checkpoint(id, __FILE__, __LINE__, ELPP_FUNC)
4035 #undef ELPP_COUNTER
4036 #undef ELPP_COUNTER_POS
4037 #define ELPP_COUNTER (ELPP->hitCounters()->getCounter(__FILE__, __LINE__))
4039 #define ELPP_COUNTER_POS (ELPP_COUNTER == nullptr ? -1 : ELPP_COUNTER->hitCounts())
4041 // Undef levels to support LOG(LEVEL)
4042 #undef INFO
4043 #undef WARNING
4044 #undef DEBUG
4045 #undef ERROR
4046 #undef FATAL
4047 #undef TRACE
4048 #undef VERBOSE
4049 // Undef existing
4050 #undef CINFO
4051 #undef CWARNING
4052 #undef CDEBUG
4053 #undef CFATAL
4054 #undef CERROR
4055 #undef CTRACE
4056 #undef CVERBOSE
4057 #undef CINFO_IF
4058 #undef CWARNING_IF
4059 #undef CDEBUG_IF
4060 #undef CERROR_IF
4061 #undef CFATAL_IF
4062 #undef CTRACE_IF
4063 #undef CVERBOSE_IF
4064 #undef CINFO_EVERY_N
4065 #undef CWARNING_EVERY_N
4066 #undef CDEBUG_EVERY_N
4067 #undef CERROR_EVERY_N
4068 #undef CFATAL_EVERY_N
4069 #undef CTRACE_EVERY_N
4070 #undef CVERBOSE_EVERY_N
4071 #undef CINFO_AFTER_N
4072 #undef CWARNING_AFTER_N
4073 #undef CDEBUG_AFTER_N
4074 #undef CERROR_AFTER_N
4075 #undef CFATAL_AFTER_N
4076 #undef CTRACE_AFTER_N
4077 #undef CVERBOSE_AFTER_N
4078 #undef CINFO_N_TIMES
4079 #undef CWARNING_N_TIMES
4080 #undef CDEBUG_N_TIMES
4081 #undef CERROR_N_TIMES
4082 #undef CFATAL_N_TIMES
4083 #undef CTRACE_N_TIMES
4084 #undef CVERBOSE_N_TIMES
4085 // Normal logs
4086 #if ELPP_INFO_LOG
4087 # define CINFO(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Info, dispatchAction, __VA_ARGS__)
4088 #else
4089 # define CINFO(writer, dispatchAction, ...) el::base::NullWriter()
4090 #endif // ELPP_INFO_LOG
4091 #if ELPP_WARNING_LOG
4092 # define CWARNING(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Warning, dispatchAction, __VA_ARGS__)
4093 #else
4094 # define CWARNING(writer, dispatchAction, ...) el::base::NullWriter()
4095 #endif // ELPP_WARNING_LOG
4096 #if ELPP_DEBUG_LOG
4097 # define CDEBUG(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Debug, dispatchAction, __VA_ARGS__)
4098 #else
4099 # define CDEBUG(writer, dispatchAction, ...) el::base::NullWriter()
4100 #endif // ELPP_DEBUG_LOG
4101 #if ELPP_ERROR_LOG
4102 # define CERROR(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Error, dispatchAction, __VA_ARGS__)
4103 #else
4104 # define CERROR(writer, dispatchAction, ...) el::base::NullWriter()
4105 #endif // ELPP_ERROR_LOG
4106 #if ELPP_FATAL_LOG
4107 # define CFATAL(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4108 #else
4109 # define CFATAL(writer, dispatchAction, ...) el::base::NullWriter()
4110 #endif // ELPP_FATAL_LOG
4111 #if ELPP_TRACE_LOG
4112 # define CTRACE(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Trace, dispatchAction, __VA_ARGS__)
4113 #else
4114 # define CTRACE(writer, dispatchAction, ...) el::base::NullWriter()
4115 #endif // ELPP_TRACE_LOG
4116 #if ELPP_VERBOSE_LOG
4117 # define CVERBOSE(writer, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel)) writer(\
4118 el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
4119 #else
4120 # define CVERBOSE(writer, vlevel, dispatchAction, ...) el::base::NullWriter()
4121 #endif // ELPP_VERBOSE_LOG
4122 // Conditional logs
4123 #if ELPP_INFO_LOG
4124 # define CINFO_IF(writer, condition_, dispatchAction, ...) \
4125 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Info, dispatchAction, __VA_ARGS__)
4126 #else
4127 # define CINFO_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4128 #endif // ELPP_INFO_LOG
4129 #if ELPP_WARNING_LOG
4130 # define CWARNING_IF(writer, condition_, dispatchAction, ...)\
4131 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Warning, dispatchAction, __VA_ARGS__)
4132 #else
4133 # define CWARNING_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4134 #endif // ELPP_WARNING_LOG
4135 #if ELPP_DEBUG_LOG
4136 # define CDEBUG_IF(writer, condition_, dispatchAction, ...)\
4137 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Debug, dispatchAction, __VA_ARGS__)
4138 #else
4139 # define CDEBUG_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4140 #endif // ELPP_DEBUG_LOG
4141 #if ELPP_ERROR_LOG
4142 # define CERROR_IF(writer, condition_, dispatchAction, ...)\
4143 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Error, dispatchAction, __VA_ARGS__)
4144 #else
4145 # define CERROR_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4146 #endif // ELPP_ERROR_LOG
4147 #if ELPP_FATAL_LOG
4148 # define CFATAL_IF(writer, condition_, dispatchAction, ...)\
4149 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Fatal, dispatchAction, __VA_ARGS__)
4150 #else
4151 # define CFATAL_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4152 #endif // ELPP_FATAL_LOG
4153 #if ELPP_TRACE_LOG
4154 # define CTRACE_IF(writer, condition_, dispatchAction, ...)\
4155 ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Trace, dispatchAction, __VA_ARGS__)
4156 #else
4157 # define CTRACE_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4158 #endif // ELPP_TRACE_LOG
4159 #if ELPP_VERBOSE_LOG
4160 # define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel) && (condition_)) writer( \
4161 el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
4162 #else
4163 # define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) el::base::NullWriter()
4164 #endif // ELPP_VERBOSE_LOG
4165 // Occasional logs
4166 #if ELPP_INFO_LOG
4167 # define CINFO_EVERY_N(writer, occasion, dispatchAction, ...)\
4168 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Info, dispatchAction, __VA_ARGS__)
4169 #else
4170 # define CINFO_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4171 #endif // ELPP_INFO_LOG
4172 #if ELPP_WARNING_LOG
4173 # define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...)\
4174 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Warning, dispatchAction, __VA_ARGS__)
4175 #else
4176 # define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4177 #endif // ELPP_WARNING_LOG
4178 #if ELPP_DEBUG_LOG
4179 # define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...)\
4180 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Debug, dispatchAction, __VA_ARGS__)
4181 #else
4182 # define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4183 #endif // ELPP_DEBUG_LOG
4184 #if ELPP_ERROR_LOG
4185 # define CERROR_EVERY_N(writer, occasion, dispatchAction, ...)\
4186 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Error, dispatchAction, __VA_ARGS__)
4187 #else
4188 # define CERROR_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4189 #endif // ELPP_ERROR_LOG
4190 #if ELPP_FATAL_LOG
4191 # define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...)\
4192 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4193 #else
4194 # define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4195 #endif // ELPP_FATAL_LOG
4196 #if ELPP_TRACE_LOG
4197 # define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...)\
4198 ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Trace, dispatchAction, __VA_ARGS__)
4199 #else
4200 # define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4201 #endif // ELPP_TRACE_LOG
4202 #if ELPP_VERBOSE_LOG
4203 # define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...)\
4204 CVERBOSE_IF(writer, ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion), vlevel, dispatchAction, __VA_ARGS__)
4205 #else
4206 # define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...) el::base::NullWriter()
4207 #endif // ELPP_VERBOSE_LOG
4208 // After N logs
4209 #if ELPP_INFO_LOG
4210 # define CINFO_AFTER_N(writer, n, dispatchAction, ...)\
4211 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__)
4212 #else
4213 # define CINFO_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4214 #endif // ELPP_INFO_LOG
4215 #if ELPP_WARNING_LOG
4216 # define CWARNING_AFTER_N(writer, n, dispatchAction, ...)\
4217 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__)
4218 #else
4219 # define CWARNING_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4220 #endif // ELPP_WARNING_LOG
4221 #if ELPP_DEBUG_LOG
4222 # define CDEBUG_AFTER_N(writer, n, dispatchAction, ...)\
4223 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__)
4224 #else
4225 # define CDEBUG_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4226 #endif // ELPP_DEBUG_LOG
4227 #if ELPP_ERROR_LOG
4228 # define CERROR_AFTER_N(writer, n, dispatchAction, ...)\
4229 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__)
4230 #else
4231 # define CERROR_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4232 #endif // ELPP_ERROR_LOG
4233 #if ELPP_FATAL_LOG
4234 # define CFATAL_AFTER_N(writer, n, dispatchAction, ...)\
4235 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4236 #else
4237 # define CFATAL_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4238 #endif // ELPP_FATAL_LOG
4239 #if ELPP_TRACE_LOG
4240 # define CTRACE_AFTER_N(writer, n, dispatchAction, ...)\
4241 ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__)
4242 #else
4243 # define CTRACE_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4244 #endif // ELPP_TRACE_LOG
4245 #if ELPP_VERBOSE_LOG
4246 # define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...)\
4247 CVERBOSE_IF(writer, ELPP->validateAfterNCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__)
4248 #else
4249 # define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter()
4250 #endif // ELPP_VERBOSE_LOG
4251 // N Times logs
4252 #if ELPP_INFO_LOG
4253 # define CINFO_N_TIMES(writer, n, dispatchAction, ...)\
4254 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__)
4255 #else
4256 # define CINFO_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4257 #endif // ELPP_INFO_LOG
4258 #if ELPP_WARNING_LOG
4259 # define CWARNING_N_TIMES(writer, n, dispatchAction, ...)\
4260 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__)
4261 #else
4262 # define CWARNING_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4263 #endif // ELPP_WARNING_LOG
4264 #if ELPP_DEBUG_LOG
4265 # define CDEBUG_N_TIMES(writer, n, dispatchAction, ...)\
4266 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__)
4267 #else
4268 # define CDEBUG_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4269 #endif // ELPP_DEBUG_LOG
4270 #if ELPP_ERROR_LOG
4271 # define CERROR_N_TIMES(writer, n, dispatchAction, ...)\
4272 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__)
4273 #else
4274 # define CERROR_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4275 #endif // ELPP_ERROR_LOG
4276 #if ELPP_FATAL_LOG
4277 # define CFATAL_N_TIMES(writer, n, dispatchAction, ...)\
4278 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4279 #else
4280 # define CFATAL_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4281 #endif // ELPP_FATAL_LOG
4282 #if ELPP_TRACE_LOG
4283 # define CTRACE_N_TIMES(writer, n, dispatchAction, ...)\
4284 ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__)
4285 #else
4286 # define CTRACE_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4287 #endif // ELPP_TRACE_LOG
4288 #if ELPP_VERBOSE_LOG
4289 # define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...)\
4290 CVERBOSE_IF(writer, ELPP->validateNTimesCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__)
4291 #else
4292 # define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter()
4293 #endif // ELPP_VERBOSE_LOG
4294 //
4295 // Custom Loggers - Requires (level, dispatchAction, loggerId/s)
4296 //
4297 // undef existing
4298 #undef CLOG
4299 #undef CLOG_VERBOSE
4300 #undef CVLOG
4301 #undef CLOG_IF
4302 #undef CLOG_VERBOSE_IF
4303 #undef CVLOG_IF
4304 #undef CLOG_EVERY_N
4305 #undef CVLOG_EVERY_N
4306 #undef CLOG_AFTER_N
4307 #undef CVLOG_AFTER_N
4308 #undef CLOG_N_TIMES
4309 #undef CVLOG_N_TIMES
4310 // Normal logs
4311 #define CLOG(LEVEL, ...)\
4312 C##LEVEL(el::base::Writer, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4313 #define CVLOG(vlevel, ...) CVERBOSE(el::base::Writer, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4314 // Conditional logs
4315 #define CLOG_IF(condition, LEVEL, ...)\
4316 C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4317 #define CVLOG_IF(condition, vlevel, ...)\
4318 CVERBOSE_IF(el::base::Writer, condition, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4319 // Hit counts based logs
4320 #define CLOG_EVERY_N(n, LEVEL, ...)\
4321 C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4322 #define CVLOG_EVERY_N(n, vlevel, ...)\
4323 CVERBOSE_EVERY_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4324 #define CLOG_AFTER_N(n, LEVEL, ...)\
4325 C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4326 #define CVLOG_AFTER_N(n, vlevel, ...)\
4327 CVERBOSE_AFTER_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4328 #define CLOG_N_TIMES(n, LEVEL, ...)\
4329 C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4330 #define CVLOG_N_TIMES(n, vlevel, ...)\
4331 CVERBOSE_N_TIMES(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4332 //
4333 // Default Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros
4334 //
4335 // undef existing
4336 #undef LOG
4337 #undef VLOG
4338 #undef LOG_IF
4339 #undef VLOG_IF
4340 #undef LOG_EVERY_N
4341 #undef VLOG_EVERY_N
4342 #undef LOG_AFTER_N
4343 #undef VLOG_AFTER_N
4344 #undef LOG_N_TIMES
4345 #undef VLOG_N_TIMES
4346 #undef ELPP_CURR_FILE_LOGGER_ID
4347 #if defined(ELPP_DEFAULT_LOGGER)
4348 # define ELPP_CURR_FILE_LOGGER_ID ELPP_DEFAULT_LOGGER
4349 #else
4350 # define ELPP_CURR_FILE_LOGGER_ID el::base::consts::kDefaultLoggerId
4351 #endif
4352 #undef ELPP_TRACE
4353 #define ELPP_TRACE CLOG(TRACE, ELPP_CURR_FILE_LOGGER_ID)
4354 // Normal logs
4355 #define LOG(LEVEL) CLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4356 #define VLOG(vlevel) CVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID)
4357 // Conditional logs
4358 #define LOG_IF(condition, LEVEL) CLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4359 #define VLOG_IF(condition, vlevel) CVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4360 // Hit counts based logs
4361 #define LOG_EVERY_N(n, LEVEL) CLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4362 #define VLOG_EVERY_N(n, vlevel) CVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4363 #define LOG_AFTER_N(n, LEVEL) CLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4364 #define VLOG_AFTER_N(n, vlevel) CVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4365 #define LOG_N_TIMES(n, LEVEL) CLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4366 #define VLOG_N_TIMES(n, vlevel) CVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4367 // Generic PLOG()
4368 #undef CPLOG
4369 #undef CPLOG_IF
4370 #undef PLOG
4371 #undef PLOG_IF
4372 #undef DCPLOG
4373 #undef DCPLOG_IF
4374 #undef DPLOG
4375 #undef DPLOG_IF
4376 #define CPLOG(LEVEL, ...)\
4377 C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4378 #define CPLOG_IF(condition, LEVEL, ...)\
4379 C##LEVEL##_IF(el::base::PErrorWriter, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4380 #define DCPLOG(LEVEL, ...)\
4381 if (ELPP_DEBUG_LOG) C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4382 #define DCPLOG_IF(condition, LEVEL, ...)\
4383 C##LEVEL##_IF(el::base::PErrorWriter, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::NormalLog, __VA_ARGS__)
4384 #define PLOG(LEVEL) CPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4385 #define PLOG_IF(condition, LEVEL) CPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4386 #define DPLOG(LEVEL) DCPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4387 #define DPLOG_IF(condition, LEVEL) DCPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4388 // Generic SYSLOG()
4389 #undef CSYSLOG
4390 #undef CSYSLOG_IF
4391 #undef CSYSLOG_EVERY_N
4392 #undef CSYSLOG_AFTER_N
4393 #undef CSYSLOG_N_TIMES
4394 #undef SYSLOG
4395 #undef SYSLOG_IF
4396 #undef SYSLOG_EVERY_N
4397 #undef SYSLOG_AFTER_N
4398 #undef SYSLOG_N_TIMES
4399 #undef DCSYSLOG
4400 #undef DCSYSLOG_IF
4401 #undef DCSYSLOG_EVERY_N
4402 #undef DCSYSLOG_AFTER_N
4403 #undef DCSYSLOG_N_TIMES
4404 #undef DSYSLOG
4405 #undef DSYSLOG_IF
4406 #undef DSYSLOG_EVERY_N
4407 #undef DSYSLOG_AFTER_N
4408 #undef DSYSLOG_N_TIMES
4409 #if defined(ELPP_SYSLOG)
4410 # define CSYSLOG(LEVEL, ...)\
4411 C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__)
4412 # define CSYSLOG_IF(condition, LEVEL, ...)\
4413 C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::SysLog, __VA_ARGS__)
4414 # define CSYSLOG_EVERY_N(n, LEVEL, ...) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4415 # define CSYSLOG_AFTER_N(n, LEVEL, ...) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4416 # define CSYSLOG_N_TIMES(n, LEVEL, ...) C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4417 # define SYSLOG(LEVEL) CSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId)
4418 # define SYSLOG_IF(condition, LEVEL) CSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId)
4419 # define SYSLOG_EVERY_N(n, LEVEL) CSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4420 # define SYSLOG_AFTER_N(n, LEVEL) CSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4421 # define SYSLOG_N_TIMES(n, LEVEL) CSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId)
4422 # define DCSYSLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__)
4423 # define DCSYSLOG_IF(condition, LEVEL, ...)\
4424 C##LEVEL##_IF(el::base::Writer, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::SysLog, __VA_ARGS__)
4425 # define DCSYSLOG_EVERY_N(n, LEVEL, ...)\
4426 if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4427 # define DCSYSLOG_AFTER_N(n, LEVEL, ...)\
4428 if (ELPP_DEBUG_LOG) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4429 # define DCSYSLOG_N_TIMES(n, LEVEL, ...)\
4430 if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4431 # define DSYSLOG(LEVEL) DCSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId)
4432 # define DSYSLOG_IF(condition, LEVEL) DCSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId)
4433 # define DSYSLOG_EVERY_N(n, LEVEL) DCSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4434 # define DSYSLOG_AFTER_N(n, LEVEL) DCSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4435 # define DSYSLOG_N_TIMES(n, LEVEL) DCSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId)
4436 #else
4437 # define CSYSLOG(LEVEL, ...) el::base::NullWriter()
4438 # define CSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter()
4439 # define CSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter()
4440 # define CSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter()
4441 # define CSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter()
4442 # define SYSLOG(LEVEL) el::base::NullWriter()
4443 # define SYSLOG_IF(condition, LEVEL) el::base::NullWriter()
4444 # define SYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter()
4445 # define SYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter()
4446 # define SYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter()
4447 # define DCSYSLOG(LEVEL, ...) el::base::NullWriter()
4448 # define DCSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter()
4449 # define DCSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter()
4450 # define DCSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter()
4451 # define DCSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter()
4452 # define DSYSLOG(LEVEL) el::base::NullWriter()
4453 # define DSYSLOG_IF(condition, LEVEL) el::base::NullWriter()
4454 # define DSYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter()
4455 # define DSYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter()
4456 # define DSYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter()
4457 #endif // defined(ELPP_SYSLOG)
4458 //
4459 // Custom Debug Only Loggers - Requires (level, loggerId/s)
4460 //
4461 // undef existing
4462 #undef DCLOG
4463 #undef DCVLOG
4464 #undef DCLOG_IF
4465 #undef DCVLOG_IF
4466 #undef DCLOG_EVERY_N
4467 #undef DCVLOG_EVERY_N
4468 #undef DCLOG_AFTER_N
4469 #undef DCVLOG_AFTER_N
4470 #undef DCLOG_N_TIMES
4471 #undef DCVLOG_N_TIMES
4472 // Normal logs
4473 #define DCLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG(LEVEL, __VA_ARGS__)
4474 #define DCLOG_VERBOSE(vlevel, ...) if (ELPP_DEBUG_LOG) CLOG_VERBOSE(vlevel, __VA_ARGS__)
4475 #define DCVLOG(vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG(vlevel, __VA_ARGS__)
4476 // Conditional logs
4477 #define DCLOG_IF(condition, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_IF(condition, LEVEL, __VA_ARGS__)
4478 #define DCVLOG_IF(condition, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_IF(condition, vlevel, __VA_ARGS__)
4479 // Hit counts based logs
4480 #define DCLOG_EVERY_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_EVERY_N(n, LEVEL, __VA_ARGS__)
4481 #define DCVLOG_EVERY_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_EVERY_N(n, vlevel, __VA_ARGS__)
4482 #define DCLOG_AFTER_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_AFTER_N(n, LEVEL, __VA_ARGS__)
4483 #define DCVLOG_AFTER_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_AFTER_N(n, vlevel, __VA_ARGS__)
4484 #define DCLOG_N_TIMES(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_N_TIMES(n, LEVEL, __VA_ARGS__)
4485 #define DCVLOG_N_TIMES(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_N_TIMES(n, vlevel, __VA_ARGS__)
4486 //
4487 // Default Debug Only Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros
4488 //
4489 #if !defined(ELPP_NO_DEBUG_MACROS)
4490 // undef existing
4491 #undef DLOG
4492 #undef DVLOG
4493 #undef DLOG_IF
4494 #undef DVLOG_IF
4495 #undef DLOG_EVERY_N
4496 #undef DVLOG_EVERY_N
4497 #undef DLOG_AFTER_N
4498 #undef DVLOG_AFTER_N
4499 #undef DLOG_N_TIMES
4500 #undef DVLOG_N_TIMES
4501 // Normal logs
4502 #define DLOG(LEVEL) DCLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4503 #define DVLOG(vlevel) DCVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID)
4504 // Conditional logs
4505 #define DLOG_IF(condition, LEVEL) DCLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4506 #define DVLOG_IF(condition, vlevel) DCVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4507 // Hit counts based logs
4508 #define DLOG_EVERY_N(n, LEVEL) DCLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4509 #define DVLOG_EVERY_N(n, vlevel) DCVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4510 #define DLOG_AFTER_N(n, LEVEL) DCLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4511 #define DVLOG_AFTER_N(n, vlevel) DCVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4512 #define DLOG_N_TIMES(n, LEVEL) DCLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4513 #define DVLOG_N_TIMES(n, vlevel) DCVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4514 #endif // defined(ELPP_NO_DEBUG_MACROS)
4515 #if !defined(ELPP_NO_CHECK_MACROS)
4516 // Check macros
4517 #undef CCHECK
4518 #undef CPCHECK
4519 #undef CCHECK_EQ
4520 #undef CCHECK_NE
4521 #undef CCHECK_LT
4522 #undef CCHECK_GT
4523 #undef CCHECK_LE
4524 #undef CCHECK_GE
4525 #undef CCHECK_BOUNDS
4526 #undef CCHECK_NOTNULL
4527 #undef CCHECK_STRCASEEQ
4528 #undef CCHECK_STRCASENE
4529 #undef CHECK
4530 #undef PCHECK
4531 #undef CHECK_EQ
4532 #undef CHECK_NE
4533 #undef CHECK_LT
4534 #undef CHECK_GT
4535 #undef CHECK_LE
4536 #undef CHECK_GE
4537 #undef CHECK_BOUNDS
4538 #undef CHECK_NOTNULL
4539 #undef CHECK_STRCASEEQ
4540 #undef CHECK_STRCASENE
4541 #define CCHECK(condition, ...) CLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] "
4542 #define CPCHECK(condition, ...) CPLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] "
4543 #define CHECK(condition) CCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4544 #define PCHECK(condition) CPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4545 #define CCHECK_EQ(a, b, ...) CCHECK(a == b, __VA_ARGS__)
4546 #define CCHECK_NE(a, b, ...) CCHECK(a != b, __VA_ARGS__)
4547 #define CCHECK_LT(a, b, ...) CCHECK(a < b, __VA_ARGS__)
4548 #define CCHECK_GT(a, b, ...) CCHECK(a > b, __VA_ARGS__)
4549 #define CCHECK_LE(a, b, ...) CCHECK(a <= b, __VA_ARGS__)
4550 #define CCHECK_GE(a, b, ...) CCHECK(a >= b, __VA_ARGS__)
4551 #define CCHECK_BOUNDS(val, min, max, ...) CCHECK(val >= min && val <= max, __VA_ARGS__)
4552 #define CHECK_EQ(a, b) CCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID)
4553 #define CHECK_NE(a, b) CCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4554 #define CHECK_LT(a, b) CCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4555 #define CHECK_GT(a, b) CCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4556 #define CHECK_LE(a, b) CCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4557 #define CHECK_GE(a, b) CCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4558 #define CHECK_BOUNDS(val, min, max) CCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID)
4559 #define CCHECK_NOTNULL(ptr, ...) CCHECK((ptr) != nullptr, __VA_ARGS__)
4560 #define CCHECK_STREQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \
4561 << "Check failed: [" << #str1 << " == " << #str2 << "] "
4562 #define CCHECK_STRNE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \
4563 << "Check failed: [" << #str1 << " != " << #str2 << "] "
4564 #define CCHECK_STRCASEEQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \
4565 << "Check failed: [" << #str1 << " == " << #str2 << "] "
4566 #define CCHECK_STRCASENE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \
4567 << "Check failed: [" << #str1 << " != " << #str2 << "] "
4568 #define CHECK_NOTNULL(ptr) CCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID)
4569 #define CHECK_STREQ(str1, str2) CCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4570 #define CHECK_STRNE(str1, str2) CCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4571 #define CHECK_STRCASEEQ(str1, str2) CCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4572 #define CHECK_STRCASENE(str1, str2) CCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4573 #undef DCCHECK
4574 #undef DCCHECK_EQ
4575 #undef DCCHECK_NE
4576 #undef DCCHECK_LT
4577 #undef DCCHECK_GT
4578 #undef DCCHECK_LE
4579 #undef DCCHECK_GE
4580 #undef DCCHECK_BOUNDS
4581 #undef DCCHECK_NOTNULL
4582 #undef DCCHECK_STRCASEEQ
4583 #undef DCCHECK_STRCASENE
4584 #undef DCPCHECK
4585 #undef DCHECK
4586 #undef DCHECK_EQ
4587 #undef DCHECK_NE
4588 #undef DCHECK_LT
4589 #undef DCHECK_GT
4590 #undef DCHECK_LE
4591 #undef DCHECK_GE
4592 #undef DCHECK_BOUNDS_
4593 #undef DCHECK_NOTNULL
4594 #undef DCHECK_STRCASEEQ
4595 #undef DCHECK_STRCASENE
4596 #undef DPCHECK
4597 #define DCCHECK(condition, ...) if (ELPP_DEBUG_LOG) CCHECK(condition, __VA_ARGS__)
4598 #define DCCHECK_EQ(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_EQ(a, b, __VA_ARGS__)
4599 #define DCCHECK_NE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_NE(a, b, __VA_ARGS__)
4600 #define DCCHECK_LT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LT(a, b, __VA_ARGS__)
4601 #define DCCHECK_GT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GT(a, b, __VA_ARGS__)
4602 #define DCCHECK_LE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LE(a, b, __VA_ARGS__)
4603 #define DCCHECK_GE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GE(a, b, __VA_ARGS__)
4604 #define DCCHECK_BOUNDS(val, min, max, ...) if (ELPP_DEBUG_LOG) CCHECK_BOUNDS(val, min, max, __VA_ARGS__)
4605 #define DCCHECK_NOTNULL(ptr, ...) if (ELPP_DEBUG_LOG) CCHECK_NOTNULL((ptr), __VA_ARGS__)
4606 #define DCCHECK_STREQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STREQ(str1, str2, __VA_ARGS__)
4607 #define DCCHECK_STRNE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRNE(str1, str2, __VA_ARGS__)
4608 #define DCCHECK_STRCASEEQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASEEQ(str1, str2, __VA_ARGS__)
4609 #define DCCHECK_STRCASENE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASENE(str1, str2, __VA_ARGS__)
4610 #define DCPCHECK(condition, ...) if (ELPP_DEBUG_LOG) CPCHECK(condition, __VA_ARGS__)
4611 #define DCHECK(condition) DCCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4612 #define DCHECK_EQ(a, b) DCCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID)
4613 #define DCHECK_NE(a, b) DCCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4614 #define DCHECK_LT(a, b) DCCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4615 #define DCHECK_GT(a, b) DCCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4616 #define DCHECK_LE(a, b) DCCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4617 #define DCHECK_GE(a, b) DCCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4618 #define DCHECK_BOUNDS(val, min, max) DCCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID)
4619 #define DCHECK_NOTNULL(ptr) DCCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID)
4620 #define DCHECK_STREQ(str1, str2) DCCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4621 #define DCHECK_STRNE(str1, str2) DCCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4622 #define DCHECK_STRCASEEQ(str1, str2) DCCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4623 #define DCHECK_STRCASENE(str1, str2) DCCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4624 #define DPCHECK(condition) DCPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4625 #endif // defined(ELPP_NO_CHECK_MACROS)
4626 #if defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING)
4627 # define ELPP_USE_DEF_CRASH_HANDLER false
4628 #else
4629 # define ELPP_USE_DEF_CRASH_HANDLER true
4630 #endif // defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING)
4631 #define ELPP_CRASH_HANDLER_INIT
4632 #define ELPP_INIT_EASYLOGGINGPP(val) \
4633 namespace el { \
4634 namespace base { \
4635 el::base::type::StoragePointer elStorage(val); \
4636 } \
4637 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER); \
4638 }
4639 
4640 #if ELPP_ASYNC_LOGGING
4641 # define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()),\
4642 new el::base::AsyncDispatchWorker()))
4643 #else
4644 # define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder())))
4645 #endif // ELPP_ASYNC_LOGGING
4646 #define INITIALIZE_NULL_EASYLOGGINGPP \
4647 namespace el {\
4648 namespace base {\
4649 el::base::type::StoragePointer elStorage;\
4650 }\
4651 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\
4652 }
4653 #define SHARE_EASYLOGGINGPP(initializedStorage)\
4654 namespace el {\
4655 namespace base {\
4656 el::base::type::StoragePointer elStorage(initializedStorage);\
4657 }\
4658 el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\
4659 }
4660 
4661 #if defined(ELPP_UNICODE)
4662 # define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv); std::locale::global(std::locale(""))
4663 #else
4664 # define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv)
4665 #endif // defined(ELPP_UNICODE)
4666 #endif // EASYLOGGINGPP_H
bool priority_allowed(int priority, const std::string &category)
Definition: easylogging++.cc:2222
std::unordered_map< Level, std::size_t > m_logFlushThresholdMap
Definition: easylogging++.h:1980
base::type::LineNumber line(void) const
Definition: easylogging++.h:2530
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++.cc:947
Conf_T & getConfigByRef(Level level, std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition: easylogging++.h:1996
virtual ~Storage(void)
Definition: easylogging++.cc:2341
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++.cc:1300
char char_t
Definition: easylogging++.h:546
static const base::type::EnumType kMinValid
Represents minimum valid level. Useful when iterating through enum.
Definition: easylogging++.h:634
virtual ~ScopedLock(void)
Definition: easylogging++.h:991
double value
Definition: easylogging++.h:797
void setArgs(int argc, const char **argv)
Sets arguments and parses them.
Definition: easylogging++.h:1262
std::shared_ptr< base::type::fstream_t > FileStreamPtr
Definition: easylogging++.h:1933
virtual void log(el::base::type::ostream_t &os) const
Definition: easylogging++.cc:338
Specifies precision of the subsecond part. It should be within range (1-6).
static std::string getCategories()
Gets current categories.
Definition: easylogging++.cc:3531
void setValue(Level level, const Conf_T &value, std::unordered_map< Level, Conf_T > *confMap, bool includeGlobalLevel=true)
Definition: easylogging++.h:2036
void setLogBuilder(const LogBuilderPtr &logBuilder)
Definition: easylogging++.h:2308
Abstract registry (aka repository) that provides basic interface for pointer repository specified by ...
Definition: easylogging++.h:1293
static bool hasLogger(const std::string &identity)
Whether or not logger with id is registered.
Definition: easylogging++.cc:3380
bool toFile(Level level)
Definition: easylogging++.cc:1736
void flush(void)
Flushes logger to sync all log files for all levels.
Definition: easylogging++.cc:778
bool validateNTimes(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
Validates counter for hits are <= n, i.e, registers new if does not exist otherwise updates original ...
Definition: easylogging++.cc:1975
std::unordered_map< Level, bool > m_enabledMap
Definition: easylogging++.h:1971
void setModules(const char *modules)
Definition: easylogging++.cc:2055
virtual const_iterator cbegin(void) const ELPP_FINAL
Definition: easylogging++.h:1359
FormatSpecifierValueResolver m_resolver
Definition: easylogging++.h:1700
base::threading::Mutex m_mutex
Definition: easylogging++.h:1042
Parser used internally to parse configurations from file or text.
Definition: easylogging++.h:1877
std::size_t operator()(const el::Level &l) const
Definition: easylogging++.h:624
const struct el::base::consts::@16 kCrashSignals[]
static int init(int argc, char **argv, struct runtime_vars *v)
Definition: miniupnpd.c:1149
void addFlag(base::FormatFlags flag)
Definition: easylogging++.h:1664
void unregister(const T_Key &uniqKey)
Unregisters single entry mapped to specified unique key.
Definition: easylogging++.h:1455
static const unsigned int kMaxLogPerCounter
Definition: easylogging++.h:765
bool validateEveryN(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
Validates counter for every N, i.e, registers new if does not exist otherwise updates original one...
Definition: easylogging++.cc:1945
const uint32_t T[512]
Definition: groestl_tables.h:36
Determines whether or not corresponding level and logger of logging is enabled You may disable all lo...
Operating System helper static class used internally. You should not use it.
Definition: easylogging++.h:1175
std::string getCategories()
Definition: easylogging++.cc:2214
static void setCategories(const char *categories, bool clear=true)
Sets categories as specified (on the fly)
Definition: easylogging++.cc:3527
const base::LogFormat & logFormat(Level level)
Definition: easylogging++.cc:1748
bool hasFlag(LoggingFlag flag) const
Definition: easylogging++.h:2667
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:3780
std::fstream fstream_t
Definition: easylogging++.h:549
static Logger * reconfigureLogger(Logger *logger, const Configurations &configurations)
Reconfigures specified logger with new configurations.
Definition: easylogging++.cc:3384
Callback(void)
Definition: easylogging++.h:2184
Configuration(const Configuration &c)
Definition: easylogging++.cc:316
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:3718
Determines whether or not performance tracking is enabled.
friend class base::PerformanceTracker
Definition: easylogging++.h:2229
Color color(void) const
Definition: easylogging++.h:2524
virtual void releaseLock(void) ELPP_FINAL
Definition: easylogging++.h:1036
static T * callback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
Definition: easylogging++.h:1588
void uninstallLoggerRegistrationCallback(const std::string &id)
Definition: easylogging++.h:2412
Used to find configuration from configuration (pointers) repository. Avoid using it.
Definition: easylogging++.h:1747
static const char * convertToString(ConfigurationType configurationType)
Converts configuration type to associated const char*.
Definition: easylogging++.cc:263
std::map< std::string, int > m_cached_allowed_categories
Definition: easylogging++.h:2509
void convertToColoredOutput(base::type::string_t *logLine, Level level, Color color)
Definition: easylogging++.cc:662
Creates logger automatically when not available.
static std::vector< std::string > * populateAllLoggerIds(std::vector< std::string > *targetList)
Populates all logger IDs in current repository.
Definition: easylogging++.cc:3443
unsigned long getULong(std::string confVal)
Definition: easylogging++.cc:1831
static const char * kFilePathSeperator
Definition: easylogging++.h:790
int * count
Definition: gmock_stress_test.cc:176
static void removeFlag(LoggingFlag flag)
Removes logging flag used internally.
Definition: easylogging++.h:3934
void flushAll(void)
Definition: easylogging++.h:2436
const std::string & filename(Level level)
Definition: easylogging++.cc:1740
static void buildStrippedFilename(const char *filename, char buff[], const std::string &commonPrefix=NULL, std::size_t limit=base::consts::kSourceFilenameMaxLength)
builds stripped filename and puts it in buff
Definition: easylogging++.cc:931
ScopedLock(M &mutex)
Definition: easylogging++.h:986
ConfigurationType configurationType(void) const
Gets configuration type of current configuration.
Definition: easylogging++.h:1728
const std::string & file(void) const
Definition: easylogging++.h:2527
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++.cc:1318
static std::string extractPathFromFilename(const std::string &fullPath, const char *seperator=base::consts::kFilePathSeperator)
Extracts path of filename with leading slash.
Definition: easylogging++.cc:920
Container::const_iterator const_iterator
Definition: easylogging++.h:1296
static bool hasFlag(LoggingFlag flag)
Determines whether or not certain flag is active.
Definition: easylogging++.h:3938
void setLoggingLevel(Level level)
Definition: easylogging++.h:2703
std::size_t count_
Definition: levin_notify.cpp:694
Information representing errors in application but application will keep running. ...
Definition: easylogging++.h:1569
base::threading::Mutex & fileHandle(const LogDispatchData *data)
Definition: easylogging++.cc:2427
virtual ~Logger(void)
Definition: easylogging++.h:2259
JSON writer.
Definition: fwd.h:95
const base::type::LineNumber m_line
Definition: easylogging++.h:3318
static el::base::type::StoragePointer & getELPP()
Definition: easylogging++.cc:2282
static Level convertFromStringPrefix(const char *levelStr)
Converts from prefix of levelStr to Level.
Definition: easylogging++.cc:231
int i
Definition: pymoduletest.py:23
ELPP_EXPORT base::type::StoragePointer elStorage
Represents log format containing flags and date format. This is used internally to start initial log...
Definition: easylogging++.h:1613
enum upnpconfigoptions id
Definition: options.c:29
NoCopy(void)
Definition: easylogging++.h:571
virtual void handle(const LogDispatchData *data)
Definition: easylogging++.cc:2416
Definition: easylogging++.h:2227
void setDefaultLogBuilder(LogBuilderPtr &logBuilderPtr)
Definition: easylogging++.h:2441
bool m_isConfigured
Definition: easylogging++.h:2342
static const std::string & getFilenameCommonPrefix()
Gets filename common prefix.
Definition: easylogging++.cc:3543
Color m_color
Definition: easylogging++.h:3316
const std::string & value(void) const
Gets string based configuration value.
Definition: easylogging++.h:1733
base::type::stringstream_t & stream(void)
Definition: easylogging++.h:2378
static const base::type::EnumType kMaxValid
Represents maximum valid configuration type. This is used internally and you should not need it...
Definition: easylogging++.h:701
std::pair< epee::span< const std::uint8_t >, epee::span< const std::uint8_t > > get(MDB_cursor &cur, MDB_cursor_op op, std::size_t key, std::size_t value)
Definition: value_stream.cpp:53
static std::string getThreadName()
Definition: easylogging++.h:3757
static void setDefaultLogBuilder(el::LogBuilderPtr &logBuilderPtr)
Changes default log builder for future loggers.
Definition: easylogging++.cc:3372
#define ELPP_EXPORT
Definition: easylogging++.h:252
::std::string string
Definition: gtest-port.h:1097
static base::type::EnumType castToInt(Level level)
Casts level to int, useful for iterating through enum.
Definition: easylogging++.h:638
static std::string & rtrim(std::string &str)
Definition: easylogging++.cc:995
std::ostream ostream_t
Definition: easylogging++.h:550
CrashHandler(bool)
Definition: easylogging++.h:3707
static T * loggerRegistrationCallback(const std::string &id)
Definition: easylogging++.h:3884
l
Definition: base.py:3
virtual const_iterator cend(void) const ELPP_FINAL
Definition: easylogging++.h:1364
MessageBuilder & operator<<(std::ostream &(*OStreamMani)(std::ostream &))
Definition: easylogging++.h:2965
bool enabled(void) const
Definition: easylogging++.h:2185
virtual ~Configurations(void)
Definition: easylogging++.h:1781
static bool pathExists(const char *path, bool considerFile=false)
Determines whether or not provided path exist in current file system.
Definition: easylogging++.cc:863
virtual ~LogFormat(void)
Definition: easylogging++.h:1620
std::unordered_map< std::string, base::type::PerformanceTrackingCallbackPtr > m_performanceTrackingCallbacks
Definition: easylogging++.h:2770
bool validateNTimesCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
Definition: easylogging++.h:2633
#define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp)
Definition: easylogging++.h:2969
const std::string & configurationFile(void) const
Gets configuration file used in parsing this configurations.
Definition: easylogging++.h:1857
void build(Configurations *configurations)
Definition: easylogging++.cc:1776
Definition: easylogging++.h:2218
t
Definition: console.py:33
static void setThreadName(const std::string &name)
Sets thread name for current thread. Requires std::thread.
Definition: easylogging++.h:3754
#define ELPP
Definition: easylogging++.h:2792
base::type::VerboseLevel level(void) const
Definition: easylogging++.h:2463
friend base::type::ostream_t & operator<<(base::type::ostream_t &os, const RegistryWithPred &sr)
Definition: easylogging++.h:1515
static bool uninstallCustomFormatSpecifier(const char *formatSpecifier)
Uninstalls user defined format specifier and handler.
Definition: easylogging++.h:3852
LogFormat & operator=(const LogFormat &logFormat)
Definition: easylogging++.cc:1572
Predicate(Level level, ConfigurationType configurationType)
Used to find configuration from configuration (pointers) repository. Avoid using it.
Definition: easylogging++.cc:345
static char * convertAndAddToBuff(std::size_t n, int len, char *buf, const char *bufLim, bool zeroPadded=true)
Definition: easylogging++.cc:1091
std::shared_ptr< LogDispatchCallback > LogDispatchCallbackPtr
Definition: easylogging++.h:561
static bool createPath(const std::string &path)
Creates specified path on file system.
Definition: easylogging++.cc:880
static void setVerboseLevel(base::type::VerboseLevel level)
Sets verbose level on the fly.
Definition: easylogging++.cc:3509
base::RegisteredHitCounters * hitCounters(void) const
Definition: easylogging++.h:2637
Informational events most useful for developers to debug application.
base::type::VerboseLevel m_level
Definition: easylogging++.h:2505
const base::MillisecondsWidth & millisecondsWidth(Level level=Level::Global)
Definition: easylogging++.cc:1756
Severe error information that will presumably abort application.
base::threading::Mutex m_threadNamesLock
Definition: easylogging++.h:2774
std::size_t hitCounts(void) const
Definition: easylogging++.h:2125
SubsecondPrecision(void)
Definition: easylogging++.h:867
friend base::type::ostream_t & operator<<(base::type::ostream_t &os, const CommandLineArgs &c)
Definition: easylogging++.cc:1474
Main entry point of each logging.
Definition: easylogging++.h:3257
std::enable_if< std::is_integral< T >::value, Writer & >::type operator<<(T log)
Definition: easylogging++.h:3277
ConfigurationType m_configurationType
Definition: easylogging++.h:1760
static Level castFromInt(base::type::EnumType l)
Casts int(ushort) to level, useful for iterating through enum.
Definition: easylogging++.h:642
Base of thread safe class, this class is inheritable-only.
Definition: easylogging++.h:1033
bool parseFromFile(const std::string &configurationFile, Configurations *base=nullptr)
Parses configuration from file.
Definition: easylogging++.cc:371
void insertFile(Level level, const std::string &fullFilename)
Definition: easylogging++.cc:1885
ConfigurationType m_configurationType
Definition: easylogging++.h:1755
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++.cc:3422
void setGlobally(ConfigurationType configurationType, const std::string &value)
Sets configuration for all levels.
Definition: easylogging++.h:1844
base::type::fstream_t * fileStream(Level level)
Definition: easylogging++.cc:1764
NullWriter(void)
Definition: easylogging++.h:3240
std::string data
Definition: base58.cpp:37
Easylogging++ entry namespace.
Definition: easylogging++.cc:27
Scoped lock for compiler that dont yet support std::lock_guard.
Definition: easylogging++.h:984
Definition: easylogging++.h:3705
Container m_list
Definition: easylogging++.h:1399
std::vector< std::pair< std::string, Level > > m_categories
Definition: easylogging++.h:2508
virtual void updateFormatSpec(void) ELPP_FINAL
Updates level from format. This is so that we dont have to do it at log-writing-time. It uses m_format and m_level.
Definition: easylogging++.cc:1668
Base of Easylogging++ friendly class.
Definition: easylogging++.h:1601
Level m_level
Definition: easylogging++.h:1669
LoggingFlag
Flags used while writing logs. This flags are set by user.
Definition: easylogging++.h:725
int type
Definition: superscalar.cpp:50
const std::string & dateTimeFormat(void) const
Definition: easylogging++.h:1639
bool operator==(const char *formatSpecifier)
Definition: easylogging++.h:1694
Makes sure we have new line for each container log entry.
SubsecondPrecision MillisecondsWidth
Type alias of SubsecondPrecision.
Definition: easylogging++.h:882
const char * s
Definition: minissdp.c:596
Disables comparing performance tracker&#39;s checkpoints.
Definition: enums.h:67
Conf_T & unsafeGetConfigByRef(Level level, std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition: easylogging++.h:2019
void setFlags(base::type::EnumType flags)
Definition: easylogging++.h:2675
Color m_color
Definition: easylogging++.h:2547
static const unsigned int kMaxLogPerContainer
Definition: easylogging++.h:766
Level level(void) const
Definition: easylogging++.h:1627
static bool allowed(Level leve, const char *cat)
Determines whether logging will occur at this level and category.
Definition: easylogging++.cc:3360
Definition: easylogging++.h:2832
HitCounter(void)
Definition: easylogging++.h:2073
Definition: easylogging++.h:2133
unsigned long int LineNumber
Definition: easylogging++.h:559
static std::string getCurrentThreadId(void)
Gets ID of currently running threading in windows systems. On unix, nothing is returned.
Definition: easylogging++.h:1048
unsigned int m_offset
Definition: easylogging++.h:877
int m_width
Definition: easylogging++.h:876
base::threading::internal::Mutex Mutex
Definition: easylogging++.h:999
Definition: easylogging++.h:2514
def run(t, blocks)
Definition: block_weight.py:35
static bool isComment(const std::string &line)
Definition: easylogging++.cc:545
const char * filename(void) const
Definition: easylogging++.h:2117
std::unordered_map< Level, bool > m_performanceTrackingMap
Definition: easylogging++.h:1977
#define ELPP_INTERNAL_INFO(lvl, msg)
Definition: easylogging++.h:221
static std::string currentHost(void)
Gets current host name or computer name.
Definition: easylogging++.cc:1234
static char * clearBuff(char buff[], std::size_t lim)
Definition: easylogging++.cc:1112
static const char * convertToString(Level level)
Converts level to associated const char*.
Definition: easylogging++.cc:193
virtual void registerNew(T_Ptr *ptr) ELPP_FINAL
Definition: easylogging++.h:1547
virtual iterator end(void) ELPP_FINAL
Definition: easylogging++.h:1353
RegistryWithPred(const RegistryWithPred &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
Definition: easylogging++.h:1497
base::VRegistry * m_vRegistry
Definition: easylogging++.h:2762
std::unordered_map< Level, std::string > m_filenameMap
Definition: easylogging++.h:1973
base::RegisteredLoggers * m_registeredLoggers
Definition: easylogging++.h:2760
Represents unknown level.
tools::wallet2::message_signature_result_t result
Definition: signature.cpp:62
base::type::string_t m_format
Definition: easylogging++.h:1671
Definition: easylogging++.h:2231
bool toStandardOutput(Level level)
Definition: easylogging++.cc:1744
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.
Definition: easylogging++.h:1439
Level
Represents enumeration for severity level used to determine level of logging.
Definition: easylogging++.h:591
AbstractRegistry(AbstractRegistry &&sr)
Move constructor that is useful for base classes.
Definition: easylogging++.h:1302
static char * wcharPtrToCharPtr(const wchar_t *line)
Converst wchar* to char* NOTE: Need to free return value after use!
Definition: easylogging++.cc:1120
RegistryWithPred< T_Ptr, Pred >::iterator iterator
Definition: easylogging++.h:1486
Level m_level
Definition: easylogging++.h:2546
args
Definition: build_protob.py:10
void clearModules(void)
Definition: easylogging++.h:2469
base::DispatchAction m_dispatchAction
Definition: easylogging++.h:2850
const char * name
Definition: easylogging++.h:810
virtual ~Registry(void)
Definition: easylogging++.h:1434
const char * brief
Definition: easylogging++.h:811
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:3819
LogBuilder()
Definition: easylogging++.h:2237
static char * addToBuff(const char *str, char *buf, const char *bufLim)
Definition: easylogging++.cc:1106
void setApplicationArguments(int argc, const char **argv)
Definition: easylogging++.h:2787
T * logDispatchCallback(const std::string &id)
Definition: easylogging++.h:2717
void setColor(Color color, bool bright)
Definition: easylogging++.cc:692
virtual void unregister(T_Ptr *&ptr) ELPP_FINAL
Definition: easylogging++.h:1532
bool uninstallCustomFormatSpecifier(const char *formatSpecifier)
Definition: easylogging++.cc:2374
static std::size_t getSizeOfFile(base::type::fstream_t *fs)
Gets size of file provided in stream.
Definition: easylogging++.cc:853
virtual ~Configuration(void)
Definition: easylogging++.h:1716
FormatFlags
Format flags used to determine specifiers that are active for performance improvements.
Definition: easylogging++.h:847
bool m_termSupportsColor
Definition: easylogging++.h:2245
void resolveLoggerFormatSpec(void) const
Definition: easylogging++.cc:811
LogBuilderPtr m_logBuilder
Definition: easylogging++.h:2346
virtual ~Writer(void)
Definition: easylogging++.h:3271
std::unordered_map< Level, base::FileStreamPtr > m_fileStreamMap
Definition: easylogging++.h:1978
M * m_mutex
Definition: easylogging++.h:995
const int max_
Definition: gmock-cardinalities.cc:89
static std::string currentUser(void)
Gets current username.
Definition: easylogging++.cc:1221
static void setVModules(const char *modules)
Sets vmodules as specified (on the fly)
Definition: easylogging++.cc:3517
Determines log file (full path) to write logs to for correponding level and logger.
virtual ~ThreadSafe(void)
Definition: easylogging++.h:1040
void lock(void)
Definition: easylogging++.h:951
virtual void log(el::base::type::ostream_t &os) const
Definition: easylogging++.h:2263
base::type::LineNumber m_line
Definition: easylogging++.h:2549
base::TypedConfigurations * m_typedConfigurations
Definition: easylogging++.h:2339
void installCustomFormatSpecifier(const CustomFormatSpecifier &customFormatSpecifier)
Definition: easylogging++.cc:2366
Writes nothing - Used when certain log is disabled.
Definition: easylogging++.h:3238
base::type::LineNumber m_lineNumber
Definition: easylogging++.h:2147
LogMessage(Level level, Color color, const std::string &file, base::type::LineNumber line, const std::string &func, base::type::VerboseLevel verboseLevel, Logger *logger, const base::type::string_t *msg=nullptr)
Definition: easylogging++.h:2516
Mutex(void)
Definition: easylogging++.h:931
Container::iterator iterator
Definition: easylogging++.h:1295
static const unsigned int kDefaultSubsecondPrecision
Definition: easylogging++.h:767
Loggers repository.
Definition: easylogging++.h:2386
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
Definition: gmock-generated-matchers.h:481
Conf_T getConfigByVal(Level level, const std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition: easylogging++.h:1990
virtual ~LogBuilder(void)
Definition: easylogging++.h:2238
bool enabled(Level level) const
Definition: easylogging++.h:2312
#define ELPP_INTERNAL_ERROR(msg, pe)
Definition: easylogging++.h:207
void setFromArgs(const base::utils::CommandLineArgs *commandLineArgs)
Definition: easylogging++.cc:2263
Adds spaces b/w logs that separated by left-shift operator.
void setFilenameCommonPrefix(const std::string &prefix)
Definition: easylogging++.h:2496
bool hasConfiguration(ConfigurationType configurationType)
Determines whether or not specified configuration type exists in the repository.
Definition: easylogging++.cc:403
base::type::string_t build(const LogMessage *logMessage, bool appendNewLine) const
Definition: easylogging++.cc:2779
std::unordered_map< std::string, std::string > m_paramsWithValue
Definition: easylogging++.h:1283
Internal helper class that prevent copy constructor for class.
Definition: easylogging++.h:569
String utilities helper class used internally. You should not use it.
Definition: easylogging++.h:1104
CommandLineArgs(int argc, const char **argv)
Definition: easylogging++.h:1254
virtual ~Loggable(void)
Definition: easylogging++.h:1603
static void defaultPreRollOutCallback(const char *, std::size_t)
Definition: easylogging++.h:841
static const int kCrashSignalsCount
Definition: easylogging++.h:836
virtual void log(el::base::type::ostream_t &os) const
Definition: easylogging++.h:1651
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++.cc:2892
Information that can be highly useful and vary with verbose logging level.
void setDispatchAction(base::DispatchAction dispatchAction)
Definition: easylogging++.h:2209
Determines format of logging corresponding level and logger.
static void removeFlag(Enum e, base::type::EnumType *flag)
Definition: easylogging++.h:916
static void setStorage(base::type::StoragePointer storage)
Shares logging repository (base::Storage)
Definition: easylogging++.h:3738
RegisteredLoggers(const LogBuilderPtr &defaultLogBuilder)
Definition: easylogging++.cc:1990
CustomFormatSpecifier(const char *formatSpecifier, const FormatSpecifierValueResolver &resolver)
Definition: easylogging++.h:1686
Disable VModules extensions.
#define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp)
Definition: easylogging++.h:2974
static void installCustomFormatSpecifier(const CustomFormatSpecifier &customFormatSpecifier)
Installs user defined format specifier and handler.
Definition: easylogging++.h:3848
PErrorWriter(Level level, Color color, const char *file, base::type::LineNumber line, const char *func, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog, base::type::VerboseLevel verboseLevel=0)
Definition: easylogging++.h:3336
LogBuilderPtr m_defaultLogBuilder
Definition: easylogging++.h:2447
static std::string & replaceAll(std::string &str, char replaceWhat, char replaceWith)
Replaces all instances of replaceWhat with &#39;replaceWith&#39;. Original variable is changed for performanc...
Definition: easylogging++.cc:1014
std::unique_ptr< el::base::PerformanceTracker > PerformanceTrackerPtr
Definition: easylogging++.h:564
e
Definition: pymoduletest.py:79
friend class el::base::PerformanceTracker
Definition: easylogging++.h:2782
virtual ~AbstractRegistry(void)
Definition: easylogging++.h:1344
static bool contains(const char *str, char c)
Returns true if c exist in str.
Definition: easylogging++.cc:1083
const base::SubsecondPrecision & subsecondPrecision(Level level=Level::Global)
Definition: easylogging++.cc:1752
virtual ~Mutex(void)
Definition: easylogging++.h:943
friend el::base::type::ostream_t & operator<<(el::base::type::ostream_t &os, const Loggable &loggable)
Definition: easylogging++.h:1606
modules
Definition: check_missing_rpc_methods.py:19
static base::TypedConfigurations defaultTypedConfigurations(void)
Default typed configuration based on existing defaultConf.
Definition: easylogging++.cc:3437
base::type::EnumType m_flags
Definition: easylogging++.h:2761
bool parseFromText(const std::string &configurationsString, Configurations *base=nullptr)
Parse configurations from configuration string.
Definition: easylogging++.cc:385
virtual std::size_t size(void) const ELPP_FINAL
Definition: easylogging++.h:1374
SubsecondPrecision(int width)
Definition: easylogging++.h:870
base::TypedConfigurations * typedConfigurations(void)
Definition: easylogging++.h:2289
const base::type::string_t & format(void) const
Definition: easylogging++.h:1635
void unlock(void)
Definition: easylogging++.h:967
static bool isValidId(const std::string &id)
Definition: easylogging++.cc:769
void addFlag(LoggingFlag flag)
Definition: easylogging++.h:2659
const struct el::base::consts::@15 kTimeFormats[]
static std::enable_if< std::is_pointer< T * >::value, void >::type safeDelete(T *&pointer)
Deletes memory safely and points to null.
Definition: easylogging++.h:889
Writer & operator<<(std::ostream &(*log)(std::ostream &))
Definition: easylogging++.h:3297
bool validateEveryNCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t occasion)
Definition: easylogging++.h:2625
std::unordered_map< Level, unsigned int > m_unflushedCount
Definition: easylogging++.h:2344
A pointer registry mechanism to manage memory and provide search functionalities. (predicate version)...
Definition: easylogging++.h:1484
virtual void deepCopy(const AbstractRegistry< T_Ptr, Container > &)=0
const char * m_func
Definition: easylogging++.h:3319
static std::string & trim(std::string &str)
Definition: easylogging++.cc:1002
LogDispatcher(bool proceed, LogMessage *logMessage, base::DispatchAction dispatchAction)
Definition: easylogging++.h:2839
bool try_lock(void)
Definition: easylogging++.h:959
LogMessage * m_logMessage
Definition: easylogging++.h:2849
bool operator==(const SubsecondPrecision &ssPrec)
Definition: easylogging++.h:873
void initUnflushedCount(void)
Definition: easylogging++.cc:802
TypedConfigurations(Configurations *configurations, base::LogStreamsReferenceMap *logStreamsReference)
Constructor to initialize (construct) the object off el::Configurations.
Definition: easylogging++.cc:1719
Definition: readline_buffer.h:9
std::unordered_map< std::string, FileStreamPtr > LogStreamsReferenceMap
Definition: easylogging++.h:1934
std::vector< std::string > m_params
Definition: easylogging++.h:1284
std::shared_ptr< PerformanceTrackingCallback > PerformanceTrackingCallbackPtr
Definition: easylogging++.h:562
static base::type::EnumType And(Enum e, base::type::EnumType flag)
Definition: easylogging++.h:899
void dispatch(base::type::string_t &&rawLinePrefix, base::type::string_t &&rawLinePayload, base::type::string_t &&logLine)
Definition: easylogging++.cc:2593
std::unordered_map< Level, bool > m_toStandardOutputMap
Definition: easylogging++.h:1974
bool hasCustomFormatSpecifier(const char *formatSpecifier)
Definition: easylogging++.cc:2360
LogMessage * m_msg
Definition: easylogging++.h:3314
std::string resolveFilename(const std::string &filename)
Definition: easylogging++.cc:1846
static const Level kPerformanceTrackerDefaultLevel
Definition: easylogging++.h:795
static void forEachLevel(base::type::EnumType *startIndex, const std::function< bool(void)> &fn)
Applies specified function to each level starting from startIndex.
Definition: easylogging++.cc:251
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++.cc:1064
base::LogStreamsReferenceMap m_logStreamsReference
Definition: easylogging++.h:2449
Logger * m_logger
Definition: easylogging++.h:3321
static void uninstallLogDispatchCallback(const std::string &id)
Uninstalls log dispatch callback.
Definition: easylogging++.h:3794
Registry & operator=(const Registry &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
Definition: easylogging++.h:1426
const char * m_filename
Definition: easylogging++.h:2151
base::type::EnumType flags(void) const
Definition: easylogging++.h:1643
virtual void handle(const T *handlePtr)=0
static bool isConfig(const std::string &line)
Definition: easylogging++.cc:549
Preserves time format and does not convert it to sec, hour etc (performance tracking only) ...
#define ELPP_SIMPLE_LOG(LOG_TYPE)
Definition: easylogging++.h:2934
void clear(void)
Clears repository so that all the configurations are unset.
Definition: easylogging++.h:1849
unsigned int EnumType
Definition: easylogging++.h:557
std::function< std::string(const LogMessage *)> FormatSpecifierValueResolver
Resolving function for format specifier.
Definition: easylogging++.h:1680
~ScopedAddFlag(void)
Definition: easylogging++.h:3947
Registry< T_Ptr, T_Key >::const_iterator const_iterator
Definition: easylogging++.h:1411
::std::wstring wstring
Definition: gtest-port.h:1103
static base::type::EnumType castToInt(ConfigurationType configurationType)
Casts configuration type to int, useful for iterating through enum.
Definition: easylogging++.h:703
base::LogStreamsReferenceMap * m_logStreamsReference
Definition: easylogging++.h:2345
virtual void updateDateFormat(std::size_t index, base::type::string_t &currFormat) ELPP_FINAL
Updates date time format if available in currFormat.
Definition: easylogging++.cc:1641
std::size_t size(void) const
Returns total number of arguments. This exclude argv[0].
Definition: easylogging++.cc:1470
void init(int width)
Definition: easylogging++.cc:1510
bool validateFileRolling(Level level, const PreRollOutCallback &preRollOutCallback)
Definition: easylogging++.h:2065
Logger * m_logger
Definition: easylogging++.h:3217
static const char * kDefaultLoggerId
Definition: easylogging++.h:772
bool has(const std::string &id)
Definition: easylogging++.h:2423
static void log()
Definition: logging.cpp:81
base::threading::internal::ScopedLock< base::threading::Mutex > ScopedLock
Definition: easylogging++.h:1000
void setLevel(base::type::VerboseLevel level)
Sets verbose level. Accepted range is 0-9.
Definition: easylogging++.cc:2047
Definition: easylogging++.h:2197
HitCounter(const HitCounter &hitCounter)
Definition: easylogging++.h:2085
const char * m_formatSpecifier
Definition: easylogging++.h:1699
static void setFilenameCommonPrefix(const std::string &prefix)
Sets filename common prefix.
Definition: easylogging++.cc:3539
Static class that contains helper functions for el::ConfigurationType.
Definition: easylogging++.h:696
bool operator!=(const AbstractRegistry< T_Ptr, Container > &other)
Definition: easylogging++.h:1322
Definition: easylogging++.h:3334
bool isFlushNeeded(Level level)
Definition: easylogging++.h:2300
virtual void unregisterAll(void)=0
Unregisters all the pointers from current repository.
bool allowed(Level level, const std::string &category)
Definition: easylogging++.cc:2219
virtual void log(el::base::type::ostream_t &) const =0
const char * m_filename
Definition: easylogging++.h:2146
base::type::EnumType flags(void) const
Definition: easylogging++.h:2671
static char * parseFormat(char *buf, std::size_t bufSz, const char *format, const struct tm *tInfo, std::size_t msec, const base::SubsecondPrecision *ssPrec)
Definition: easylogging++.cc:1357
std::string m_id
Definition: easylogging++.h:2338
bool m_enabled
Definition: easylogging++.h:2195
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++.cc:304
static ConfigurationType convertFromString(const char *configStr)
Converts from configStr to ConfigurationType.
Definition: easylogging++.cc:295
void unsafeSet(Level level, ConfigurationType configurationType, const std::string &value)
Thread unsafe set.
Definition: easylogging++.cc:624
static void addFlag(Enum e, base::type::EnumType *flag)
Definition: easylogging++.h:912
friend class el::base::PerformanceTracker
Definition: easylogging++.h:2357
void unsetPreRollOutCallback(void)
Definition: easylogging++.h:2683
bool operator()(const HitCounter *counter)
Definition: easylogging++.h:2139
static void setArgs(int argc, const char **argv)
Sets application arguments and figures out whats active for logging and whats not.
Definition: easylogging++.h:3750
Storage(const LogBuilderPtr &defaultLogBuilder)
Definition: easylogging++.cc:2292
static std::string & toUpper(std::string &str)
Converts string to uppercase.
Definition: easylogging++.cc:1050
base::DispatchAction m_dispatchAction
Definition: easylogging++.h:2214
static bool isDigit(char c)
Checks if character is digit. Dont use libc implementation of it to prevent locale issues...
Definition: easylogging++.h:1107
void reconfigure(void)
Reconfigures logger using existing configurations.
Definition: easylogging++.cc:764
static const std::string releaseDate(void)
Release date of current version.
Definition: easylogging++.cc:3553
Adds flag and removes it when scope goes out.
Definition: easylogging++.h:3942
unsigned short VerboseLevel
Definition: easylogging++.h:558
void unregister(Logger *&logger)
Definition: easylogging++.h:2427
#define ELPP_UNUSED(x)
Definition: easylogging++.h:240
void setEnabled(bool enabled)
Definition: easylogging++.h:2188
A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate vers...
Definition: easylogging++.h:1408
static void clearCategories(void)
Clears categories.
Definition: easylogging++.cc:3535
const std::string & parentApplicationName(void) const
Definition: easylogging++.h:2277
static void flushAll(void)
Flushes all loggers for all levels - Be careful if you dont know how many loggers are registered...
Definition: easylogging++.cc:3505
RegistryWithPred & operator=(const RegistryWithPred &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
Definition: easylogging++.h:1507
static const std::size_t kSourceFilenameMaxLength
Definition: easylogging++.h:793
Definition: easylogging++.h:2929
int
Definition: pymoduletest.py:17
static void reconfigureAllLoggers(const Configurations &configurations)
Reconfigures all the existing loggers with new configurations.
Definition: easylogging++.cc:3405
set
Definition: gmock_class.py:44
Static helpers to deal with loggers and their configurations.
Definition: easylogging++.h:3865
std::string m_currentUser
Definition: easylogging++.h:1674
base::threading::Mutex m_customFormatSpecifiersLock
Definition: easylogging++.h:2773
bool installLogDispatchCallback(const std::string &id)
Definition: easylogging++.h:2708
static bool hasFlag(Enum e, base::type::EnumType flag)
Definition: easylogging++.h:920
Configurations(void)
Default constructor with empty repository.
Definition: easylogging++.cc:356
std::unordered_map< std::string, std::string > m_threadNames
Definition: easylogging++.h:2771
base::type::ostream_t & operator<<(base::type::ostream_t &os, const CommandLineArgs &c)
Definition: easylogging++.cc:1474
Contains utilities for cross-platform date/time. This class make use of el::base::utils::Str.
Definition: easylogging++.h:1217
ScopedAddFlag(LoggingFlag flag)
Definition: easylogging++.h:3944
void unsafeSetGlobally(ConfigurationType configurationType, const std::string &value, bool includeGlobalLevel)
Sets configurations (Unsafely) for all levels including Level::Global if includeGlobalLevel is true...
Definition: easylogging++.cc:648
static const char kFormatSpecifierCharValue
Definition: easylogging++.h:763
bool unsafeValidateFileRolling(Level level, const PreRollOutCallback &preRollOutCallback)
Definition: easylogging++.cc:1924
std::unordered_map< Level, base::LogFormat > m_logFormatMap
Definition: easylogging++.h:1975
Configurations with data types.
Definition: easylogging++.h:1941
bool performanceTracking(Level level=Level::Global)
Definition: easylogging++.cc:1760
MessageBuilder & writeIterator(Iterator begin_, Iterator end_, std::size_t size_)
Definition: easylogging++.h:3221
static void setLoggingLevel(Level level)
Sets hierarchy for logging. Needs to enable logging flag (HierarchicalLogging)
Definition: easylogging++.h:3966
static bool termSupportsColor(void)
Whether or not terminal supports colors.
Definition: easylogging++.cc:1247
virtual ~TypedConfigurations(void)
Definition: easylogging++.h:1950
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.
Definition: easylogging++.h:1523
std::vector< std::string > m_loggerIds
Definition: easylogging++.h:3325
Configurations * m_configurations
Definition: easylogging++.h:1970
void setPreRollOutCallback(const PreRollOutCallback &callback)
Definition: easylogging++.h:2679
bool m_isFromFile
Definition: easylogging++.h:1914
static void gettimeofday(struct timeval *tv)
Cross platform gettimeofday for Windows and unix platform. This can be used to determine current micr...
Definition: easylogging++.cc:1256
#define false
Definition: stdbool.h:37
virtual ~CommandLineArgs(void)
Definition: easylogging++.h:1260
base::utils::CommandLineArgs m_commandLineArgs
Definition: easylogging++.h:2767
net::dandelionpp::connection_map map_
Definition: levin_notify.cpp:587
const base::type::char_t * unit
Definition: easylogging++.h:798
PreRollOutCallback m_preRollOutCallback
Definition: easylogging++.h:2768
std::shared_ptr< LogBuilder > LogBuilderPtr
Definition: easylogging++.h:2248
LoggingFlag m_flag
Definition: easylogging++.h:3963
virtual void acquireLock(void) ELPP_FINAL
Definition: easylogging++.h:1035
const base::HitCounter * getCounter(const char *filename, base::type::LineNumber lineNumber)
Gets hit counter registered at specified position.
Definition: easylogging++.h:2171
Alias of SubsecondPrecision (for backward compatibility)
Make terminal output colorful for supported terminals.
#define ELPP_LITERAL(txt)
Definition: easylogging++.h:539
HitCounter & operator=(const HitCounter &hitCounter)
Definition: easylogging++.h:2091
static MDB_envinfo info
Definition: mdb_load.c:37
Repository for hit counters used across the application.
Definition: easylogging++.h:2156
void removeFlag(LoggingFlag flag)
Definition: easylogging++.h:2663
Configurations m_defaultConfigurations
Definition: easylogging++.h:2448
static void replaceFirstWithEscape(base::type::string_t &str, const base::type::string_t &replaceWhat, const base::type::string_t &replaceWith)
Definition: easylogging++.cc:1030
static const int kTimeFormatsCount
Definition: easylogging++.h:807
virtual ~SysLogInitializer(void)
Definition: easylogging++.h:3727
bool installLoggerRegistrationCallback(const std::string &id)
Definition: easylogging++.h:2406
LogFormat(void)
Definition: easylogging++.cc:1536
static void configureFromGlobal(const char *globalConfigurationFilePath)
Sets configurations from global configuration file.
Definition: easylogging++.cc:3452
LogBuilder * logBuilder(void) const
Definition: easylogging++.h:2304
Logger * logger(void) const
Definition: easylogging++.h:2539
static const std::string getBashOutput(const char *command)
Runs command on terminal and returns the output.
Definition: easylogging++.cc:1169
base::type::LineNumber lineNumber(void) const
Definition: easylogging++.h:2121
const char * buf
Definition: slow_memmem.cpp:73
bool validateAfterNCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
Definition: easylogging++.h:2629
User-provided custom format specifier.
Definition: easylogging++.h:1684
Writer(Level level, Color color, const char *file, base::type::LineNumber line, const char *func, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog, base::type::VerboseLevel verboseLevel=0)
Definition: easylogging++.h:3259
void validateHitCounts(std::size_t n)
Validates hit counts and resets it if necessary.
Definition: easylogging++.h:2110
Useful when application has potentially harmful situtaions.
Definition: easylogging++.h:1077
void handle(const LogDispatchData *data)
Definition: easylogging++.cc:2448
int numb
Definition: easylogging++.h:809
static bool wildCardMatch(const char *str, const char *pattern)
Matches wildcards, &#39;*&#39; and &#39;?&#39; only supported.
Definition: easylogging++.cc:964
std::string string_t
Definition: easylogging++.h:547
When handling crashes by default, detailed crash reason will be logged as well.
static bool cStringEq(const char *s1, const char *s2)
Compares cstring equality - uses strcmp.
Definition: easylogging++.cc:1058
DispatchAction
Action to be taken for dispatching.
Definition: easylogging++.h:2177
void setThreadName(const std::string &name)
Sets thread name for current thread. Requires std::thread.
Definition: easylogging++.h:2741
Enables strict file rolling.
std::size_t maxLogFileSize(Level level)
Definition: easylogging++.cc:1768
static base::type::StoragePointer storage()
Definition: easylogging++.h:3742
void unsafeFlushAll(void)
Definition: easylogging++.cc:2032
void setApplicationArguments(int argc, char **argv)
Definition: easylogging++.cc:2385
Conf_T unsafeGetConfigByVal(Level level, const std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition: easylogging++.h:2002
std::unordered_map< std::string, std::unique_ptr< base::threading::Mutex > > m_fileLocks
Definition: easylogging++.h:2224
static void uninstallPreRollOutCallback(void)
Uninstalls pre rollout callback.
Definition: easylogging++.h:3784
const char * m_file
Definition: easylogging++.h:3317
NullWriter & operator<<(const T &)
Definition: easylogging++.h:3248
const char * detail
Definition: easylogging++.h:812
virtual void deepCopy(const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr *>> &sr) ELPP_FINAL
Definition: easylogging++.h:1472
std::string m_parentApplicationName
Definition: easylogging++.h:2341
void setRemainingToDefault(void)
Lets you set the remaining configurations to default.
Definition: easylogging++.cc:465
static void uninstallLoggerRegistrationCallback(const std::string &id)
Uninstalls log dispatch callback.
Definition: easylogging++.h:3880
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++.cc:1197
virtual Container & list(void) ELPP_FINAL
Returns underlying container by reference.
Definition: easylogging++.h:1379
Removes flag and add it when scope goes out.
Definition: easylogging++.h:3954
base::Storage * StoragePointer
Definition: easylogging++.h:560
const base::type::string_t & userFormat(void) const
Definition: easylogging++.h:1631
static T * logDispatchCallback(const std::string &id)
Definition: easylogging++.h:3798
#define si(y, x, c)
Definition: aesb.c:48
const char *const str
Definition: portlistingparse.c:23
MessageBuilder & operator<<(const std::string &msg)
Definition: easylogging++.h:2943
const std::string & id(void) const
Definition: easylogging++.h:2273
Definition: base.py:1
std::string m_func
Definition: easylogging++.h:2550
std::vector< int8_t > m_data
Definition: base58.cpp:76
LoggingFlag m_flag
Definition: easylogging++.h:3951
Level m_level
Definition: easylogging++.h:1754
Flushes log with every log-entry (performance sensative) - Disabled by default.
static void reserveCustomFormatSpecifiers(std::size_t size)
Reserve space for custom format specifiers for performance.
Definition: easylogging++.h:3844
const char * formatSpecifier(void) const
Definition: easylogging++.h:1688
const base::utils::CommandLineArgs * commandLineArgs(void) const
Definition: easylogging++.h:2655
static struct ::tm * buildTimeInfo(struct timeval *currTime, struct ::tm *timeInfo)
Definition: easylogging++.cc:1331
bool operator()(const Configuration *conf) const
Definition: easylogging++.cc:350
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++.cc:3376
void configure(const Configurations &configurations)
Configures the logger using specified configurations.
Definition: easylogging++.cc:745
Definition: document.h:406
Thread-safe Configuration repository.
Definition: easylogging++.h:1767
CommandLineArgs(int argc, char **argv)
Definition: easylogging++.h:1257
Writer(LogMessage *msg, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog)
Definition: easylogging++.h:3266
Mainly useful to represent current progress of application.
std::string m_filenameCommonPrefix
Definition: easylogging++.h:2511
void setValue(const std::string &value)
Set string based configuration value.
Definition: easylogging++.h:1740
key identity()
Definition: rctOps.h:73
Level level(void) const
Gets level of current configuration.
Definition: easylogging++.h:1723
bool enabled(Level level)
Definition: easylogging++.cc:1732
base::threading::Mutex m_fileLocksMapLock
Definition: easylogging++.h:2225
static bool installCallback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
Definition: easylogging++.h:1572
base::threading::Mutex & customFormatSpecifiersLock()
Definition: easylogging++.h:2699
const T & move(const T &t)
Definition: gtest-port.h:1317
bool hasFlag(base::FormatFlags flag) const
Definition: easylogging++.h:1647
Dispatches log messages.
Definition: easylogging++.h:2837
bool hasParam(const char *paramKey) const
Return true if arguments has a param (not having a value) i,e without &#39;=&#39;.
Definition: easylogging++.cc:1462
Predicate(const char *filename, base::type::LineNumber lineNumber)
Definition: easylogging++.h:2135
static const base::LogStreamsReferenceMap * logStreamsReference(void)
Returns log stream reference pointer if needed by user.
Definition: easylogging++.cc:3433
static void reconfigureAllLoggers(ConfigurationType configurationType, const std::string &value)
Reconfigures single configuration for all the loggers.
Definition: easylogging++.h:3902
const std::string & func(void) const
Definition: easylogging++.h:2533
static bool parseFromText(const std::string &configurationsString, Configurations *sender, Configurations *base=nullptr)
Parse configurations from configuration string.
Definition: easylogging++.cc:506
std::function< void(const char *, std::size_t)> PreRollOutCallback
Definition: easylogging++.h:839
static bool parseFromFile(const std::string &configurationFile, Configurations *sender, Configurations *base=nullptr)
Parses configuration from file.
Definition: easylogging++.cc:488
Level m_level
Definition: easylogging++.h:1759
virtual ~PErrorWriter(void)
Definition: easylogging++.cc:3073
void resetLocation(const char *filename, base::type::LineNumber lineNumber)
Resets location of current hit counter.
Definition: easylogging++.h:2104
Configurations * configurations(void)
Definition: easylogging++.h:2285
static const std::string version(void)
Current version number.
Definition: easylogging++.cc:3549
virtual ~RegisteredLoggers(void)
Definition: easylogging++.h:2390
bool operator==(const AbstractRegistry< T_Ptr, Container > &other)
Definition: easylogging++.h:1310
TimestampUnit
Enum to represent timestamp unit.
Definition: easylogging++.h:843
Command line arguments for application if specified using el::Helpers::setArgs(..) or START_EASYLOGGI...
Definition: easylogging++.h:1249
Configurations * defaultConfigurations(void)
Definition: easylogging++.h:2399
PreRollOutCallback & preRollOutCallback(void)
Definition: easylogging++.h:2687
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
static bool endsWith(const std::string &str, const std::string &end)
Determines whether or not str ends with specified string.
Definition: easylogging++.cc:1010
const_iterator begin() const noexcept
Definition: dandelionpp.h:80
void setDefaultConfigurations(const Configurations &configurations)
Definition: easylogging++.h:2394
base::RegisteredHitCounters * m_registeredHitCounters
Definition: easylogging++.h:2759
base::DispatchAction m_dispatchAction
Definition: easylogging++.h:3324
Definition: easylogging++.h:2793
std::string getThreadName(const std::string &threadId)
Definition: easylogging++.h:2747
static const char kFormatSpecifierChar
Definition: easylogging++.h:764
base::MessageBuilder m_messageBuilder
Definition: easylogging++.h:3323
Specifies number of log entries to hold until we flush pending log data.
time
Definition: gen_wide_data.py:40
static bool parseLine(std::string *line, std::string *currConfigStr, std::string *currLevelStr, Level *currLevel, Configurations *conf)
Definition: easylogging++.cc:557
base::type::string_t m_message
Definition: easylogging++.h:2553
std::string m_configurationFile
Definition: easylogging++.h:1913
static bool configureFromArg(const char *argKey)
Configures loggers using command line arg. Ensure you have already set command line args...
Definition: easylogging++.cc:3493
base::type::string_t m_userFormat
Definition: easylogging++.h:1670
static void addFlag(LoggingFlag flag)
Adds logging flag used internally.
Definition: easylogging++.h:3930
std::unordered_map< std::string, base::type::LoggerRegistrationCallbackPtr > m_loggerRegistrationCallbacks
Definition: easylogging++.h:2450
Definition: easylogging++.h:2235
static void validateFileRolling(Logger *logger, Level level)
Definition: easylogging++.h:3859
static const base::type::EnumType kMinValid
Represents minimum valid configuration type. Useful when iterating through enum.
Definition: easylogging++.h:699
Configurations m_configurations
Definition: easylogging++.h:2343
std::shared_ptr< LoggerRegistrationCallback > LoggerRegistrationCallbackPtr
Definition: easylogging++.h:563
LogMessage * m_logMessage
Definition: easylogging++.h:2213
conn start()
base::type::EnumType m_flags
Definition: easylogging++.h:1673
static Logger * getLogger(const std::string &identity, bool registerIfNotAvailable=true)
Gets existing or registers new logger.
Definition: easylogging++.cc:3368
static std::string timevalToString(struct timeval tval, const char *format, const el::base::SubsecondPrecision *ssPrec)
Converts timeval (struct from ctime) to string using specified format and subsecond precision...
Definition: easylogging++.cc:1289
base::type::VerboseLevel verboseLevel(void) const
Definition: easylogging++.h:2536
int bool
Definition: stdbool.h:35
AbstractRegistry(void)
Default constructor.
Definition: easylogging++.h:1299
NullWriter & operator<<(std::ostream &(*)(std::ostream &))
Definition: easylogging++.h:3243
base::debug::CrashHandler elCrashHandler
T * loggerRegistrationCallback(const std::string &id)
Definition: easylogging++.h:2417
static const el::base::utils::CommandLineArgs * commandLineArgs(void)
Returns command line arguments (pointer) provided to easylogging++.
Definition: easylogging++.h:3839
bool vModulesEnabled(void)
Whether or not vModules enabled.
Definition: easylogging++.h:2492
void setFromBase(Configurations *base)
Sets configuration based-off an existing configurations.
Definition: easylogging++.cc:393
A subsecond precision class containing actual width and offset of the subsecond part.
Definition: easylogging++.h:865
static bool installLoggerRegistrationCallback(const std::string &id)
Installs logger registration callback, this callback is triggered when new logger is registered...
Definition: easylogging++.h:3875
#define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp)
Definition: easylogging++.h:2984
const std::string & getFilenameCommonPrefix() const
Definition: easylogging++.h:2500
const Configurations * configurations(void) const
Definition: easylogging++.h:1953
~ScopedRemoveFlag(void)
Definition: easylogging++.h:3959
base::VRegistry * vRegistry(void) const
Definition: easylogging++.h:2645
virtual iterator begin(void) ELPP_FINAL
Definition: easylogging++.h:1348
Level m_level
Definition: easylogging++.h:3315
void clearCategories(void)
Definition: easylogging++.cc:2144
NoCopy & operator=(const NoCopy &)
Logger * m_logger
Definition: easylogging++.h:2552
Configuration & operator=(const Configuration &c)
Definition: easylogging++.cc:322
virtual void deepCopy(const AbstractRegistry< T_Ptr, std::vector< T_Ptr *>> &sr)
Definition: easylogging++.h:1563
bool operator==(const LogFormat &other)
Definition: easylogging++.cc:1584
static const std::size_t kSourceLineMaxLength
Definition: easylogging++.h:794
std::string m_file
Definition: easylogging++.h:2548
std::string m_value
Definition: easylogging++.h:1761
std::unordered_map< std::string, base::type::LogDispatchCallbackPtr > m_logDispatchCallbacks
Definition: easylogging++.h:2769
void parseFromFormat(const base::type::string_t &userFormat)
Updates format to be used while logging.
Definition: easylogging++.cc:1591
const char * getParamValue(const char *paramKey) const
Returns value of arguments.
Definition: easylogging++.cc:1457
void dispatch(void)
Definition: easylogging++.cc:2860
void unsafeSetIfNotExist(Level level, ConfigurationType configurationType, const std::string &value)
Unsafely sets configuration if does not already exist.
Definition: easylogging++.cc:617
base::LogStreamsReferenceMap * logStreamsReference(void)
Definition: easylogging++.h:2432
base::type::VerboseLevel m_verboseLevel
Definition: easylogging++.h:3320
prefix
Definition: check.py:15
std::unordered_map< std::string, base::type::VerboseLevel > m_modules
Definition: easylogging++.h:2507
base::threading::ScopedLock m_sync
Definition: easylogging++.h:3326
Definition: easylogging++.h:494
#define M(w0, w14, w9, w1)
Definition: sha512-blocks.c:41
POD_CLASS hash
Definition: hash.h:49
virtual ~HitCounter(void)
Definition: easylogging++.h:2100
VRegistry(base::type::VerboseLevel level, base::type::EnumType *pFlags)
Definition: easylogging++.cc:2043
base::RegisteredLoggers * registeredLoggers(void) const
Definition: easylogging++.h:2641
Logger & operator=(const Logger &logger)
Definition: easylogging++.cc:731
base::DispatchAction dispatchAction(void) const
Definition: easylogging++.h:2203
virtual const Container & list(void) const ELPP_FINAL
Returns underlying container by constant reference.
Definition: easylogging++.h:1384
CommandLineArgs(void)
Definition: easylogging++.h:1251
Generic level that represents all the levels. Useful when setting global configuration for all levels...
Registry< T_Ptr, T_Key >::iterator iterator
Definition: easylogging++.h:1410
virtual void registerNew(const T_Key &uniqKey, T_Ptr *ptr) ELPP_FINAL
Registers new registry to repository.
Definition: easylogging++.h:1449
bool m_proceed
Definition: easylogging++.h:2848
void triggerDispatch(void)
Definition: easylogging++.cc:3044
const LogMessage * logMessage(void) const
Definition: easylogging++.h:2200
static void ignoreComments(std::string *line)
Definition: easylogging++.cc:522
static int priority(Level level)
Definition: easylogging++.cc:2128
Whether or not to write corresponding log to log file.
#define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp)
Definition: easylogging++.h:2979
static const Configurations * defaultConfigurations(void)
Returns current default.
Definition: easylogging++.cc:3429
Represents single configuration that has representing level, configuration type and a string based va...
Definition: easylogging++.h:1711
Internal helper class that makes all default constructors private.
Definition: easylogging++.h:580
void uninstallLogDispatchCallback(const std::string &id)
Definition: easylogging++.h:2713
void setLogMessage(LogMessage *logMessage)
Definition: easylogging++.h:2206
static base::type::EnumType Not(Enum e, base::type::EnumType flag)
Definition: easylogging++.h:903
virtual ~RegistryWithPred(void)
Definition: easylogging++.h:1492
A mutex wrapper for compiler that dont yet support std::recursive_mutex.
Definition: easylogging++.h:929
Logger(void)
static bool isLevel(const std::string &line)
Definition: easylogging++.cc:541
static base::type::fstream_t * newFileStream(const std::string &filename)
Creates new out file stream for specified filename.
Definition: easylogging++.cc:829
ScopedRemoveFlag(LoggingFlag flag)
Definition: easylogging++.h:3956
const base::type::char_t * m_containerLogSeperator
Definition: easylogging++.h:3218
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:2071
def next(obj)
Definition: ast.py:58
Represents a logger holding ID and configurations we need to write logs.
Definition: easylogging++.h:2252
ConfigurationType
Represents enumeration of ConfigurationType used to configure or access certain aspect of logging...
Definition: easylogging++.h:664
base::type::stringstream_t m_stream
Definition: easylogging++.h:2340
AbstractRegistry & operator=(AbstractRegistry &&sr)
Assignment move operator.
Definition: easylogging++.h:1335
Registry(const Registry &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
Definition: easylogging++.h:1416
static const base::type::EnumType kMaxValid
Represents maximum valid level. This is used internally and you should not need it.
Definition: easylogging++.h:636
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1124
std::unordered_map< Level, bool > m_toFileMap
Definition: easylogging++.h:1972
const char * name
Definition: options.c:30
void increment(void)
Definition: easylogging++.h:2129
static base::type::EnumType Or(Enum e, base::type::EnumType flag)
Definition: easylogging++.h:907
RegistryWithPred< T_Ptr, Pred >::const_iterator const_iterator
Definition: easylogging++.h:1487
static Level convertFromString(const char *levelStr)
Converts from levelStr to Level.
Definition: easylogging++.cc:222
const LogDispatchData * m_data
Definition: easylogging++.h:2797
const FormatSpecifierValueResolver & resolver(void) const
Definition: easylogging++.h:1691
static std::string getDateTime(const char *format, const base::SubsecondPrecision *ssPrec)
Gets current date and time with a subsecond part.
Definition: easylogging++.cc:1283
HitCounter(const char *filename, base::type::LineNumber lineNumber)
Definition: easylogging++.h:2079
void setCategories(const char *categories, bool clear=true)
Definition: easylogging++.cc:2151
constexpr bool trace
Definition: common.hpp:104
std::stringstream stringstream_t
Definition: easylogging++.h:548
std::string m_currentHost
Definition: easylogging++.h:1675
std::vector< CustomFormatSpecifier > m_customFormatSpecifiers
Definition: easylogging++.h:2772
void initializeLogger(const std::string &loggerId, bool lookup=true, bool needLock=true)
Definition: easylogging++.cc:2950
LogDispatchData()
Definition: easylogging++.h:2199
base::type::VerboseLevel m_verboseLevel
Definition: easylogging++.h:2551
StaticClass & operator=(const StaticClass &)
static bool startsWith(const std::string &str, const std::string &start)
Determines whether or not str starts with specified string.
Definition: easylogging++.cc:1006
const std::unordered_map< std::string, base::type::VerboseLevel > & modules(void) const
Definition: easylogging++.h:2485
char ** m_argv
Definition: easylogging++.h:1282
const std::vector< CustomFormatSpecifier > * customFormatSpecifiers(void) const
Definition: easylogging++.h:2695
Static class that contains helper functions for el::Level.
Definition: easylogging++.h:631
Writer & construct(Logger *logger, bool needLock=true)
Definition: easylogging++.cc:2918
Level m_loggingLevel
Definition: easylogging++.h:2775
void setParentApplicationName(const std::string &parentApplicationName)
Definition: easylogging++.h:2281
bool m_proceed
Definition: easylogging++.h:3322
line
Definition: check.py:23
std::unordered_map< Level, std::size_t > m_maxLogFileSizeMap
Definition: easylogging++.h:1979
void reinitDeepCopy(const AbstractRegistry< T_Ptr, Container > &sr)
Definition: easylogging++.h:1393
error
Tracks LMDB error codes.
Definition: error.h:44
std::string m_dateTimeFormat
Definition: easylogging++.h:1672
int m_argc
Definition: easylogging++.h:1281
#define const
Definition: ipfrdr.c:80
static std::vector< std::string > lookup(lookup_t type, const char *hostname)
Definition: dns_checks.cpp:47
static void uninstallCallback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
Definition: easylogging++.h:1581
base::type::LineNumber m_lineNumber
Definition: easylogging++.h:2152
Color
Definition: easylogging++.h:611
base::LogStreamsReferenceMap * m_logStreamsReference
Definition: easylogging++.h:1981
bool validateAfterN(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
Validates counter for hits >= N, i.e, registers new if does not exist otherwise updates original one...
Definition: easylogging++.cc:1958
Enables hierarchical logging.
static constexpr const char hex[]
Definition: wipeable_string.cpp:36
Registry(void)
Definition: easylogging++.h:1413
#define true
Definition: stdbool.h:36
Definition: easylogging++.h:3988
static std::string & ltrim(std::string &str)
Definition: easylogging++.cc:988
Level level(void) const
Definition: easylogging++.h:2521
MessageBuilder(void)
Definition: easylogging++.h:2931
ThreadSafe(void)
Definition: easylogging++.h:1039
c
Definition: pymoduletest.py:79
static bool hasCustomFormatSpecifier(const char *formatSpecifier)
Returns true if custom format specifier is installed.
Definition: easylogging++.h:3856
#define ELPP_FINAL
Definition: easylogging++.h:284
Supports use of multiple logging in same macro, e.g, CLOG(INFO, "default", "network") ...
Static helpers for developers.
Definition: easylogging++.h:3735
std::size_t logFlushThreshold(Level level)
Definition: easylogging++.cc:1772
bool empty(void) const
Returns true if no params available. This exclude argv[0].
Definition: easylogging++.cc:1466
static ConfigurationType castFromInt(base::type::EnumType c)
Casts int(ushort) to configurationt type, useful for iterating through enum.
Definition: easylogging++.h:707
bool hasParamWithValue(const char *paramKey) const
Returns true if arguments contain paramKey with a value (seperated by &#39;=&#39;)
Definition: easylogging++.cc:1453
cryptonote::block b
Definition: block.cpp:40
std::string m_categoriesString
Definition: easylogging++.h:2510
#define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp)
Definition: easylogging++.h:2989
static void clearVModules(void)
Clears vmodules.
Definition: easylogging++.cc:3523
Information that can be useful to back-trace certain events - mostly useful than debug logs...
RegistryWithPred(void)
Definition: easylogging++.h:1489
const char * queue
Definition: testobsdrdr.c:21
virtual base::threading::Mutex & lock(void) ELPP_FINAL
Definition: easylogging++.h:1037
const base::type::string_t & message(void) const
Definition: easylogging++.h:2542
Specifies log file max size.
std::size_t m_hitCounts
Definition: easylogging++.h:2153
void processDispatch()
Definition: easylogging++.cc:2991
Represents registries for verbose logging.
Definition: easylogging++.h:2456
void setToDefault(void)
Sets configurations to "factory based" configurations.
Definition: easylogging++.cc:441
std::unordered_map< Level, base::SubsecondPrecision > m_subsecondPrecisionMap
Definition: easylogging++.h:1976
static base::type::VerboseLevel verboseLevel(void)
Gets current verbose level.
Definition: easylogging++.cc:3513
static void setArgs(int argc, char **argv)
Sets application arguments and figures out whats active for logging and whats not.
Definition: easylogging++.h:3746
base::type::EnumType * m_pFlags
Definition: easylogging++.h:2506
Easylogging++ management storage.
Definition: easylogging++.h:2615
#define inline
Definition: inline_c.h:34
Allows to disable application abortion when logged using FATAL level.
virtual bool empty(void) const ELPP_FINAL
Definition: easylogging++.h:1369
static bool installLogDispatchCallback(const std::string &id)
Installs post log dispatch callback, this callback is triggered when log is dispatched.
Definition: easylogging++.h:3789