Monero
Loading...
Searching...
No Matches
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)) { \
172std::stringstream internalInfoStream; internalInfoStream << msg; \
173ELPP_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)) { \
179std::stringstream internalInfoStream; internalInfoStream << msg; \
180ELPP_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); \
191ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << buff << " [" << errno << "]";} (void)0
192#else
193# define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \
194ELPP_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) { \
199std::stringstream internalInfoStream; internalInfoStream << "<ERROR> " << msg; \
200ELPP_INTERNAL_DEBUGGING_OUT_ERROR \
201<< "ERROR FROM EASYLOGGING++ (LINE: " << __LINE__ << ") " \
202<< ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << ELPP_INTERNAL_DEBUGGING_ENDL; \
203if (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) { \
215std::stringstream internalInfoStream; internalInfoStream << "<INFO> " << msg; \
216ELPP_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
488namespace el {
489class Logger;
490class LogMessage;
491class PerformanceTrackingData;
492class Loggers;
493class Helpers;
494template <typename T> class Callback;
495class LogDispatchCallback;
496class PerformanceTrackingCallback;
497class LoggerRegistrationCallback;
498class LogDispatchData;
499namespace base {
500class Storage;
501class RegisteredLoggers;
502class PerformanceTracker;
503class MessageBuilder;
504class Writer;
505class PErrorWriter;
506class LogDispatcher;
507class DefaultLogBuilder;
508class DefaultLogDispatchCallback;
509#if ELPP_ASYNC_LOGGING
510class AsyncLogDispatchCallback;
511class AsyncDispatchWorker;
512#endif // ELPP_ASYNC_LOGGING
513class DefaultPerformanceTrackingCallback;
514} // namespace base
515} // namespace el
517namespace el {
519namespace base {
521namespace 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
533typedef wchar_t char_t;
534typedef std::wstring string_t;
535typedef std::wstringstream stringstream_t;
536typedef std::wfstream fstream_t;
537typedef 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
546typedef char char_t;
547typedef std::string string_t;
548typedef std::stringstream stringstream_t;
549typedef std::fstream fstream_t;
550typedef 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)
557typedef unsigned int EnumType;
558typedef unsigned short VerboseLevel;
559typedef unsigned long int LineNumber;
561typedef std::shared_ptr<LogDispatchCallback> LogDispatchCallbackPtr;
562typedef std::shared_ptr<PerformanceTrackingCallback> PerformanceTrackingCallbackPtr;
563typedef std::shared_ptr<LoggerRegistrationCallback> LoggerRegistrationCallbackPtr;
564typedef std::unique_ptr<el::base::PerformanceTracker> PerformanceTrackerPtr;
565} // namespace type
566
569class NoCopy {
570 protected:
571 NoCopy(void) {}
572 private:
573 NoCopy(const NoCopy&);
575};
576
586} // namespace base
595 Trace = 2,
597 Debug = 4,
599 Fatal = 8,
601 Error = 16,
607 Info = 128,
609 Unknown = 1010
610};
620} // namespace el
621namespace std {
622template<> 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}
629namespace el {
632 public:
639 return static_cast<base::type::EnumType>(level);
640 }
641
643 return static_cast<Level>(l);
644 }
645
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};
662
695
697 public:
704 return static_cast<base::type::EnumType>(configurationType);
705 }
706
708 return static_cast<ConfigurationType>(c);
709 }
710
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};
724
760namespace base {
762namespace consts {
763static const char kFormatSpecifierCharValue = 'v';
764static const char kFormatSpecifierChar = '%';
765static const unsigned int kMaxLogPerCounter = 100000;
766static const unsigned int kMaxLogPerContainer = 100;
767static const unsigned int kDefaultSubsecondPrecision = 3;
768
769#ifdef ELPP_DEFAULT_LOGGER
770static const char* kDefaultLoggerId = ELPP_DEFAULT_LOGGER;
771#else
772static const char* kDefaultLoggerId = "default";
773#endif
774
775#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
776#ifdef ELPP_DEFAULT_PERFORMANCE_LOGGER
777static const char* kPerformanceLoggerId = ELPP_DEFAULT_PERFORMANCE_LOGGER;
778#else
779static const char* kPerformanceLoggerId = "performance";
780#endif // ELPP_DEFAULT_PERFORMANCE_LOGGER
781#endif
782
783#if defined(ELPP_SYSLOG)
784static const char* kSysLogLoggerId = "syslog";
785#endif // defined(ELPP_SYSLOG)
786
787#if ELPP_OS_WINDOWS
788static const char* kFilePathSeperator = "\\";
789#else
790static const char* kFilePathSeperator = "/";
791#endif // ELPP_OS_WINDOWS
792
793static const std::size_t kSourceFilenameMaxLength = 100;
794static const std::size_t kSourceLineMaxLength = 10;
796const 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") }
807static const int kTimeFormatsCount = sizeof(kTimeFormats) / sizeof(kTimeFormats[0]);
808const 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 },
836static const int kCrashSignalsCount = sizeof(kCrashSignals) / sizeof(kCrashSignals[0]);
837} // namespace consts
838} // namespace base
839typedef std::function<void(const char*, std::size_t)> PreRollOutCallback;
840namespace base {
841static inline void defaultPreRollOutCallback(const char*, std::size_t) {}
844 Microsecond = 0, Millisecond = 1, Second = 2, Minute = 3, Hour = 4, Day = 5
845};
846
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};
864
866 public:
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 }
877 unsigned int m_offset;
878 private:
879 void init(int width);
880};
881
884namespace utils {
886template <typename T>
887static
888typename std::enable_if<std::is_pointer<T*>::value, void>::type
890 if (pointer == nullptr)
891 return;
892 delete pointer;
893 pointer = nullptr;
894}
895
897namespace bitwise {
898template <typename Enum>
899static 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}
902template <typename Enum>
903static 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}
906template <typename Enum>
907static 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
911template <typename Enum>
912static inline void addFlag(Enum e, base::type::EnumType* flag) {
913 *flag = base::utils::bitwise::Or<Enum>(e, *flag);
914}
915template <typename Enum>
916static inline void removeFlag(Enum e, base::type::EnumType* flag) {
917 *flag = base::utils::bitwise::Not<Enum>(e, *flag);
918}
919template <typename Enum>
920static inline bool hasFlag(Enum e, base::type::EnumType flag) {
921 return base::utils::bitwise::And<Enum>(e, flag) > 0x0;
922}
923} // namespace utils
924namespace threading {
925#if ELPP_THREADING_ENABLED
926# if !ELPP_USE_STD_THREADING
927namespace internal {
929class Mutex : base::NoCopy {
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};
983template <typename M>
984class ScopedLock : base::NoCopy {
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:
995 M* m_mutex;
996 ScopedLock(void);
997};
998} // namespace internal
999typedef base::threading::internal::Mutex Mutex;
1000typedef base::threading::internal::ScopedLock<base::threading::Mutex> ScopedLock;
1001# else
1002typedef std::recursive_mutex Mutex;
1003typedef std::lock_guard<base::threading::Mutex> ScopedLock;
1004# endif // !ELPP_USE_STD_THREADING
1005#else
1006namespace internal {
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};
1017
1018template <typename Mutex>
1020 public:
1021 explicit NoScopedLock(Mutex&) {
1022 }
1023 virtual ~NoScopedLock(void) {
1024 }
1025 private:
1027};
1028} // namespace internal
1031#endif // ELPP_THREADING_ENABLED
1033class 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
1048static 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
1057static 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
1071static inline std::string getCurrentThreadId(void) {
1072 return std::string();
1073}
1074#endif // ELPP_THREADING_ENABLED
1075} // namespace threading
1076namespace 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};
1103
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)
1154 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};
1174
1176 public:
1177#if ELPP_OS_WINDOWS
1182 static const char* getWindowsEnvironmentVariable(const char* varname);
1183#endif // ELPP_OS_WINDOWS
1184#if ELPP_OS_ANDROID
1186 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(std::string& term);
1216 static bool termSupportsColor(void);
1217};
1218
1220 public:
1225 static void gettimeofday(struct timeval* tv);
1226
1231 static std::string getDateTime(const char* format, const base::SubsecondPrecision* ssPrec);
1232
1234 static std::string timevalToString(struct timeval tval, const char* format,
1235 const el::base::SubsecondPrecision* ssPrec);
1236
1238 static base::type::string_t formatTime(unsigned long long time, base::TimestampUnit timestampUnit);
1239
1241 static unsigned long long getTimeDifference(const struct timeval& endTime, const struct timeval& startTime,
1242 base::TimestampUnit timestampUnit);
1243
1244
1245 static struct ::tm* buildTimeInfo(struct timeval* currTime, struct ::tm* timeInfo);
1246 private:
1247 static char* parseFormat(char* buf, std::size_t bufSz, const char* format, const struct tm* tInfo,
1248 std::size_t msec, const base::SubsecondPrecision* ssPrec);
1249};
1250
1252 public:
1254 setArgs(0, static_cast<char**>(nullptr));
1255 }
1256 CommandLineArgs(int argc, const char** argv) {
1257 setArgs(argc, argv);
1258 }
1259 CommandLineArgs(int argc, char** argv) {
1260 setArgs(argc, argv);
1261 }
1262 virtual ~CommandLineArgs(void) {}
1264 inline void setArgs(int argc, const char** argv) {
1265 setArgs(argc, const_cast<char**>(argv));
1266 }
1267
1268 void setArgs(int argc, char** argv);
1270 bool hasParamWithValue(const char* paramKey) const;
1273 const char* getParamValue(const char* paramKey) const;
1275 bool hasParam(const char* paramKey) const;
1277 bool empty(void) const;
1279 std::size_t size(void) const;
1281
1282 private:
1284 char** m_argv;
1285 std::unordered_map<std::string, std::string> m_paramsWithValue;
1286 std::vector<std::string> m_params;
1287};
1288
1294template <typename T_Ptr, typename Container>
1296 public:
1297 typedef typename Container::iterator iterator;
1298 typedef typename Container::const_iterator const_iterator;
1299
1302
1305 if (this == &sr) {
1306 return;
1307 }
1308 unregisterAll();
1309 m_list = std::move(sr.m_list);
1310 }
1311
1313 if (size() != other.size()) {
1314 return false;
1315 }
1316 for (std::size_t i = 0; i < m_list.size(); ++i) {
1317 if (m_list.at(i) != other.m_list.at(i)) {
1318 return false;
1319 }
1320 }
1321 return true;
1322 }
1323
1325 if (size() != other.size()) {
1326 return true;
1327 }
1328 for (std::size_t i = 0; i < m_list.size(); ++i) {
1329 if (m_list.at(i) != other.m_list.at(i)) {
1330 return true;
1331 }
1332 }
1333 return false;
1334 }
1335
1338 if (this == &sr) {
1339 return *this;
1340 }
1341 unregisterAll();
1342 m_list = std::move(sr.m_list);
1343 return *this;
1344 }
1345
1346 virtual ~AbstractRegistry(void) {
1347 }
1348
1350 virtual inline iterator begin(void) ELPP_FINAL {
1351 return m_list.begin();
1352 }
1353
1355 virtual inline iterator end(void) ELPP_FINAL {
1356 return m_list.end();
1357 }
1358
1359
1361 virtual inline const_iterator cbegin(void) const ELPP_FINAL {
1362 return m_list.cbegin();
1363 }
1364
1366 virtual inline const_iterator cend(void) const ELPP_FINAL {
1367 return m_list.cend();
1368 }
1369
1371 virtual inline bool empty(void) const ELPP_FINAL {
1372 return m_list.empty();
1373 }
1374
1376 virtual inline std::size_t size(void) const ELPP_FINAL {
1377 return m_list.size();
1378 }
1379
1381 virtual inline Container& list(void) ELPP_FINAL {
1382 return m_list;
1383 }
1384
1386 virtual inline const Container& list(void) const ELPP_FINAL {
1387 return m_list;
1388 }
1389
1391 virtual void unregisterAll(void) = 0;
1392
1393 protected:
1399
1400 private:
1401 Container m_list;
1402};
1403
1409template <typename T_Ptr, typename T_Key = const char*>
1410class Registry : public AbstractRegistry<T_Ptr, std::unordered_map<T_Key, T_Ptr*>> {
1411 public:
1414
1415 Registry(void) {}
1416
1418 Registry(const Registry& sr) : AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>() {
1419 if (this == &sr) {
1420 return;
1421 }
1422 this->reinitDeepCopy(sr);
1423 }
1424
1429 if (this == &sr) {
1430 return *this;
1431 }
1432 this->reinitDeepCopy(sr);
1433 return *this;
1434 }
1435
1436 virtual ~Registry(void) {
1437 unregisterAll();
1438 }
1439
1440 protected:
1441 virtual void unregisterAll(void) ELPP_FINAL {
1442 if (!this->empty()) {
1443 for (auto&& curr : this->list()) {
1444 base::utils::safeDelete(curr.second);
1445 }
1446 this->list().clear();
1447 }
1448 }
1449
1451 virtual void registerNew(const T_Key& uniqKey, T_Ptr* ptr) ELPP_FINAL {
1452 unregister(uniqKey);
1453 this->list().insert(std::make_pair(uniqKey, ptr));
1454 }
1455
1457 void unregister(const T_Key& uniqKey) {
1458 T_Ptr* existing = get(uniqKey);
1459 if (existing != nullptr) {
1460 this->list().erase(uniqKey);
1461 base::utils::safeDelete(existing);
1462 }
1463 }
1464
1466 T_Ptr* get(const T_Key& uniqKey) {
1467 iterator it = this->list().find(uniqKey);
1468 return it == this->list().end()
1469 ? nullptr
1470 : it->second;
1471 }
1472
1473 private:
1474 virtual void deepCopy(const AbstractRegistry<T_Ptr, std::unordered_map<T_Key, T_Ptr*>>& sr) ELPP_FINAL {
1475 for (const_iterator it = sr.cbegin(); it != sr.cend(); ++it) {
1476 registerNew(it->first, new T_Ptr(*it->second));
1477 }
1478 }
1479};
1480
1485template <typename T_Ptr, typename Pred>
1486class RegistryWithPred : public AbstractRegistry<T_Ptr, std::vector<T_Ptr*>> {
1487 public:
1490
1492 }
1493
1494 virtual ~RegistryWithPred(void) {
1495 unregisterAll();
1496 }
1497
1500 if (this == &sr) {
1501 return;
1502 }
1503 this->reinitDeepCopy(sr);
1504 }
1505
1510 if (this == &sr) {
1511 return *this;
1512 }
1513 this->reinitDeepCopy(sr);
1514 return *this;
1515 }
1516
1518 for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) {
1519 os << ELPP_LITERAL(" ") << **it << ELPP_LITERAL("\n");
1520 }
1521 return os;
1522 }
1523
1524 protected:
1525 virtual void unregisterAll(void) ELPP_FINAL {
1526 if (!this->empty()) {
1527 for (auto&& curr : this->list()) {
1529 }
1530 this->list().clear();
1531 }
1532 }
1533
1534 virtual void unregister(T_Ptr*& ptr) ELPP_FINAL {
1535 if (ptr) {
1536 iterator iter = this->begin();
1537 for (; iter != this->end(); ++iter) {
1538 if (ptr == *iter) {
1539 break;
1540 }
1541 }
1542 if (iter != this->end() && *iter != nullptr) {
1543 this->list().erase(iter);
1545 }
1546 }
1547 }
1548
1549 virtual inline void registerNew(T_Ptr* ptr) ELPP_FINAL {
1550 this->list().push_back(ptr);
1551 }
1552
1555 template <typename T, typename T2>
1556 T_Ptr* get(const T& arg1, const T2 arg2) {
1557 iterator iter = std::find_if(this->list().begin(), this->list().end(), Pred(arg1, arg2));
1558 if (iter != this->list().end() && *iter != nullptr) {
1559 return *iter;
1560 }
1561 return nullptr;
1562 }
1563
1564 private:
1565 virtual void deepCopy(const AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>& sr) {
1566 for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) {
1567 registerNew(new T_Ptr(**it));
1568 }
1569 }
1570};
1571class Utils {
1572 public:
1573 template <typename T, typename TPtr>
1574 static bool installCallback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
1575 if (mapT->find(id) == mapT->end()) {
1576 mapT->insert(std::make_pair(id, TPtr(new T())));
1577 return true;
1578 }
1579 return false;
1580 }
1581
1582 template <typename T, typename TPtr>
1583 static void uninstallCallback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
1584 if (mapT->find(id) != mapT->end()) {
1585 mapT->erase(id);
1586 }
1587 }
1588
1589 template <typename T, typename TPtr>
1590 static T* callback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
1591 typename std::unordered_map<std::string, TPtr>::iterator iter = mapT->find(id);
1592 if (iter != mapT->end()) {
1593 return static_cast<T*>(iter->second.get());
1594 }
1595 return nullptr;
1596 }
1597};
1598} // namespace utils
1599} // namespace base
1604 public:
1605 virtual ~Loggable(void) {}
1606 virtual void log(el::base::type::ostream_t&) const = 0;
1607 private:
1609 loggable.log(os);
1610 return os;
1611 }
1612};
1613namespace base {
1615class LogFormat : public Loggable {
1616 public:
1617 LogFormat(void);
1619 LogFormat(const LogFormat& logFormat);
1620 LogFormat(LogFormat&& logFormat);
1621 LogFormat& operator=(const LogFormat& logFormat);
1622 virtual ~LogFormat(void) {}
1623 bool operator==(const LogFormat& other);
1624
1627 void parseFromFormat(const base::type::string_t& userFormat);
1628
1629 inline Level level(void) const {
1630 return m_level;
1631 }
1632
1633 inline const base::type::string_t& userFormat(void) const {
1634 return m_userFormat;
1635 }
1636
1637 inline const base::type::string_t& format(void) const {
1638 return m_format;
1639 }
1640
1641 inline const std::string& dateTimeFormat(void) const {
1642 return m_dateTimeFormat;
1643 }
1644
1645 inline base::type::EnumType flags(void) const {
1646 return m_flags;
1647 }
1648
1649 inline bool hasFlag(base::FormatFlags flag) const {
1650 return base::utils::hasFlag(flag, m_flags);
1651 }
1652
1653 virtual void log(el::base::type::ostream_t& os) const {
1654 os << m_format;
1655 }
1656
1657 protected:
1661 virtual void updateDateFormat(std::size_t index, base::type::string_t& currFormat) ELPP_FINAL;
1662
1664 virtual void updateFormatSpec(void) ELPP_FINAL;
1665
1666 inline void addFlag(base::FormatFlags flag) {
1668 }
1669
1670 private:
1674 std::string m_dateTimeFormat;
1676 std::string m_currentUser;
1677 std::string m_currentHost;
1678 friend class el::Logger; // To resolve loggerId format specifier easily
1679};
1680} // namespace base
1682typedef std::function<std::string(const LogMessage*)> FormatSpecifierValueResolver;
1687 public:
1690 inline const char* formatSpecifier(void) const {
1691 return m_formatSpecifier;
1692 }
1693 inline const FormatSpecifierValueResolver& resolver(void) const {
1694 return m_resolver;
1695 }
1696 inline bool operator==(const char* formatSpecifier) {
1697 return strcmp(m_formatSpecifier, formatSpecifier) == 0;
1698 }
1699
1700 private:
1703};
1704
1713class Configuration : public Loggable {
1714 public:
1715 Configuration(const Configuration& c);
1717
1718 virtual ~Configuration(void) {
1719 }
1720
1722 Configuration(Level level, ConfigurationType configurationType, const std::string& value);
1723
1725 inline Level level(void) const {
1726 return m_level;
1727 }
1728
1731 return m_configurationType;
1732 }
1733
1735 inline const std::string& value(void) const {
1736 return m_value;
1737 }
1738
1742 inline void setValue(const std::string& value) {
1743 m_value = value;
1744 }
1745
1746 virtual void log(el::base::type::ostream_t& os) const;
1747
1750 public:
1752
1753 bool operator()(const Configuration* conf) const;
1754
1755 private:
1758 };
1759
1760 private:
1763 std::string m_value;
1764};
1765
1769class Configurations : public base::utils::RegistryWithPred<Configuration, Configuration::Predicate> {
1770 public:
1772 Configurations(void);
1773
1780 Configurations(const std::string& configurationFile, bool useDefaultsForRemaining = true,
1781 Configurations* base = nullptr);
1782
1783 virtual ~Configurations(void) {
1784 }
1785
1792 bool parseFromFile(const std::string& configurationFile, Configurations* base = nullptr);
1793
1802 bool parseFromText(const std::string& configurationsString, Configurations* base = nullptr);
1803
1806 void setFromBase(Configurations* base);
1807
1812 bool hasConfiguration(ConfigurationType configurationType);
1813
1817 bool hasConfiguration(Level level, ConfigurationType configurationType);
1818
1831 void set(Level level, ConfigurationType configurationType, const std::string& value);
1832
1835 void set(Configuration* conf);
1836
1837 inline Configuration* get(Level level, ConfigurationType configurationType) {
1838 base::threading::ScopedLock scopedLock(lock());
1840 }
1841
1846 inline void setGlobally(ConfigurationType configurationType, const std::string& value) {
1847 setGlobally(configurationType, value, false);
1848 }
1849
1851 inline void clear(void) {
1852 base::threading::ScopedLock scopedLock(lock());
1853 unregisterAll();
1854 }
1855
1859 inline const std::string& configurationFile(void) const {
1860 return m_configurationFile;
1861 }
1862
1864 void setToDefault(void);
1865
1873 void setRemainingToDefault(void);
1874
1880 public:
1888 static bool parseFromFile(const std::string& configurationFile, Configurations* sender,
1889 Configurations* base = nullptr);
1890
1901 static bool parseFromText(const std::string& configurationsString, Configurations* sender,
1902 Configurations* base = nullptr);
1903
1904 private:
1905 friend class el::Loggers;
1906 static void ignoreComments(std::string* line);
1907 static bool isLevel(const std::string& line);
1908 static bool isComment(const std::string& line);
1909 static inline bool isConfig(const std::string& line);
1910 static bool parseLine(std::string* line, std::string* currConfigStr, std::string* currLevelStr, Level* currLevel,
1911 Configurations* conf);
1912 };
1913
1914 private:
1917 friend class el::Loggers;
1918
1920 void unsafeSetIfNotExist(Level level, ConfigurationType configurationType, const std::string& value);
1921
1923 void unsafeSet(Level level, ConfigurationType configurationType, const std::string& value);
1924
1927 void setGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel);
1928
1931 void unsafeSetGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel);
1932};
1933
1934namespace base {
1935typedef std::shared_ptr<base::type::fstream_t> FileStreamPtr;
1936typedef std::unordered_map<std::string, FileStreamPtr> LogStreamsReferenceMap;
1944 public:
1949
1951
1952 virtual ~TypedConfigurations(void) {
1953 }
1954
1955 const Configurations* configurations(void) const {
1956 return m_configurations;
1957 }
1958
1959 bool enabled(Level level);
1960 bool toFile(Level level);
1961 const std::string& filename(Level level);
1962 bool toStandardOutput(Level level);
1963 const base::LogFormat& logFormat(Level level);
1964 const base::SubsecondPrecision& subsecondPrecision(Level level = Level::Global);
1965 const base::MillisecondsWidth& millisecondsWidth(Level level = Level::Global);
1966 bool performanceTracking(Level level = Level::Global);
1967 base::type::fstream_t* fileStream(Level level);
1968 std::size_t maxLogFileSize(Level level);
1969 std::size_t logFlushThreshold(Level level);
1970
1971 private:
1973 std::unordered_map<Level, bool> m_enabledMap;
1974 std::unordered_map<Level, bool> m_toFileMap;
1975 std::unordered_map<Level, std::string> m_filenameMap;
1976 std::unordered_map<Level, bool> m_toStandardOutputMap;
1977 std::unordered_map<Level, base::LogFormat> m_logFormatMap;
1978 std::unordered_map<Level, base::SubsecondPrecision> m_subsecondPrecisionMap;
1979 std::unordered_map<Level, bool> m_performanceTrackingMap;
1980 std::unordered_map<Level, base::FileStreamPtr> m_fileStreamMap;
1981 std::unordered_map<Level, std::size_t> m_maxLogFileSizeMap;
1982 std::unordered_map<Level, std::size_t> m_logFlushThresholdMap;
1984
1985 friend class el::Helpers;
1987 friend class el::base::Writer;
1990
1991 template <typename Conf_T>
1992 inline Conf_T getConfigByVal(Level level, const std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
1993 base::threading::ScopedLock scopedLock(lock());
1994 return unsafeGetConfigByVal(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
1995 }
1996
1997 template <typename Conf_T>
1998 inline Conf_T& getConfigByRef(Level level, std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
1999 base::threading::ScopedLock scopedLock(lock());
2000 return unsafeGetConfigByRef(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
2001 }
2002
2003 template <typename Conf_T>
2004 Conf_T unsafeGetConfigByVal(Level level, const std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
2005 ELPP_UNUSED(confName);
2006 typename std::unordered_map<Level, Conf_T>::const_iterator it = confMap->find(level);
2007 if (it == confMap->end()) {
2008 try {
2009 return confMap->at(Level::Global);
2010 } catch (...) {
2011 ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level ["
2012 << LevelHelper::convertToString(level) << "]"
2013 << std::endl << "Please ensure you have properly configured logger.", false);
2014 return Conf_T();
2015 }
2016 }
2017 return it->second;
2018 }
2019
2020 template <typename Conf_T>
2021 Conf_T& unsafeGetConfigByRef(Level level, std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
2022 ELPP_UNUSED(confName);
2023 typename std::unordered_map<Level, Conf_T>::iterator it = confMap->find(level);
2024 if (it == confMap->end()) {
2025 try {
2026 return confMap->at(Level::Global);
2027 } catch (...) {
2028 ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level ["
2029 << LevelHelper::convertToString(level) << "]"
2030 << std::endl << "Please ensure you have properly configured logger.", false);
2031 throw; // The exception has to be rethrown, to abort a branch leading to UB.
2032 }
2033 }
2034 return it->second;
2035 }
2036
2037 template <typename Conf_T>
2038 void setValue(Level level, const Conf_T& value, std::unordered_map<Level, Conf_T>* confMap,
2039 bool includeGlobalLevel = true) {
2040 // If map is empty and we are allowed to add into generic level (Level::Global), do it!
2041 if (confMap->empty() && includeGlobalLevel) {
2042 confMap->insert(std::make_pair(Level::Global, value));
2043 return;
2044 }
2045 // If same value exist in generic level already, dont add it to explicit level
2046 typename std::unordered_map<Level, Conf_T>::iterator it = confMap->find(Level::Global);
2047 if (it != confMap->end() && it->second == value) {
2048 return;
2049 }
2050 // Now make sure we dont double up values if we really need to add it to explicit level
2051 it = confMap->find(level);
2052 if (it == confMap->end()) {
2053 // Value not found for level, add new
2054 confMap->insert(std::make_pair(level, value));
2055 } else {
2056 // Value found, just update value
2057 confMap->at(level) = value;
2058 }
2059 }
2060
2061 void build(Configurations* configurations);
2062 unsigned long getULong(std::string confVal);
2063 std::string resolveFilename(const std::string& filename);
2064 void insertFile(Level level, const std::string& fullFilename);
2065 bool unsafeValidateFileRolling(Level level, const PreRollOutCallback& preRollOutCallback);
2066
2067 inline bool validateFileRolling(Level level, const PreRollOutCallback& preRollOutCallback) {
2068 base::threading::ScopedLock scopedLock(lock());
2069 return unsafeValidateFileRolling(level, preRollOutCallback);
2070 }
2071};
2072
2074 public:
2076 m_filename(""),
2077 m_lineNumber(0),
2078 m_hitCounts(0) {
2079 }
2080
2086
2087 HitCounter(const HitCounter& hitCounter) :
2088 m_filename(hitCounter.m_filename),
2089 m_lineNumber(hitCounter.m_lineNumber),
2090 m_hitCounts(hitCounter.m_hitCounts) {
2091 }
2092
2093 HitCounter& operator=(const HitCounter& hitCounter) {
2094 if (&hitCounter != this) {
2095 m_filename = hitCounter.m_filename;
2096 m_lineNumber = hitCounter.m_lineNumber;
2097 m_hitCounts = hitCounter.m_hitCounts;
2098 }
2099 return *this;
2100 }
2101
2102 virtual ~HitCounter(void) {
2103 }
2104
2110
2112 inline void validateHitCounts(std::size_t n) {
2114 m_hitCounts = (n >= 1 ? base::consts::kMaxLogPerCounter % n : 0);
2115 }
2116 ++m_hitCounts;
2117 }
2118
2119 inline const char* filename(void) const {
2120 return m_filename;
2121 }
2122
2124 return m_lineNumber;
2125 }
2126
2127 inline std::size_t hitCounts(void) const {
2128 return m_hitCounts;
2129 }
2130
2131 inline void increment(void) {
2132 ++m_hitCounts;
2133 }
2134
2136 public:
2141 inline bool operator()(const HitCounter* counter) {
2142 return ((counter != nullptr) &&
2143 (strcmp(counter->m_filename, m_filename) == 0) &&
2144 (counter->m_lineNumber == m_lineNumber));
2145 }
2146
2147 private:
2148 const char* m_filename;
2150 };
2151
2152 private:
2153 const char* m_filename;
2155 std::size_t m_hitCounts;
2156};
2157
2158class RegisteredHitCounters : public base::utils::RegistryWithPred<base::HitCounter, base::HitCounter::Predicate> {
2159 public:
2162 bool validateEveryN(const char* filename, base::type::LineNumber lineNumber, std::size_t n);
2163
2166 bool validateAfterN(const char* filename, base::type::LineNumber lineNumber, std::size_t n);
2167
2170 bool validateNTimes(const char* filename, base::type::LineNumber lineNumber, std::size_t n);
2171
2173 inline const base::HitCounter* getCounter(const char* filename, base::type::LineNumber lineNumber) {
2174 base::threading::ScopedLock scopedLock(lock());
2175 return get(filename, lineNumber);
2176 }
2177};
2178
2182} // namespace base
2183template <typename T>
2185 public:
2187 inline bool enabled(void) const {
2188 return m_enabled;
2189 }
2190 inline void setEnabled(bool enabled) {
2191 base::threading::ScopedLock scopedLock(lock());
2193 }
2194 protected:
2195 virtual void handle(const T* handlePtr) = 0;
2196 private:
2198};
2200 public:
2201 LogDispatchData() : m_logMessage(nullptr), m_dispatchAction(base::DispatchAction::None) {}
2202 inline const LogMessage* logMessage(void) const {
2203 return m_logMessage;
2204 }
2206 return m_dispatchAction;
2207 }
2214 private:
2218
2219};
2220class LogDispatchCallback : public Callback<LogDispatchData> {
2221 protected:
2222 virtual void handle(const LogDispatchData* data);
2224 private:
2226 std::unordered_map<std::string, std::unique_ptr<base::threading::Mutex>> m_fileLocks;
2228};
2229class PerformanceTrackingCallback : public Callback<PerformanceTrackingData> {
2230 private:
2231 friend class base::PerformanceTracker;
2232};
2233class LoggerRegistrationCallback : public Callback<Logger> {
2234 private:
2236};
2238 public:
2239 LogBuilder() : m_termSupportsColor(base::utils::OS::termSupportsColor()) {}
2240 virtual ~LogBuilder(void) {
2241 ELPP_INTERNAL_INFO(3, "Destroying log builder...")
2242 }
2243 virtual base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const = 0;
2244 void convertToColoredOutput(base::type::string_t* logLine, Level level, Color color);
2245 void setColor(Color color, bool bright);
2246 private:
2249};
2250typedef std::shared_ptr<LogBuilder> LogBuilderPtr;
2255 public:
2256 Logger(const std::string& id, base::LogStreamsReferenceMap* logStreamsReference);
2257 Logger(const std::string& id, const Configurations& configurations, base::LogStreamsReferenceMap* logStreamsReference);
2258 Logger(const Logger& logger);
2259 Logger& operator=(const Logger& logger);
2260
2264
2265 virtual inline void log(el::base::type::ostream_t& os) const {
2266 os << m_id.c_str();
2267 }
2268
2270 void configure(const Configurations& configurations);
2271
2273 void reconfigure(void);
2274
2275 inline const std::string& id(void) const {
2276 return m_id;
2277 }
2278
2279 inline const std::string& parentApplicationName(void) const {
2281 }
2282
2286
2288 return &m_configurations;
2289 }
2290
2294
2295 static bool isValidId(const std::string& id);
2296
2298 void flush(void);
2299
2300 void flush(Level level, base::type::fstream_t* fs);
2301
2302 inline bool isFlushNeeded(Level level) {
2303 return ++m_unflushedCount.find(level)->second >= m_typedConfigurations->logFlushThreshold(level);
2304 }
2305
2306 inline LogBuilder* logBuilder(void) const {
2307 return m_logBuilder.get();
2308 }
2309
2312 }
2313
2314 inline bool enabled(Level level) const {
2315 return m_typedConfigurations->enabled(level);
2316 }
2317
2318#if ELPP_VARIADIC_TEMPLATES_SUPPORTED
2319# define LOGGER_LEVEL_WRITERS_SIGNATURES(FUNCTION_NAME)\
2320template <typename T, typename... Args>\
2321inline void FUNCTION_NAME(const char*, const T&, const Args&...);\
2322template <typename T>\
2323inline void FUNCTION_NAME(const T&);
2324
2325 template <typename T, typename... Args>
2326 inline void verbose(int, const char*, const T&, const Args&...);
2327
2328 template <typename T>
2329 inline void verbose(int, const T&);
2330
2331 LOGGER_LEVEL_WRITERS_SIGNATURES(info)
2332 LOGGER_LEVEL_WRITERS_SIGNATURES(debug)
2333 LOGGER_LEVEL_WRITERS_SIGNATURES(warn)
2334 LOGGER_LEVEL_WRITERS_SIGNATURES(error)
2335 LOGGER_LEVEL_WRITERS_SIGNATURES(fatal)
2336 LOGGER_LEVEL_WRITERS_SIGNATURES(trace)
2337# undef LOGGER_LEVEL_WRITERS_SIGNATURES
2338#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
2339 private:
2340 std::string m_id;
2346 std::unordered_map<Level, unsigned int> m_unflushedCount;
2349
2350 friend class el::LogMessage;
2351 friend class el::Loggers;
2352 friend class el::Helpers;
2356 friend class el::base::Writer;
2358 friend class el::base::Storage;
2359 friend class el::base::PerformanceTracker;
2361
2362 Logger(void);
2363
2364#if ELPP_VARIADIC_TEMPLATES_SUPPORTED
2365 template <typename T, typename... Args>
2366 void log_(Level, int, const char*, const T&, const Args&...);
2367
2368 template <typename T>
2369 inline void log_(Level, int, const T&);
2370
2371 template <typename T, typename... Args>
2372 void log(Level, const char*, const T&, const Args&...);
2373
2374 template <typename T>
2375 inline void log(Level, const T&);
2376#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
2377
2378 void initUnflushedCount(void);
2379
2381 return m_stream;
2382 }
2383
2384 void resolveLoggerFormatSpec(void) const;
2385};
2386namespace base {
2388class RegisteredLoggers : public base::utils::Registry<Logger, std::string> {
2389 public:
2390 explicit RegisteredLoggers(const LogBuilderPtr& defaultLogBuilder);
2391
2392 virtual ~RegisteredLoggers(void) {
2394 }
2395
2396 inline void setDefaultConfigurations(const Configurations& configurations) {
2397 base::threading::ScopedLock scopedLock(lock());
2398 m_defaultConfigurations.setFromBase(const_cast<Configurations*>(&configurations));
2399 }
2400
2404
2405 Logger* get(const std::string& id, bool forceCreation = true);
2406
2407 template <typename T>
2412
2413 template <typename T>
2417
2418 template <typename T>
2422
2423 bool remove(const std::string& id);
2424
2425 inline bool has(const std::string& id) {
2426 return get(id, false) != nullptr;
2427 }
2428
2429 inline void unregister(Logger*& logger) {
2430 base::threading::ScopedLock scopedLock(lock());
2432 }
2433
2437
2438 inline void flushAll(void) {
2439 base::threading::ScopedLock scopedLock(lock());
2441 }
2442
2443 inline void setDefaultLogBuilder(LogBuilderPtr& logBuilderPtr) {
2444 base::threading::ScopedLock scopedLock(lock());
2445 m_defaultLogBuilder = logBuilderPtr;
2446 }
2447
2448 private:
2452 std::unordered_map<std::string, base::type::LoggerRegistrationCallbackPtr> m_loggerRegistrationCallbacks;
2453 friend class el::base::Storage;
2454
2455 void unsafeFlushAll(void);
2456};
2457
2459 public:
2461
2464
2465 inline base::type::VerboseLevel level(void) const {
2466 return m_level;
2467 }
2468
2469 void clearCategories(void);
2470
2471 inline void clearModules(void) {
2472 base::threading::ScopedLock scopedLock(lock());
2473 m_modules.clear();
2474 }
2475
2476 void setCategories(const char* categories, bool clear = true);
2477
2478 std::string getCategories();
2479
2480 void setModules(const char* modules);
2481
2482 bool priority_allowed(int priority, const std::string &category);
2483 bool allowed(Level level, const std::string &category);
2484
2485 bool allowed(base::type::VerboseLevel vlevel, const char* file);
2486
2487 inline const std::unordered_map<std::string, base::type::VerboseLevel>& modules(void) const {
2488 return m_modules;
2489 }
2490
2491 void setFromArgs(const base::utils::CommandLineArgs* commandLineArgs);
2492
2497
2498 inline void setFilenameCommonPrefix(const std::string &prefix) {
2499 m_filenameCommonPrefix = prefix;
2500 }
2501
2502 inline const std::string &getFilenameCommonPrefix() const {
2504 }
2505
2506 private:
2509 std::unordered_map<std::string, base::type::VerboseLevel> m_modules;
2510 std::vector<std::pair<std::string, Level>> m_categories;
2511 std::map<std::string, int> m_cached_allowed_categories;
2514};
2515} // namespace base
2517 public:
2518 LogMessage(Level level, Color color, const std::string& file, base::type::LineNumber line, const std::string& func,
2521 m_verboseLevel(verboseLevel), m_logger(logger), m_message(msg ? *msg : logger->stream().str()) {
2522 }
2523 inline Level level(void) const {
2524 return m_level;
2525 }
2526 inline Color color(void) const {
2527 return m_color;
2528 }
2529 inline const std::string& file(void) const {
2530 return m_file;
2531 }
2532 inline base::type::LineNumber line(void) const {
2533 return m_line;
2534 }
2535 inline const std::string& func(void) const {
2536 return m_func;
2537 }
2539 return m_verboseLevel;
2540 }
2541 inline Logger* logger(void) const {
2542 return m_logger;
2543 }
2544 inline const base::type::string_t& message(void) const {
2545 return m_message;
2546 }
2547 private:
2550 std::string m_file;
2552 std::string m_func;
2556};
2557namespace base {
2558#if ELPP_ASYNC_LOGGING
2559class AsyncLogItem {
2560 public:
2561 explicit AsyncLogItem(const LogMessage& logMessage, const LogDispatchData& data, const base::type::string_t& logLine)
2562 : m_logMessage(logMessage), m_dispatchData(data), m_logLine(logLine) {}
2563 virtual ~AsyncLogItem() {}
2564 inline LogMessage* logMessage(void) {
2565 return &m_logMessage;
2566 }
2567 inline LogDispatchData* data(void) {
2568 return &m_dispatchData;
2569 }
2570 inline base::type::string_t logLine(void) {
2571 return m_logLine;
2572 }
2573 private:
2574 LogMessage m_logMessage;
2575 LogDispatchData m_dispatchData;
2576 base::type::string_t m_logLine;
2577};
2578class AsyncLogQueue : public base::threading::ThreadSafe {
2579 public:
2580 virtual ~AsyncLogQueue() {
2581 ELPP_INTERNAL_INFO(6, "~AsyncLogQueue");
2582 }
2583
2584 inline AsyncLogItem next(void) {
2585 base::threading::ScopedLock scopedLock(lock());
2586 AsyncLogItem result = m_queue.front();
2587 m_queue.pop();
2588 return result;
2589 }
2590
2591 inline void push(const AsyncLogItem& item) {
2592 base::threading::ScopedLock scopedLock(lock());
2593 m_queue.push(item);
2594 }
2595 inline void pop(void) {
2596 base::threading::ScopedLock scopedLock(lock());
2597 m_queue.pop();
2598 }
2599 inline AsyncLogItem front(void) {
2600 base::threading::ScopedLock scopedLock(lock());
2601 return m_queue.front();
2602 }
2603 inline bool empty(void) {
2604 base::threading::ScopedLock scopedLock(lock());
2605 return m_queue.empty();
2606 }
2607 private:
2608 std::queue<AsyncLogItem> m_queue;
2609};
2610class IWorker {
2611 public:
2612 virtual ~IWorker() {}
2613 virtual void start() = 0;
2614};
2615#endif // ELPP_ASYNC_LOGGING
2617class Storage : base::NoCopy, public base::threading::ThreadSafe {
2618 public:
2619#if ELPP_ASYNC_LOGGING
2620 Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker);
2621#else
2622 explicit Storage(const LogBuilderPtr& defaultLogBuilder);
2623#endif // ELPP_ASYNC_LOGGING
2624
2625 virtual ~Storage(void);
2626
2627 inline bool validateEveryNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t occasion) {
2628 return hitCounters()->validateEveryN(filename, lineNumber, occasion);
2629 }
2630
2631 inline bool validateAfterNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
2632 return hitCounters()->validateAfterN(filename, lineNumber, n);
2633 }
2634
2635 inline bool validateNTimesCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
2636 return hitCounters()->validateNTimes(filename, lineNumber, n);
2637 }
2638
2641 }
2642
2644 return m_registeredLoggers;
2645 }
2646
2647 inline base::VRegistry* vRegistry(void) const {
2648 return m_vRegistry;
2649 }
2650
2651#if ELPP_ASYNC_LOGGING
2652 inline base::AsyncLogQueue* asyncLogQueue(void) const {
2653 return m_asyncLogQueue;
2654 }
2655#endif // ELPP_ASYNC_LOGGING
2656
2658 return &m_commandLineArgs;
2659 }
2660
2661 inline void addFlag(LoggingFlag flag) {
2663 }
2664
2665 inline void removeFlag(LoggingFlag flag) {
2667 }
2668
2669 inline bool hasFlag(LoggingFlag flag) const {
2670 return base::utils::hasFlag(flag, m_flags);
2671 }
2672
2673 inline base::type::EnumType flags(void) const {
2674 return m_flags;
2675 }
2676
2678 m_flags = flags;
2679 }
2680
2681 inline void setPreRollOutCallback(const PreRollOutCallback& callback) {
2682 m_preRollOutCallback = callback;
2683 }
2684
2688
2692
2693 bool hasCustomFormatSpecifier(const char* formatSpecifier);
2694 void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier);
2695 bool uninstallCustomFormatSpecifier(const char* formatSpecifier);
2696
2697 const std::vector<CustomFormatSpecifier>* customFormatSpecifiers(void) const {
2699 }
2700
2704
2705 inline void setLoggingLevel(Level level) {
2706 m_loggingLevel = level;
2707 }
2708
2709 template <typename T>
2713
2714 template <typename T>
2718 template <typename T>
2722
2723#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
2724 template <typename T>
2725 inline bool installPerformanceTrackingCallback(const std::string& id) {
2727 &m_performanceTrackingCallbacks);
2728 }
2729
2730 template <typename T>
2731 inline void uninstallPerformanceTrackingCallback(const std::string& id) {
2733 &m_performanceTrackingCallbacks);
2734 }
2735
2736 template <typename T>
2737 inline T* performanceTrackingCallback(const std::string& id) {
2738 return base::utils::Utils::callback<T, base::type::PerformanceTrackingCallbackPtr>(id, &m_performanceTrackingCallbacks);
2739 }
2740#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
2741
2743 inline void setThreadName(const std::string& name) {
2744 if (name.empty()) return;
2747 }
2748
2749 inline std::string getThreadName(const std::string& threadId) {
2751 std::unordered_map<std::string, std::string>::const_iterator it = m_threadNames.find(threadId);
2752 if (it == m_threadNames.end()) {
2753 return threadId;
2754 }
2755 return it->second;
2756 }
2757
2758 static el::base::type::StoragePointer &getELPP();
2759
2760 private:
2765#if ELPP_ASYNC_LOGGING
2766 base::AsyncLogQueue* m_asyncLogQueue;
2767 base::IWorker* m_asyncDispatchWorker;
2768#endif // ELPP_ASYNC_LOGGING
2771 std::unordered_map<std::string, base::type::LogDispatchCallbackPtr> m_logDispatchCallbacks;
2772 std::unordered_map<std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
2773 std::unordered_map<std::string, std::string> m_threadNames;
2774 std::vector<CustomFormatSpecifier> m_customFormatSpecifiers;
2778
2779 friend class el::Helpers;
2781 friend class el::LogBuilder;
2783 friend class el::base::Writer;
2784 friend class el::base::PerformanceTracker;
2786
2787 void setApplicationArguments(int argc, char** argv);
2788
2789 inline void setApplicationArguments(int argc, const char** argv) {
2790 setApplicationArguments(argc, const_cast<char**>(argv));
2791 }
2792};
2794ELPP_EXPORT void sanitize(std::string& s);
2795#define ELPP el::base::Storage::getELPP()
2797 protected:
2798 void handle(const LogDispatchData* data);
2799 private:
2801 void dispatch(base::type::string_t&& rawLinePrefix, base::type::string_t&& rawLinePayload, base::type::string_t&& logLine);
2802};
2803#if ELPP_ASYNC_LOGGING
2804class AsyncLogDispatchCallback : public LogDispatchCallback {
2805 protected:
2806 void handle(const LogDispatchData* data);
2807};
2808class AsyncDispatchWorker : public base::IWorker, public base::threading::ThreadSafe {
2809 public:
2810 AsyncDispatchWorker();
2811 virtual ~AsyncDispatchWorker();
2812
2813 bool clean(void);
2814 void emptyQueue(void);
2815 virtual void start(void);
2816 void handle(AsyncLogItem* logItem);
2817 void run(void);
2818
2819 void setContinueRunning(bool value) {
2820 base::threading::ScopedLock scopedLock(m_continueRunningLock);
2821 m_continueRunning = value;
2822 }
2823
2824 bool continueRunning(void) const {
2825 return m_continueRunning;
2826 }
2827 private:
2828 std::condition_variable cv;
2829 bool m_continueRunning;
2830 base::threading::Mutex m_continueRunningLock;
2831};
2832#endif // ELPP_ASYNC_LOGGING
2833} // namespace base
2834namespace base {
2836 public:
2837 base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const;
2838};
2839
2841 public:
2842 LogDispatcher(bool proceed, LogMessage* logMessage, base::DispatchAction dispatchAction) :
2843 m_proceed(proceed),
2844 m_logMessage(logMessage),
2845 m_dispatchAction(std::move(dispatchAction)) {
2846 }
2847
2848 void dispatch(void);
2849
2850 private:
2854};
2855#if defined(ELPP_STL_LOGGING)
2862namespace workarounds {
2864template <typename T, typename Container>
2865class IterableContainer {
2866 public:
2867 typedef typename Container::iterator iterator;
2868 typedef typename Container::const_iterator const_iterator;
2869 IterableContainer(void) {}
2870 virtual ~IterableContainer(void) {}
2871 iterator begin(void) {
2872 return getContainer().begin();
2873 }
2874 iterator end(void) {
2875 return getContainer().end();
2876 }
2877 private:
2878 virtual Container& getContainer(void) = 0;
2879};
2881template<typename T, typename Container = std::vector<T>, typename Comparator = std::less<typename Container::value_type>>
2882class IterablePriorityQueue : public IterableContainer<T, Container>,
2883 public std::priority_queue<T, Container, Comparator> {
2884 public:
2885 IterablePriorityQueue(std::priority_queue<T, Container, Comparator> queue_) {
2886 std::size_t count_ = 0;
2887 while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) {
2888 this->push(queue_.top());
2889 queue_.pop();
2890 }
2891 }
2892 private:
2893 inline Container& getContainer(void) {
2894 return this->c;
2895 }
2896};
2898template<typename T, typename Container = std::deque<T>>
2899class IterableQueue : public IterableContainer<T, Container>, public std::queue<T, Container> {
2900 public:
2901 IterableQueue(std::queue<T, Container> queue_) {
2902 std::size_t count_ = 0;
2903 while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) {
2904 this->push(queue_.front());
2905 queue_.pop();
2906 }
2907 }
2908 private:
2909 inline Container& getContainer(void) {
2910 return this->c;
2911 }
2912};
2914template<typename T, typename Container = std::deque<T>>
2915class IterableStack : public IterableContainer<T, Container>, public std::stack<T, Container> {
2916 public:
2917 IterableStack(std::stack<T, Container> stack_) {
2918 std::size_t count_ = 0;
2919 while (++count_ < base::consts::kMaxLogPerContainer && !stack_.empty()) {
2920 this->push(stack_.top());
2921 stack_.pop();
2922 }
2923 }
2924 private:
2925 inline Container& getContainer(void) {
2926 return this->c;
2927 }
2928};
2929} // namespace workarounds
2930#endif // defined(ELPP_STL_LOGGING)
2931// Log message builder
2933 public:
2935 void initialize(Logger* logger);
2936
2937# define ELPP_SIMPLE_LOG(LOG_TYPE)\
2938MessageBuilder& operator<<(LOG_TYPE msg) {\
2939m_logger->stream() << msg;\
2940if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {\
2941m_logger->stream() << " ";\
2942}\
2943return *this;\
2944}
2945
2946 inline MessageBuilder& operator<<(const std::string& msg) {
2947 return operator<<(msg.c_str());
2948 }
2949 ELPP_SIMPLE_LOG(char)
2950 ELPP_SIMPLE_LOG(bool)
2951 ELPP_SIMPLE_LOG(signed short)
2952 ELPP_SIMPLE_LOG(unsigned short)
2953 ELPP_SIMPLE_LOG(signed int)
2954 ELPP_SIMPLE_LOG(unsigned int)
2955 ELPP_SIMPLE_LOG(signed long)
2956 ELPP_SIMPLE_LOG(unsigned long)
2957 ELPP_SIMPLE_LOG(float)
2958 ELPP_SIMPLE_LOG(double)
2959 ELPP_SIMPLE_LOG(char*)
2960 ELPP_SIMPLE_LOG(const char*)
2961 ELPP_SIMPLE_LOG(const void*)
2962 ELPP_SIMPLE_LOG(long double)
2963 inline MessageBuilder& operator<<(const std::wstring& msg) {
2964 return operator<<(msg.c_str());
2965 }
2966 MessageBuilder& operator<<(const wchar_t* msg);
2967 // ostream manipulators
2968 inline MessageBuilder& operator<<(std::ostream& (*OStreamMani)(std::ostream&)) {
2969 m_logger->stream() << OStreamMani;
2970 return *this;
2971 }
2972#define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp) \
2973template <typename T> \
2974inline MessageBuilder& operator<<(const temp<T>& template_inst) { \
2975return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2976}
2977#define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp) \
2978template <typename T1, typename T2> \
2979inline MessageBuilder& operator<<(const temp<T1, T2>& template_inst) { \
2980return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2981}
2982#define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp) \
2983template <typename T1, typename T2, typename T3> \
2984inline MessageBuilder& operator<<(const temp<T1, T2, T3>& template_inst) { \
2985return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2986}
2987#define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp) \
2988template <typename T1, typename T2, typename T3, typename T4> \
2989inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4>& template_inst) { \
2990return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2991}
2992#define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp) \
2993template <typename T1, typename T2, typename T3, typename T4, typename T5> \
2994inline MessageBuilder& operator<<(const temp<T1, T2, T3, T4, T5>& template_inst) { \
2995return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \
2996}
2997
2998#if defined(ELPP_STL_LOGGING)
3006 template <class T, class Container>
3007 inline MessageBuilder& operator<<(const std::queue<T, Container>& queue_) {
3008 base::workarounds::IterableQueue<T, Container> iterableQueue_ =
3009 static_cast<base::workarounds::IterableQueue<T, Container> >(queue_);
3010 return writeIterator(iterableQueue_.begin(), iterableQueue_.end(), iterableQueue_.size());
3011 }
3012 template <class T, class Container>
3013 inline MessageBuilder& operator<<(const std::stack<T, Container>& stack_) {
3014 base::workarounds::IterableStack<T, Container> iterableStack_ =
3015 static_cast<base::workarounds::IterableStack<T, Container> >(stack_);
3016 return writeIterator(iterableStack_.begin(), iterableStack_.end(), iterableStack_.size());
3017 }
3018 template <class T, class Container, class Comparator>
3019 inline MessageBuilder& operator<<(const std::priority_queue<T, Container, Comparator>& priorityQueue_) {
3020 base::workarounds::IterablePriorityQueue<T, Container, Comparator> iterablePriorityQueue_ =
3021 static_cast<base::workarounds::IterablePriorityQueue<T, Container, Comparator> >(priorityQueue_);
3022 return writeIterator(iterablePriorityQueue_.begin(), iterablePriorityQueue_.end(), iterablePriorityQueue_.size());
3023 }
3024 template <class First, class Second>
3025 MessageBuilder& operator<<(const std::pair<First, Second>& pair_) {
3026 m_logger->stream() << ELPP_LITERAL("(");
3027 operator << (static_cast<First>(pair_.first));
3028 m_logger->stream() << ELPP_LITERAL(", ");
3029 operator << (static_cast<Second>(pair_.second));
3030 m_logger->stream() << ELPP_LITERAL(")");
3031 return *this;
3032 }
3033 template <std::size_t Size>
3034 MessageBuilder& operator<<(const std::bitset<Size>& bitset_) {
3035 m_logger->stream() << ELPP_LITERAL("[");
3036 operator << (bitset_.to_string());
3037 m_logger->stream() << ELPP_LITERAL("]");
3038 return *this;
3039 }
3040# if defined(ELPP_LOG_STD_ARRAY)
3041 template <class T, std::size_t Size>
3042 inline MessageBuilder& operator<<(const std::array<T, Size>& array) {
3043 return writeIterator(array.begin(), array.end(), array.size());
3044 }
3045# endif // defined(ELPP_LOG_STD_ARRAY)
3046# if defined(ELPP_LOG_UNORDERED_MAP)
3047 ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_map)
3048 ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_multimap)
3049# endif // defined(ELPP_LOG_UNORDERED_MAP)
3050# if defined(ELPP_LOG_UNORDERED_SET)
3051 ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_set)
3052 ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_multiset)
3053# endif // defined(ELPP_LOG_UNORDERED_SET)
3054#endif // defined(ELPP_STL_LOGGING)
3055#if defined(ELPP_QT_LOGGING)
3056 inline MessageBuilder& operator<<(const QString& msg) {
3057# if defined(ELPP_UNICODE)
3058 m_logger->stream() << msg.toStdWString();
3059# else
3060 m_logger->stream() << msg.toStdString();
3061# endif // defined(ELPP_UNICODE)
3062 return *this;
3063 }
3064 inline MessageBuilder& operator<<(const QByteArray& msg) {
3065 return operator << (QString(msg));
3066 }
3067 inline MessageBuilder& operator<<(const QStringRef& msg) {
3068 return operator<<(msg.toString());
3069 }
3070 inline MessageBuilder& operator<<(qint64 msg) {
3071# if defined(ELPP_UNICODE)
3072 m_logger->stream() << QString::number(msg).toStdWString();
3073# else
3074 m_logger->stream() << QString::number(msg).toStdString();
3075# endif // defined(ELPP_UNICODE)
3076 return *this;
3077 }
3078 inline MessageBuilder& operator<<(quint64 msg) {
3079# if defined(ELPP_UNICODE)
3080 m_logger->stream() << QString::number(msg).toStdWString();
3081# else
3082 m_logger->stream() << QString::number(msg).toStdString();
3083# endif // defined(ELPP_UNICODE)
3084 return *this;
3085 }
3086 inline MessageBuilder& operator<<(QChar msg) {
3087 m_logger->stream() << msg.toLatin1();
3088 return *this;
3089 }
3090 inline MessageBuilder& operator<<(const QLatin1String& msg) {
3091 m_logger->stream() << msg.latin1();
3092 return *this;
3093 }
3100 template <typename First, typename Second>
3101 MessageBuilder& operator<<(const QPair<First, Second>& pair_) {
3102 m_logger->stream() << ELPP_LITERAL("(");
3103 operator << (static_cast<First>(pair_.first));
3104 m_logger->stream() << ELPP_LITERAL(", ");
3105 operator << (static_cast<Second>(pair_.second));
3106 m_logger->stream() << ELPP_LITERAL(")");
3107 return *this;
3108 }
3109 template <typename K, typename V>
3110 MessageBuilder& operator<<(const QMap<K, V>& map_) {
3111 m_logger->stream() << ELPP_LITERAL("[");
3112 QList<K> keys = map_.keys();
3113 typename QList<K>::const_iterator begin = keys.begin();
3114 typename QList<K>::const_iterator end = keys.end();
3115 int max_ = static_cast<int>(base::consts::kMaxLogPerContainer); // to prevent warning
3116 for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) {
3117 m_logger->stream() << ELPP_LITERAL("(");
3118 operator << (static_cast<K>(*begin));
3119 m_logger->stream() << ELPP_LITERAL(", ");
3120 operator << (static_cast<V>(map_.value(*begin)));
3121 m_logger->stream() << ELPP_LITERAL(")");
3122 m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator : ELPP_LITERAL(""));
3123 }
3124 if (begin != end) {
3125 m_logger->stream() << ELPP_LITERAL("...");
3126 }
3127 m_logger->stream() << ELPP_LITERAL("]");
3128 return *this;
3129 }
3130 template <typename K, typename V>
3131 inline MessageBuilder& operator<<(const QMultiMap<K, V>& map_) {
3132 operator << (static_cast<QMap<K, V>>(map_));
3133 return *this;
3134 }
3135 template <typename K, typename V>
3136 MessageBuilder& operator<<(const QHash<K, V>& hash_) {
3137 m_logger->stream() << ELPP_LITERAL("[");
3138 QList<K> keys = hash_.keys();
3139 typename QList<K>::const_iterator begin = keys.begin();
3140 typename QList<K>::const_iterator end = keys.end();
3141 int max_ = static_cast<int>(base::consts::kMaxLogPerContainer); // prevent type warning
3142 for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) {
3143 m_logger->stream() << ELPP_LITERAL("(");
3144 operator << (static_cast<K>(*begin));
3145 m_logger->stream() << ELPP_LITERAL(", ");
3146 operator << (static_cast<V>(hash_.value(*begin)));
3147 m_logger->stream() << ELPP_LITERAL(")");
3148 m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator : ELPP_LITERAL(""));
3149 }
3150 if (begin != end) {
3151 m_logger->stream() << ELPP_LITERAL("...");
3152 }
3153 m_logger->stream() << ELPP_LITERAL("]");
3154 return *this;
3155 }
3156 template <typename K, typename V>
3157 inline MessageBuilder& operator<<(const QMultiHash<K, V>& multiHash_) {
3158 operator << (static_cast<QHash<K, V>>(multiHash_));
3159 return *this;
3160 }
3161#endif // defined(ELPP_QT_LOGGING)
3162#if defined(ELPP_BOOST_LOGGING)
3163 ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::vector)
3164 ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::stable_vector)
3165 ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::list)
3166 ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::deque)
3167 ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::map)
3168 ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::flat_map)
3169 ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(boost::container::set)
3170 ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(boost::container::flat_set)
3171#endif // defined(ELPP_BOOST_LOGGING)
3172
3181#define MAKE_CONTAINERELPP_FRIENDLY(ContainerType, SizeMethod, ElementInstance) \
3182el::base::type::ostream_t& operator<<(el::base::type::ostream_t& ss, const ContainerType& container) {\
3183const el::base::type::char_t* sep = ELPP->hasFlag(el::LoggingFlag::NewLineForContainer) ? \
3184ELPP_LITERAL("\n ") : ELPP_LITERAL(", ");\
3185ContainerType::const_iterator elem = container.begin();\
3186ContainerType::const_iterator endElem = container.end();\
3187std::size_t size_ = container.SizeMethod; \
3188ss << ELPP_LITERAL("[");\
3189for (std::size_t i = 0; elem != endElem && i < el::base::consts::kMaxLogPerContainer; ++i, ++elem) { \
3190ss << ElementInstance;\
3191ss << ((i < size_ - 1) ? sep : ELPP_LITERAL(""));\
3192}\
3193if (elem != endElem) {\
3194ss << ELPP_LITERAL("...");\
3195}\
3196ss << ELPP_LITERAL("]");\
3197return ss;\
3198}
3199#if defined(ELPP_WXWIDGETS_LOGGING)
3201# define ELPP_WX_PTR_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), *(*elem))
3202# define ELPP_WX_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), (*elem))
3203# define ELPP_WX_HASH_MAP_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), \
3204ELPP_LITERAL("(") << elem->first << ELPP_LITERAL(", ") << elem->second << ELPP_LITERAL(")")
3205#else
3206# define ELPP_WX_PTR_ENABLED(ContainerType)
3207# define ELPP_WX_ENABLED(ContainerType)
3208# define ELPP_WX_HASH_MAP_ENABLED(ContainerType)
3209#endif // defined(ELPP_WXWIDGETS_LOGGING)
3210 // Other classes
3211 template <class Class>
3212 ELPP_SIMPLE_LOG(const Class&)
3213#undef ELPP_SIMPLE_LOG
3214#undef ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG
3215#undef ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG
3216#undef ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG
3217#undef ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG
3218#undef ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG
3219 private:
3222
3223 template<class Iterator>
3224 MessageBuilder& writeIterator(Iterator begin_, Iterator end_, std::size_t size_) {
3225 m_logger->stream() << ELPP_LITERAL("[");
3226 for (std::size_t i = 0; begin_ != end_ && i < base::consts::kMaxLogPerContainer; ++i, ++begin_) {
3227 operator << (*begin_);
3228 m_logger->stream() << ((i < size_ - 1) ? m_containerLogSeperator : ELPP_LITERAL(""));
3229 }
3230 if (begin_ != end_) {
3231 m_logger->stream() << ELPP_LITERAL("...");
3232 }
3233 m_logger->stream() << ELPP_LITERAL("]");
3234 if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {
3235 m_logger->stream() << " ";
3236 }
3237 return *this;
3238 }
3239};
3240
3242 public:
3243 NullWriter(void) {}
3244
3245 // Null manipulator
3246 inline NullWriter& operator<<(std::ostream& (*)(std::ostream&)) {
3247 return *this;
3248 }
3249
3250 template <typename T>
3251 inline NullWriter& operator<<(const T&) {
3252 return *this;
3253 }
3254
3255 inline operator bool() {
3256 return true;
3257 }
3258};
3259
3261 public:
3262 Writer(Level level, Color color, const char* file, base::type::LineNumber line,
3263 const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog,
3264 base::type::VerboseLevel verboseLevel = 0) :
3265 m_msg(nullptr), m_level(level), m_color(color), m_file(file), m_line(line), m_func(func), m_verboseLevel(verboseLevel),
3266 m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction), m_sync(ELPP->lock()) {
3267 }
3268
3270 m_msg(msg), m_level(msg != nullptr ? msg->level() : Level::Unknown),
3271 m_line(0), m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction), m_sync(ELPP->lock()) {
3272 }
3273
3274 virtual ~Writer(void) {
3276 }
3277
3278 Writer& operator<<(const std::string &log) {
3279#if ELPP_LOGGING_ENABLED
3280 if (m_proceed) {
3281 m_messageBuilder << log;
3282 }
3283#endif // ELPP_LOGGING_ENABLED
3284 return *this;
3285 }
3286
3287 inline operator bool() {
3288 return true;
3289 }
3290
3291 Writer& construct(Logger* logger, bool needLock = true);
3292 Writer& construct(int count, const char* loggerIds, ...);
3293 Writer& construct(const char *loggerId);
3294 protected:
3298 const char* m_file;
3300 const char* m_func;
3306 std::vector<std::string> m_loggerIds;
3308 friend class el::Helpers;
3309
3310 void initializeLogger(const std::string& loggerId, bool lookup = true, bool needLock = true);
3311 void initializeLogger(Logger *logger, bool needLock = true);
3312 void processDispatch();
3313 void triggerDispatch(void);
3314};
3316 public:
3317 PErrorWriter(Level level, Color color, const char* file, base::type::LineNumber line,
3318 const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog,
3319 base::type::VerboseLevel verboseLevel = 0) :
3320 base::Writer(level, color, file, line, func, dispatchAction, verboseLevel) {
3321 }
3322
3323 virtual ~PErrorWriter(void);
3324};
3325} // namespace base
3326// Logging from Logger class. Why this is here? Because we have Storage and Writer class available
3327#if ELPP_VARIADIC_TEMPLATES_SUPPORTED
3328template <typename T, typename... Args>
3329void Logger::log_(Level level, int vlevel, const char* s, const T& value, const Args&... args) {
3330 base::MessageBuilder b;
3331 b.initialize(this);
3332 while (*s) {
3333 if (*s == base::consts::kFormatSpecifierChar) {
3334 if (*(s + 1) == base::consts::kFormatSpecifierChar) {
3335 ++s;
3336 } else {
3337 if (*(s + 1) == base::consts::kFormatSpecifierCharValue) {
3338 ++s;
3339 b << value;
3340 log_(level, vlevel, ++s, args...);
3341 return;
3342 }
3343 }
3344 }
3345 b << *s++;
3346 }
3347 ELPP_INTERNAL_ERROR("Too many arguments provided. Unable to handle. Please provide more format specifiers", false);
3348}
3349template <typename T>
3350void Logger::log_(Level level, int vlevel, const T& log) {
3351 if (level == Level::Verbose) {
3352 if (ELPP->vRegistry()->allowed(vlevel, __FILE__)) {
3353 base::Writer(Level::Verbose, Color::Default, "FILE", 0, "FUNCTION",
3354 base::DispatchAction::NormalLog, vlevel).construct(this, false) << log;
3355 } else {
3356 stream().str(ELPP_LITERAL(""));
3357 releaseLock();
3358 }
3359 } else {
3360 base::Writer(level, Color::Default, "FILE", 0, "FUNCTION").construct(this, false) << log;
3361 }
3362}
3363template <typename T, typename... Args>
3364inline void Logger::log(Level level, const char* s, const T& value, const Args&... args) {
3365 acquireLock(); // released in Writer!
3366 log_(level, 0, s, value, args...);
3367}
3368template <typename T>
3369inline void Logger::log(Level level, const T& log) {
3370 acquireLock(); // released in Writer!
3371 log_(level, 0, log);
3372}
3373# if ELPP_VERBOSE_LOG
3374template <typename T, typename... Args>
3375inline void Logger::verbose(int vlevel, const char* s, const T& value, const Args&... args) {
3376 acquireLock(); // released in Writer!
3377 log_(el::Level::Verbose, vlevel, s, value, args...);
3378}
3379template <typename T>
3380inline void Logger::verbose(int vlevel, const T& log) {
3381 acquireLock(); // released in Writer!
3382 log_(el::Level::Verbose, vlevel, log);
3383}
3384# else
3385template <typename T, typename... Args>
3386inline void Logger::verbose(int, const char*, const T&, const Args&...) {
3387 return;
3388}
3389template <typename T>
3390inline void Logger::verbose(int, const T&) {
3391 return;
3392}
3393# endif // ELPP_VERBOSE_LOG
3394# define LOGGER_LEVEL_WRITERS(FUNCTION_NAME, LOG_LEVEL)\
3395template <typename T, typename... Args>\
3396inline void Logger::FUNCTION_NAME(const char* s, const T& value, const Args&... args) {\
3397log(LOG_LEVEL, s, value, args...);\
3398}\
3399template <typename T>\
3400inline void Logger::FUNCTION_NAME(const T& value) {\
3401log(LOG_LEVEL, value);\
3402}
3403# define LOGGER_LEVEL_WRITERS_DISABLED(FUNCTION_NAME, LOG_LEVEL)\
3404template <typename T, typename... Args>\
3405inline void Logger::FUNCTION_NAME(const char*, const T&, const Args&...) {\
3406return;\
3407}\
3408template <typename T>\
3409inline void Logger::FUNCTION_NAME(const T&) {\
3410return;\
3411}
3412
3413# if ELPP_INFO_LOG
3414LOGGER_LEVEL_WRITERS(info, Level::Info)
3415# else
3416LOGGER_LEVEL_WRITERS_DISABLED(info, Level::Info)
3417# endif // ELPP_INFO_LOG
3418# if ELPP_DEBUG_LOG
3419LOGGER_LEVEL_WRITERS(debug, Level::Debug)
3420# else
3421LOGGER_LEVEL_WRITERS_DISABLED(debug, Level::Debug)
3422# endif // ELPP_DEBUG_LOG
3423# if ELPP_WARNING_LOG
3424LOGGER_LEVEL_WRITERS(warn, Level::Warning)
3425# else
3426LOGGER_LEVEL_WRITERS_DISABLED(warn, Level::Warning)
3427# endif // ELPP_WARNING_LOG
3428# if ELPP_ERROR_LOG
3429LOGGER_LEVEL_WRITERS(error, Level::Error)
3430# else
3431LOGGER_LEVEL_WRITERS_DISABLED(error, Level::Error)
3432# endif // ELPP_ERROR_LOG
3433# if ELPP_FATAL_LOG
3434LOGGER_LEVEL_WRITERS(fatal, Level::Fatal)
3435# else
3436LOGGER_LEVEL_WRITERS_DISABLED(fatal, Level::Fatal)
3437# endif // ELPP_FATAL_LOG
3438# if ELPP_TRACE_LOG
3439LOGGER_LEVEL_WRITERS(trace, Level::Trace)
3440# else
3441LOGGER_LEVEL_WRITERS_DISABLED(trace, Level::Trace)
3442# endif // ELPP_TRACE_LOG
3443# undef LOGGER_LEVEL_WRITERS
3444# undef LOGGER_LEVEL_WRITERS_DISABLED
3445#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
3446#if ELPP_COMPILER_MSVC
3447# define ELPP_VARIADIC_FUNC_MSVC(variadicFunction, variadicArgs) variadicFunction variadicArgs
3448# define ELPP_VARIADIC_FUNC_MSVC_RUN(variadicFunction, ...) ELPP_VARIADIC_FUNC_MSVC(variadicFunction, (__VA_ARGS__))
3449# define el_getVALength(...) ELPP_VARIADIC_FUNC_MSVC_RUN(el_resolveVALength, 0, ## __VA_ARGS__,\
345010, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
3451#else
3452# if ELPP_COMPILER_CLANG
3453# define el_getVALength(...) el_resolveVALength(0, __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
3454# else
3455# define el_getVALength(...) el_resolveVALength(0, ## __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
3456# endif // ELPP_COMPILER_CLANG
3457#endif // ELPP_COMPILER_MSVC
3458#define el_resolveVALength(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
3459#define ELPP_WRITE_LOG(writer, level, dispatchAction, ...) \
3460writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3461#define ELPP_WRITE_LOG_IF(writer, condition, level, dispatchAction, ...) if (condition) \
3462writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3463#define ELPP_WRITE_LOG_EVERY_N(writer, occasion, level, dispatchAction, ...) \
3464ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion) && \
3465writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3466#define ELPP_WRITE_LOG_AFTER_N(writer, n, level, dispatchAction, ...) \
3467ELPP->validateAfterNCounter(__FILE__, __LINE__, n) && \
3468writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3469#define ELPP_WRITE_LOG_N_TIMES(writer, n, level, dispatchAction, ...) \
3470ELPP->validateNTimesCounter(__FILE__, __LINE__, n) && \
3471writer(level, el::Color::Default, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
3472#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3473class PerformanceTrackingData {
3474 public:
3475 enum class DataType : base::type::EnumType {
3476 Checkpoint = 1, Complete = 2
3477 };
3478 // Do not use constructor, will run into multiple definition error, use init(PerformanceTracker*)
3479 explicit PerformanceTrackingData(DataType dataType) : m_performanceTracker(nullptr),
3480 m_dataType(dataType), m_firstCheckpoint(false), m_file(""), m_line(0), m_func("") {}
3481 inline const std::string* blockName(void) const;
3482 inline const struct timeval* startTime(void) const;
3483 inline const struct timeval* endTime(void) const;
3484 inline const struct timeval* lastCheckpointTime(void) const;
3485 inline const base::PerformanceTracker* performanceTracker(void) const {
3486 return m_performanceTracker;
3487 }
3488 inline PerformanceTrackingData::DataType dataType(void) const {
3489 return m_dataType;
3490 }
3491 inline bool firstCheckpoint(void) const {
3492 return m_firstCheckpoint;
3493 }
3494 inline std::string checkpointId(void) const {
3495 return m_checkpointId;
3496 }
3497 inline const char* file(void) const {
3498 return m_file;
3499 }
3500 inline base::type::LineNumber line(void) const {
3501 return m_line;
3502 }
3503 inline const char* func(void) const {
3504 return m_func;
3505 }
3506 inline const base::type::string_t* formattedTimeTaken() const {
3507 return &m_formattedTimeTaken;
3508 }
3509 inline const std::string& loggerId(void) const;
3510 private:
3511 base::PerformanceTracker* m_performanceTracker;
3512 base::type::string_t m_formattedTimeTaken;
3513 PerformanceTrackingData::DataType m_dataType;
3514 bool m_firstCheckpoint;
3515 std::string m_checkpointId;
3516 const char* m_file;
3517 base::type::LineNumber m_line;
3518 const char* m_func;
3519 inline void init(base::PerformanceTracker* performanceTracker, bool firstCheckpoint = false) {
3520 m_performanceTracker = performanceTracker;
3521 m_firstCheckpoint = firstCheckpoint;
3522 }
3523
3524 friend class el::base::PerformanceTracker;
3525};
3526namespace base {
3529class PerformanceTracker : public base::threading::ThreadSafe, public Loggable {
3530 public:
3531 PerformanceTracker(const std::string& blockName,
3532 base::TimestampUnit timestampUnit = base::TimestampUnit::Millisecond,
3533 const std::string& loggerId = std::string(el::base::consts::kPerformanceLoggerId),
3534 bool scopedLog = true, Level level = base::consts::kPerformanceTrackerDefaultLevel);
3536 PerformanceTracker(const PerformanceTracker& t) :
3537 m_blockName(t.m_blockName), m_timestampUnit(t.m_timestampUnit), m_loggerId(t.m_loggerId), m_scopedLog(t.m_scopedLog),
3538 m_level(t.m_level), m_hasChecked(t.m_hasChecked), m_lastCheckpointId(t.m_lastCheckpointId), m_enabled(t.m_enabled),
3539 m_startTime(t.m_startTime), m_endTime(t.m_endTime), m_lastCheckpointTime(t.m_lastCheckpointTime) {
3540 }
3541 virtual ~PerformanceTracker(void);
3543 void checkpoint(const std::string& id = std::string(), const char* file = __FILE__,
3544 base::type::LineNumber line = __LINE__,
3545 const char* func = "");
3546 inline Level level(void) const {
3547 return m_level;
3548 }
3549 private:
3550 std::string m_blockName;
3551 base::TimestampUnit m_timestampUnit;
3552 std::string m_loggerId;
3553 bool m_scopedLog;
3554 Level m_level;
3555 bool m_hasChecked;
3556 std::string m_lastCheckpointId;
3557 bool m_enabled;
3558 struct timeval m_startTime, m_endTime, m_lastCheckpointTime;
3559
3560 PerformanceTracker(void);
3561
3562 friend class el::PerformanceTrackingData;
3563 friend class base::DefaultPerformanceTrackingCallback;
3564
3565 const inline base::type::string_t getFormattedTimeTaken() const {
3566 return getFormattedTimeTaken(m_startTime);
3567 }
3568
3569 const base::type::string_t getFormattedTimeTaken(struct timeval startTime) const;
3570
3571 virtual inline void log(el::base::type::ostream_t& os) const {
3572 os << getFormattedTimeTaken();
3573 }
3574};
3575class DefaultPerformanceTrackingCallback : public PerformanceTrackingCallback {
3576 protected:
3577 void handle(const PerformanceTrackingData* data) {
3578 m_data = data;
3579 base::type::stringstream_t ss;
3580 if (m_data->dataType() == PerformanceTrackingData::DataType::Complete) {
3581 ss << ELPP_LITERAL("Executed [") << m_data->blockName()->c_str() << ELPP_LITERAL("] in [") <<
3582 *m_data->formattedTimeTaken() << ELPP_LITERAL("]");
3583 } else {
3584 ss << ELPP_LITERAL("Performance checkpoint");
3585 if (!m_data->checkpointId().empty()) {
3586 ss << ELPP_LITERAL(" [") << m_data->checkpointId().c_str() << ELPP_LITERAL("]");
3587 }
3588 ss << ELPP_LITERAL(" for block [") << m_data->blockName()->c_str() << ELPP_LITERAL("] : [") <<
3589 *m_data->performanceTracker();
3590 if (!ELPP->hasFlag(LoggingFlag::DisablePerformanceTrackingCheckpointComparison)
3591 && m_data->performanceTracker()->m_hasChecked) {
3592 ss << ELPP_LITERAL(" ([") << *m_data->formattedTimeTaken() << ELPP_LITERAL("] from ");
3593 if (m_data->performanceTracker()->m_lastCheckpointId.empty()) {
3594 ss << ELPP_LITERAL("last checkpoint");
3595 } else {
3596 ss << ELPP_LITERAL("checkpoint '") << m_data->performanceTracker()->m_lastCheckpointId.c_str() << ELPP_LITERAL("'");
3597 }
3598 ss << ELPP_LITERAL(")]");
3599 } else {
3600 ss << ELPP_LITERAL("]");
3601 }
3602 }
3603 const std::string str = ss.str();
3604 el::base::Writer(m_data->performanceTracker()->level(), m_data->file(), m_data->line(), m_data->func()).construct(1,
3605 m_data->loggerId().c_str()) << str;
3606 }
3607 private:
3608 const PerformanceTrackingData* m_data;
3609};
3610} // namespace base
3611inline const std::string* PerformanceTrackingData::blockName() const {
3612 return const_cast<const std::string*>(&m_performanceTracker->m_blockName);
3613}
3614inline const struct timeval* PerformanceTrackingData::startTime() const {
3615 return const_cast<const struct timeval*>(&m_performanceTracker->m_startTime);
3616}
3617inline const struct timeval* PerformanceTrackingData::endTime() const {
3618 return const_cast<const struct timeval*>(&m_performanceTracker->m_endTime);
3619}
3620inline const struct timeval* PerformanceTrackingData::lastCheckpointTime() const {
3621 return const_cast<const struct timeval*>(&m_performanceTracker->m_lastCheckpointTime);
3622}
3623inline const std::string& PerformanceTrackingData::loggerId(void) const {
3624 return m_performanceTracker->m_loggerId;
3625}
3626#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3627namespace base {
3629namespace debug {
3630#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3631class StackTrace : base::NoCopy {
3632 public:
3633 static const unsigned int kMaxStack = 64;
3634 static const unsigned int kStackStart = 2; // We want to skip c'tor and StackTrace::generateNew()
3635 class StackTraceEntry {
3636 public:
3637 StackTraceEntry(std::size_t index, const std::string& loc, const std::string& demang, const std::string& hex,
3638 const std::string& addr);
3639 StackTraceEntry(std::size_t index, const std::string& loc) :
3640 m_index(index),
3641 m_location(loc) {
3642 }
3643 std::size_t m_index;
3644 std::string m_location;
3645 std::string m_demangled;
3646 std::string m_hex;
3647 std::string m_addr;
3648 friend std::ostream& operator<<(std::ostream& ss, const StackTraceEntry& si);
3649
3650 private:
3651 StackTraceEntry(void);
3652 };
3653
3654 StackTrace(void) {
3655 generateNew();
3656 }
3657
3658 virtual ~StackTrace(void) {
3659 }
3660
3661 inline std::vector<StackTraceEntry>& getLatestStack(void) {
3662 return m_stack;
3663 }
3664
3665 friend std::ostream& operator<<(std::ostream& os, const StackTrace& st);
3666
3667 private:
3668 std::vector<StackTraceEntry> m_stack;
3669
3670 void generateNew(void);
3671};
3673class CrashHandler : base::NoCopy {
3674 public:
3675 typedef void (*Handler)(int);
3676
3677 explicit CrashHandler(bool useDefault);
3678 explicit CrashHandler(const Handler& cHandler) {
3679 setHandler(cHandler);
3680 }
3681 void setHandler(const Handler& cHandler);
3682
3683 private:
3684 Handler m_handler;
3685};
3686#else
3688 public:
3689 explicit CrashHandler(bool) {}
3690};
3691#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3692} // namespace debug
3693} // namespace base
3694extern base::debug::CrashHandler elCrashHandler;
3695#define MAKE_LOGGABLE(ClassType, ClassInstance, OutputStreamInstance) \
3696el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamInstance, const ClassType& ClassInstance)
3697
3699 public:
3700 SysLogInitializer(const char* processIdent, int options = 0, int facility = 0) {
3701#if defined(ELPP_SYSLOG)
3702 openlog(processIdent, options, facility);
3703#else
3704 ELPP_UNUSED(processIdent);
3705 ELPP_UNUSED(options);
3706 ELPP_UNUSED(facility);
3707#endif // defined(ELPP_SYSLOG)
3708 }
3709 virtual ~SysLogInitializer(void) {
3710#if defined(ELPP_SYSLOG)
3711 closelog();
3712#endif // defined(ELPP_SYSLOG)
3713 }
3714};
3715#define ELPP_INITIALIZE_SYSLOG(id, opt, fac) el::SysLogInitializer elSyslogInit(id, opt, fac)
3718 public:
3721 ELPP = storage;
3722 }
3723
3725 return ELPP;
3726 }
3727
3728 static inline void setArgs(int argc, char** argv) {
3729 ELPP->setApplicationArguments(argc, argv);
3730 }
3731
3732 static inline void setArgs(int argc, const char** argv) {
3733 ELPP->setApplicationArguments(argc, const_cast<char**>(argv));
3734 }
3735
3736 static inline void setThreadName(const std::string& name) {
3737 ELPP->setThreadName(name);
3738 }
3739 static inline std::string getThreadName() {
3740 return ELPP->getThreadName(base::threading::getCurrentThreadId());
3741 }
3742#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3746 static inline void setCrashHandler(const el::base::debug::CrashHandler::Handler& crashHandler) {
3747 el::elCrashHandler.setHandler(crashHandler);
3748 }
3751 static void crashAbort(int sig, const char* sourceFile = "", unsigned int long line = 0);
3757 static void logCrashReason(int sig, bool stackTraceIfAvailable = false,
3758 Level level = Level::Fatal, const char* logger = base::consts::kDefaultLoggerId);
3759#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG)
3762 static inline void installPreRollOutCallback(const PreRollOutCallback& callback) {
3763 ELPP->setPreRollOutCallback(callback);
3764 }
3765
3766 static inline void uninstallPreRollOutCallback(void) {
3767 ELPP->unsetPreRollOutCallback();
3768 }
3769
3770 template <typename T>
3771 static inline bool installLogDispatchCallback(const std::string& id) {
3772 return ELPP->installLogDispatchCallback<T>(id);
3773 }
3774
3775 template <typename T>
3776 static inline void uninstallLogDispatchCallback(const std::string& id) {
3777 ELPP->uninstallLogDispatchCallback<T>(id);
3778 }
3779 template <typename T>
3780 static inline T* logDispatchCallback(const std::string& id) {
3781 return ELPP->logDispatchCallback<T>(id);
3782 }
3783#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3785 template <typename T>
3786 static inline bool installPerformanceTrackingCallback(const std::string& id) {
3787 return ELPP->installPerformanceTrackingCallback<T>(id);
3788 }
3790 template <typename T>
3791 static inline void uninstallPerformanceTrackingCallback(const std::string& id) {
3792 ELPP->uninstallPerformanceTrackingCallback<T>(id);
3793 }
3794 template <typename T>
3795 static inline T* performanceTrackingCallback(const std::string& id) {
3796 return ELPP->performanceTrackingCallback<T>(id);
3797 }
3798#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
3800 template <typename T>
3801 static std::string convertTemplateToStdString(const T& templ) {
3802 el::Logger* logger =
3803 ELPP->registeredLoggers()->get(el::base::consts::kDefaultLoggerId);
3804 if (logger == nullptr) {
3805 return std::string();
3806 }
3808 b.initialize(logger);
3809 logger->acquireLock();
3810 b << templ;
3811#if defined(ELPP_UNICODE)
3812 std::string s = std::string(logger->stream().str().begin(), logger->stream().str().end());
3813#else
3814 std::string s = logger->stream().str();
3815#endif // defined(ELPP_UNICODE)
3816 logger->stream().str(ELPP_LITERAL(""));
3817 logger->releaseLock();
3818 return s;
3819 }
3820
3822 return ELPP->commandLineArgs();
3823 }
3824
3826 static inline void reserveCustomFormatSpecifiers(std::size_t size) {
3827 ELPP->m_customFormatSpecifiers.reserve(size);
3828 }
3829
3830 static inline void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier) {
3831 ELPP->installCustomFormatSpecifier(customFormatSpecifier);
3832 }
3833
3834 static inline bool uninstallCustomFormatSpecifier(const char* formatSpecifier) {
3835 return ELPP->uninstallCustomFormatSpecifier(formatSpecifier);
3836 }
3837
3838 static inline bool hasCustomFormatSpecifier(const char* formatSpecifier) {
3839 return ELPP->hasCustomFormatSpecifier(formatSpecifier);
3840 }
3841 static inline void validateFileRolling(Logger* logger, Level level) {
3842 if (ELPP == nullptr || logger == nullptr) return;
3843 logger->m_typedConfigurations->validateFileRolling(level, ELPP->preRollOutCallback());
3844 }
3845};
3846
3848 public:
3850 static bool allowed(Level leve, const char* cat);
3852 static Logger* getLogger(const std::string& identity, bool registerIfNotAvailable = true);
3854 static void setDefaultLogBuilder(el::LogBuilderPtr& logBuilderPtr);
3856 template <typename T>
3857 static inline bool installLoggerRegistrationCallback(const std::string& id) {
3858 return ELPP->registeredLoggers()->installLoggerRegistrationCallback<T>(id);
3859 }
3860
3861 template <typename T>
3862 static inline void uninstallLoggerRegistrationCallback(const std::string& id) {
3863 ELPP->registeredLoggers()->uninstallLoggerRegistrationCallback<T>(id);
3864 }
3865 template <typename T>
3866 static inline T* loggerRegistrationCallback(const std::string& id) {
3867 return ELPP->registeredLoggers()->loggerRegistrationCallback<T>(id);
3868 }
3869
3871 static bool unregisterLogger(const std::string& identity);
3873 static bool hasLogger(const std::string& identity);
3875 static Logger* reconfigureLogger(Logger* logger, const Configurations& configurations);
3877 static Logger* reconfigureLogger(const std::string& identity, const Configurations& configurations);
3879 static Logger* reconfigureLogger(const std::string& identity, ConfigurationType configurationType,
3880 const std::string& value);
3882 static void reconfigureAllLoggers(const Configurations& configurations);
3884 static inline void reconfigureAllLoggers(ConfigurationType configurationType, const std::string& value) {
3885 reconfigureAllLoggers(Level::Global, configurationType, value);
3886 }
3887
3888 static void reconfigureAllLoggers(Level level, ConfigurationType configurationType,
3889 const std::string& value);
3891 static void setDefaultConfigurations(const Configurations& configurations,
3892 bool reconfigureExistingLoggers = false);
3894 static const Configurations* defaultConfigurations(void);
3896 static const base::LogStreamsReferenceMap* logStreamsReference(void);
3898 static base::TypedConfigurations defaultTypedConfigurations(void);
3901 static std::vector<std::string>* populateAllLoggerIds(std::vector<std::string>* targetList);
3903 static void configureFromGlobal(const char* globalConfigurationFilePath);
3908 static bool configureFromArg(const char* argKey);
3910 static void flushAll(void);
3912 static inline void addFlag(LoggingFlag flag) {
3913 ELPP->addFlag(flag);
3914 }
3915
3916 static inline void removeFlag(LoggingFlag flag) {
3917 ELPP->removeFlag(flag);
3918 }
3919
3920 static inline bool hasFlag(LoggingFlag flag) {
3921 return ELPP->hasFlag(flag);
3922 }
3923
3925 public:
3932 private:
3934 };
3935
3937 public:
3944 private:
3946 };
3947
3948 static void setLoggingLevel(Level level) {
3949 ELPP->setLoggingLevel(level);
3950 }
3951
3952 static void setVerboseLevel(base::type::VerboseLevel level);
3954 static base::type::VerboseLevel verboseLevel(void);
3956 static void setVModules(const char* modules);
3958 static void setCategories(const char* categories, bool clear = true);
3960 static std::string getCategories();
3962 static void clearVModules(void);
3964 static void clearCategories(void);
3966 static void setFilenameCommonPrefix(const std::string &prefix);
3968 static const std::string &getFilenameCommonPrefix();
3969};
3971 public:
3973 static const std::string version(void);
3974
3976 static const std::string releaseDate(void);
3977};
3978} // namespace el
3979#undef VLOG_IS_ON
3981#define VLOG_IS_ON(verboseLevel) (ELPP->vRegistry()->allowed(verboseLevel, __FILE__))
3982#undef TIMED_BLOCK
3983#undef TIMED_SCOPE
3984#undef TIMED_SCOPE_IF
3985#undef TIMED_FUNC
3986#undef TIMED_FUNC_IF
3987#undef ELPP_MIN_UNIT
3988#if defined(ELPP_PERFORMANCE_MICROSECONDS)
3989# define ELPP_MIN_UNIT el::base::TimestampUnit::Microsecond
3990#else
3991# define ELPP_MIN_UNIT el::base::TimestampUnit::Millisecond
3992#endif // (defined(ELPP_PERFORMANCE_MICROSECONDS))
3999// Note: Do not surround this definition with null macro because of obj instance
4000#define TIMED_SCOPE_IF(obj, blockname, condition) el::base::type::PerformanceTrackerPtr obj( condition ? \
4001 new el::base::PerformanceTracker(blockname, ELPP_MIN_UNIT) : nullptr )
4002#define TIMED_SCOPE(obj, blockname) TIMED_SCOPE_IF(obj, blockname, true)
4003#define TIMED_BLOCK(obj, blockName) for (struct { int i; el::base::type::PerformanceTrackerPtr timer; } obj = { 0, \
4004 el::base::type::PerformanceTrackerPtr(new el::base::PerformanceTracker(blockName, ELPP_MIN_UNIT)) }; obj.i < 1; ++obj.i)
4005
4011#define TIMED_FUNC_IF(obj,condition) TIMED_SCOPE_IF(obj, ELPP_FUNC, condition)
4012#define TIMED_FUNC(obj) TIMED_SCOPE(obj, ELPP_FUNC)
4013#undef PERFORMANCE_CHECKPOINT
4014#undef PERFORMANCE_CHECKPOINT_WITH_ID
4015#define PERFORMANCE_CHECKPOINT(obj) obj->checkpoint(std::string(), __FILE__, __LINE__, ELPP_FUNC)
4016#define PERFORMANCE_CHECKPOINT_WITH_ID(obj, id) obj->checkpoint(id, __FILE__, __LINE__, ELPP_FUNC)
4017#undef ELPP_COUNTER
4018#undef ELPP_COUNTER_POS
4020#define ELPP_COUNTER (ELPP->hitCounters()->getCounter(__FILE__, __LINE__))
4022#define ELPP_COUNTER_POS (ELPP_COUNTER == nullptr ? -1 : ELPP_COUNTER->hitCounts())
4023// Undef levels to support LOG(LEVEL)
4024#undef INFO
4025#undef WARNING
4026#undef DEBUG
4027#undef ERROR
4028#undef FATAL
4029#undef TRACE
4030#undef VERBOSE
4031// Undef existing
4032#undef CINFO
4033#undef CWARNING
4034#undef CDEBUG
4035#undef CFATAL
4036#undef CERROR
4037#undef CTRACE
4038#undef CVERBOSE
4039#undef CINFO_IF
4040#undef CWARNING_IF
4041#undef CDEBUG_IF
4042#undef CERROR_IF
4043#undef CFATAL_IF
4044#undef CTRACE_IF
4045#undef CVERBOSE_IF
4046#undef CINFO_EVERY_N
4047#undef CWARNING_EVERY_N
4048#undef CDEBUG_EVERY_N
4049#undef CERROR_EVERY_N
4050#undef CFATAL_EVERY_N
4051#undef CTRACE_EVERY_N
4052#undef CVERBOSE_EVERY_N
4053#undef CINFO_AFTER_N
4054#undef CWARNING_AFTER_N
4055#undef CDEBUG_AFTER_N
4056#undef CERROR_AFTER_N
4057#undef CFATAL_AFTER_N
4058#undef CTRACE_AFTER_N
4059#undef CVERBOSE_AFTER_N
4060#undef CINFO_N_TIMES
4061#undef CWARNING_N_TIMES
4062#undef CDEBUG_N_TIMES
4063#undef CERROR_N_TIMES
4064#undef CFATAL_N_TIMES
4065#undef CTRACE_N_TIMES
4066#undef CVERBOSE_N_TIMES
4067// Normal logs
4068#if ELPP_INFO_LOG
4069# define CINFO(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Info, dispatchAction, __VA_ARGS__)
4070#else
4071# define CINFO(writer, dispatchAction, ...) el::base::NullWriter()
4072#endif // ELPP_INFO_LOG
4073#if ELPP_WARNING_LOG
4074# define CWARNING(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Warning, dispatchAction, __VA_ARGS__)
4075#else
4076# define CWARNING(writer, dispatchAction, ...) el::base::NullWriter()
4077#endif // ELPP_WARNING_LOG
4078#if ELPP_DEBUG_LOG
4079# define CDEBUG(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Debug, dispatchAction, __VA_ARGS__)
4080#else
4081# define CDEBUG(writer, dispatchAction, ...) el::base::NullWriter()
4082#endif // ELPP_DEBUG_LOG
4083#if ELPP_ERROR_LOG
4084# define CERROR(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Error, dispatchAction, __VA_ARGS__)
4085#else
4086# define CERROR(writer, dispatchAction, ...) el::base::NullWriter()
4087#endif // ELPP_ERROR_LOG
4088#if ELPP_FATAL_LOG
4089# define CFATAL(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4090#else
4091# define CFATAL(writer, dispatchAction, ...) el::base::NullWriter()
4092#endif // ELPP_FATAL_LOG
4093#if ELPP_TRACE_LOG
4094# define CTRACE(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Trace, dispatchAction, __VA_ARGS__)
4095#else
4096# define CTRACE(writer, dispatchAction, ...) el::base::NullWriter()
4097#endif // ELPP_TRACE_LOG
4098#if ELPP_VERBOSE_LOG
4099# define CVERBOSE(writer, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel)) writer(\
4100el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
4101#else
4102# define CVERBOSE(writer, vlevel, dispatchAction, ...) el::base::NullWriter()
4103#endif // ELPP_VERBOSE_LOG
4104// Conditional logs
4105#if ELPP_INFO_LOG
4106# define CINFO_IF(writer, condition_, dispatchAction, ...) \
4107ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Info, dispatchAction, __VA_ARGS__)
4108#else
4109# define CINFO_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4110#endif // ELPP_INFO_LOG
4111#if ELPP_WARNING_LOG
4112# define CWARNING_IF(writer, condition_, dispatchAction, ...)\
4113ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Warning, dispatchAction, __VA_ARGS__)
4114#else
4115# define CWARNING_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4116#endif // ELPP_WARNING_LOG
4117#if ELPP_DEBUG_LOG
4118# define CDEBUG_IF(writer, condition_, dispatchAction, ...)\
4119ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Debug, dispatchAction, __VA_ARGS__)
4120#else
4121# define CDEBUG_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4122#endif // ELPP_DEBUG_LOG
4123#if ELPP_ERROR_LOG
4124# define CERROR_IF(writer, condition_, dispatchAction, ...)\
4125ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Error, dispatchAction, __VA_ARGS__)
4126#else
4127# define CERROR_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4128#endif // ELPP_ERROR_LOG
4129#if ELPP_FATAL_LOG
4130# define CFATAL_IF(writer, condition_, dispatchAction, ...)\
4131ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Fatal, dispatchAction, __VA_ARGS__)
4132#else
4133# define CFATAL_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4134#endif // ELPP_FATAL_LOG
4135#if ELPP_TRACE_LOG
4136# define CTRACE_IF(writer, condition_, dispatchAction, ...)\
4137ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Trace, dispatchAction, __VA_ARGS__)
4138#else
4139# define CTRACE_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter()
4140#endif // ELPP_TRACE_LOG
4141#if ELPP_VERBOSE_LOG
4142# define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel) && (condition_)) writer( \
4143el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__)
4144#else
4145# define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) el::base::NullWriter()
4146#endif // ELPP_VERBOSE_LOG
4147// Occasional logs
4148#if ELPP_INFO_LOG
4149# define CINFO_EVERY_N(writer, occasion, dispatchAction, ...)\
4150ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Info, dispatchAction, __VA_ARGS__)
4151#else
4152# define CINFO_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4153#endif // ELPP_INFO_LOG
4154#if ELPP_WARNING_LOG
4155# define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...)\
4156ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Warning, dispatchAction, __VA_ARGS__)
4157#else
4158# define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4159#endif // ELPP_WARNING_LOG
4160#if ELPP_DEBUG_LOG
4161# define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...)\
4162ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Debug, dispatchAction, __VA_ARGS__)
4163#else
4164# define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4165#endif // ELPP_DEBUG_LOG
4166#if ELPP_ERROR_LOG
4167# define CERROR_EVERY_N(writer, occasion, dispatchAction, ...)\
4168ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Error, dispatchAction, __VA_ARGS__)
4169#else
4170# define CERROR_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4171#endif // ELPP_ERROR_LOG
4172#if ELPP_FATAL_LOG
4173# define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...)\
4174ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4175#else
4176# define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4177#endif // ELPP_FATAL_LOG
4178#if ELPP_TRACE_LOG
4179# define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...)\
4180ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Trace, dispatchAction, __VA_ARGS__)
4181#else
4182# define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter()
4183#endif // ELPP_TRACE_LOG
4184#if ELPP_VERBOSE_LOG
4185# define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...)\
4186CVERBOSE_IF(writer, ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion), vlevel, dispatchAction, __VA_ARGS__)
4187#else
4188# define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...) el::base::NullWriter()
4189#endif // ELPP_VERBOSE_LOG
4190// After N logs
4191#if ELPP_INFO_LOG
4192# define CINFO_AFTER_N(writer, n, dispatchAction, ...)\
4193ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__)
4194#else
4195# define CINFO_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4196#endif // ELPP_INFO_LOG
4197#if ELPP_WARNING_LOG
4198# define CWARNING_AFTER_N(writer, n, dispatchAction, ...)\
4199ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__)
4200#else
4201# define CWARNING_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4202#endif // ELPP_WARNING_LOG
4203#if ELPP_DEBUG_LOG
4204# define CDEBUG_AFTER_N(writer, n, dispatchAction, ...)\
4205ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__)
4206#else
4207# define CDEBUG_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4208#endif // ELPP_DEBUG_LOG
4209#if ELPP_ERROR_LOG
4210# define CERROR_AFTER_N(writer, n, dispatchAction, ...)\
4211ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__)
4212#else
4213# define CERROR_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4214#endif // ELPP_ERROR_LOG
4215#if ELPP_FATAL_LOG
4216# define CFATAL_AFTER_N(writer, n, dispatchAction, ...)\
4217ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4218#else
4219# define CFATAL_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4220#endif // ELPP_FATAL_LOG
4221#if ELPP_TRACE_LOG
4222# define CTRACE_AFTER_N(writer, n, dispatchAction, ...)\
4223ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__)
4224#else
4225# define CTRACE_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter()
4226#endif // ELPP_TRACE_LOG
4227#if ELPP_VERBOSE_LOG
4228# define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...)\
4229CVERBOSE_IF(writer, ELPP->validateAfterNCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__)
4230#else
4231# define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter()
4232#endif // ELPP_VERBOSE_LOG
4233// N Times logs
4234#if ELPP_INFO_LOG
4235# define CINFO_N_TIMES(writer, n, dispatchAction, ...)\
4236ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__)
4237#else
4238# define CINFO_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4239#endif // ELPP_INFO_LOG
4240#if ELPP_WARNING_LOG
4241# define CWARNING_N_TIMES(writer, n, dispatchAction, ...)\
4242ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__)
4243#else
4244# define CWARNING_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4245#endif // ELPP_WARNING_LOG
4246#if ELPP_DEBUG_LOG
4247# define CDEBUG_N_TIMES(writer, n, dispatchAction, ...)\
4248ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__)
4249#else
4250# define CDEBUG_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4251#endif // ELPP_DEBUG_LOG
4252#if ELPP_ERROR_LOG
4253# define CERROR_N_TIMES(writer, n, dispatchAction, ...)\
4254ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__)
4255#else
4256# define CERROR_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4257#endif // ELPP_ERROR_LOG
4258#if ELPP_FATAL_LOG
4259# define CFATAL_N_TIMES(writer, n, dispatchAction, ...)\
4260ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__)
4261#else
4262# define CFATAL_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4263#endif // ELPP_FATAL_LOG
4264#if ELPP_TRACE_LOG
4265# define CTRACE_N_TIMES(writer, n, dispatchAction, ...)\
4266ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__)
4267#else
4268# define CTRACE_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter()
4269#endif // ELPP_TRACE_LOG
4270#if ELPP_VERBOSE_LOG
4271# define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...)\
4272CVERBOSE_IF(writer, ELPP->validateNTimesCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__)
4273#else
4274# define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter()
4275#endif // ELPP_VERBOSE_LOG
4276//
4277// Custom Loggers - Requires (level, dispatchAction, loggerId/s)
4278//
4279// undef existing
4280#undef CLOG
4281#undef CLOG_VERBOSE
4282#undef CVLOG
4283#undef CLOG_IF
4284#undef CLOG_VERBOSE_IF
4285#undef CVLOG_IF
4286#undef CLOG_EVERY_N
4287#undef CVLOG_EVERY_N
4288#undef CLOG_AFTER_N
4289#undef CVLOG_AFTER_N
4290#undef CLOG_N_TIMES
4291#undef CVLOG_N_TIMES
4292// Normal logs
4293#define CLOG(LEVEL, ...)\
4294C##LEVEL(el::base::Writer, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4295#define CVLOG(vlevel, ...) CVERBOSE(el::base::Writer, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4296// Conditional logs
4297#define CLOG_IF(condition, LEVEL, ...)\
4298C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4299#define CVLOG_IF(condition, vlevel, ...)\
4300CVERBOSE_IF(el::base::Writer, condition, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4301// Hit counts based logs
4302#define CLOG_EVERY_N(n, LEVEL, ...)\
4303C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4304#define CVLOG_EVERY_N(n, vlevel, ...)\
4305CVERBOSE_EVERY_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4306#define CLOG_AFTER_N(n, LEVEL, ...)\
4307C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4308#define CVLOG_AFTER_N(n, vlevel, ...)\
4309CVERBOSE_AFTER_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4310#define CLOG_N_TIMES(n, LEVEL, ...)\
4311C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4312#define CVLOG_N_TIMES(n, vlevel, ...)\
4313CVERBOSE_N_TIMES(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4314//
4315// Default Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros
4316//
4317// undef existing
4318#undef LOG
4319#undef VLOG
4320#undef LOG_IF
4321#undef VLOG_IF
4322#undef LOG_EVERY_N
4323#undef VLOG_EVERY_N
4324#undef LOG_AFTER_N
4325#undef VLOG_AFTER_N
4326#undef LOG_N_TIMES
4327#undef VLOG_N_TIMES
4328#undef ELPP_CURR_FILE_LOGGER_ID
4329#if defined(ELPP_DEFAULT_LOGGER)
4330# define ELPP_CURR_FILE_LOGGER_ID ELPP_DEFAULT_LOGGER
4331#else
4332# define ELPP_CURR_FILE_LOGGER_ID el::base::consts::kDefaultLoggerId
4333#endif
4334#undef ELPP_TRACE
4335#define ELPP_TRACE CLOG(TRACE, ELPP_CURR_FILE_LOGGER_ID)
4336// Normal logs
4337#define LOG(LEVEL) CLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4338#define VLOG(vlevel) CVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID)
4339// Conditional logs
4340#define LOG_IF(condition, LEVEL) CLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4341#define VLOG_IF(condition, vlevel) CVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4342// Hit counts based logs
4343#define LOG_EVERY_N(n, LEVEL) CLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4344#define VLOG_EVERY_N(n, vlevel) CVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4345#define LOG_AFTER_N(n, LEVEL) CLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4346#define VLOG_AFTER_N(n, vlevel) CVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4347#define LOG_N_TIMES(n, LEVEL) CLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4348#define VLOG_N_TIMES(n, vlevel) CVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4349// Generic PLOG()
4350#undef CPLOG
4351#undef CPLOG_IF
4352#undef PLOG
4353#undef PLOG_IF
4354#undef DCPLOG
4355#undef DCPLOG_IF
4356#undef DPLOG
4357#undef DPLOG_IF
4358#define CPLOG(LEVEL, ...)\
4359C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4360#define CPLOG_IF(condition, LEVEL, ...)\
4361C##LEVEL##_IF(el::base::PErrorWriter, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4362#define DCPLOG(LEVEL, ...)\
4363if (ELPP_DEBUG_LOG) C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__)
4364#define DCPLOG_IF(condition, LEVEL, ...)\
4365C##LEVEL##_IF(el::base::PErrorWriter, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::NormalLog, __VA_ARGS__)
4366#define PLOG(LEVEL) CPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4367#define PLOG_IF(condition, LEVEL) CPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4368#define DPLOG(LEVEL) DCPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4369#define DPLOG_IF(condition, LEVEL) DCPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4370// Generic SYSLOG()
4371#undef CSYSLOG
4372#undef CSYSLOG_IF
4373#undef CSYSLOG_EVERY_N
4374#undef CSYSLOG_AFTER_N
4375#undef CSYSLOG_N_TIMES
4376#undef SYSLOG
4377#undef SYSLOG_IF
4378#undef SYSLOG_EVERY_N
4379#undef SYSLOG_AFTER_N
4380#undef SYSLOG_N_TIMES
4381#undef DCSYSLOG
4382#undef DCSYSLOG_IF
4383#undef DCSYSLOG_EVERY_N
4384#undef DCSYSLOG_AFTER_N
4385#undef DCSYSLOG_N_TIMES
4386#undef DSYSLOG
4387#undef DSYSLOG_IF
4388#undef DSYSLOG_EVERY_N
4389#undef DSYSLOG_AFTER_N
4390#undef DSYSLOG_N_TIMES
4391#if defined(ELPP_SYSLOG)
4392# define CSYSLOG(LEVEL, ...)\
4393C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__)
4394# define CSYSLOG_IF(condition, LEVEL, ...)\
4395C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::SysLog, __VA_ARGS__)
4396# define CSYSLOG_EVERY_N(n, LEVEL, ...) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4397# define CSYSLOG_AFTER_N(n, LEVEL, ...) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4398# define CSYSLOG_N_TIMES(n, LEVEL, ...) C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4399# define SYSLOG(LEVEL) CSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId)
4400# define SYSLOG_IF(condition, LEVEL) CSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId)
4401# define SYSLOG_EVERY_N(n, LEVEL) CSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4402# define SYSLOG_AFTER_N(n, LEVEL) CSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4403# define SYSLOG_N_TIMES(n, LEVEL) CSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId)
4404# define DCSYSLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__)
4405# define DCSYSLOG_IF(condition, LEVEL, ...)\
4406C##LEVEL##_IF(el::base::Writer, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::SysLog, __VA_ARGS__)
4407# define DCSYSLOG_EVERY_N(n, LEVEL, ...)\
4408if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4409# define DCSYSLOG_AFTER_N(n, LEVEL, ...)\
4410if (ELPP_DEBUG_LOG) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4411# define DCSYSLOG_N_TIMES(n, LEVEL, ...)\
4412if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__)
4413# define DSYSLOG(LEVEL) DCSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId)
4414# define DSYSLOG_IF(condition, LEVEL) DCSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId)
4415# define DSYSLOG_EVERY_N(n, LEVEL) DCSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4416# define DSYSLOG_AFTER_N(n, LEVEL) DCSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId)
4417# define DSYSLOG_N_TIMES(n, LEVEL) DCSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId)
4418#else
4419# define CSYSLOG(LEVEL, ...) el::base::NullWriter()
4420# define CSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter()
4421# define CSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter()
4422# define CSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter()
4423# define CSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter()
4424# define SYSLOG(LEVEL) el::base::NullWriter()
4425# define SYSLOG_IF(condition, LEVEL) el::base::NullWriter()
4426# define SYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter()
4427# define SYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter()
4428# define SYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter()
4429# define DCSYSLOG(LEVEL, ...) el::base::NullWriter()
4430# define DCSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter()
4431# define DCSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter()
4432# define DCSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter()
4433# define DCSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter()
4434# define DSYSLOG(LEVEL) el::base::NullWriter()
4435# define DSYSLOG_IF(condition, LEVEL) el::base::NullWriter()
4436# define DSYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter()
4437# define DSYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter()
4438# define DSYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter()
4439#endif // defined(ELPP_SYSLOG)
4440//
4441// Custom Debug Only Loggers - Requires (level, loggerId/s)
4442//
4443// undef existing
4444#undef DCLOG
4445#undef DCVLOG
4446#undef DCLOG_IF
4447#undef DCVLOG_IF
4448#undef DCLOG_EVERY_N
4449#undef DCVLOG_EVERY_N
4450#undef DCLOG_AFTER_N
4451#undef DCVLOG_AFTER_N
4452#undef DCLOG_N_TIMES
4453#undef DCVLOG_N_TIMES
4454// Normal logs
4455#define DCLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG(LEVEL, __VA_ARGS__)
4456#define DCLOG_VERBOSE(vlevel, ...) if (ELPP_DEBUG_LOG) CLOG_VERBOSE(vlevel, __VA_ARGS__)
4457#define DCVLOG(vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG(vlevel, __VA_ARGS__)
4458// Conditional logs
4459#define DCLOG_IF(condition, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_IF(condition, LEVEL, __VA_ARGS__)
4460#define DCVLOG_IF(condition, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_IF(condition, vlevel, __VA_ARGS__)
4461// Hit counts based logs
4462#define DCLOG_EVERY_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_EVERY_N(n, LEVEL, __VA_ARGS__)
4463#define DCVLOG_EVERY_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_EVERY_N(n, vlevel, __VA_ARGS__)
4464#define DCLOG_AFTER_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_AFTER_N(n, LEVEL, __VA_ARGS__)
4465#define DCVLOG_AFTER_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_AFTER_N(n, vlevel, __VA_ARGS__)
4466#define DCLOG_N_TIMES(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_N_TIMES(n, LEVEL, __VA_ARGS__)
4467#define DCVLOG_N_TIMES(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_N_TIMES(n, vlevel, __VA_ARGS__)
4468//
4469// Default Debug Only Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros
4470//
4471#if !defined(ELPP_NO_DEBUG_MACROS)
4472// undef existing
4473#undef DLOG
4474#undef DVLOG
4475#undef DLOG_IF
4476#undef DVLOG_IF
4477#undef DLOG_EVERY_N
4478#undef DVLOG_EVERY_N
4479#undef DLOG_AFTER_N
4480#undef DVLOG_AFTER_N
4481#undef DLOG_N_TIMES
4482#undef DVLOG_N_TIMES
4483// Normal logs
4484#define DLOG(LEVEL) DCLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4485#define DVLOG(vlevel) DCVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID)
4486// Conditional logs
4487#define DLOG_IF(condition, LEVEL) DCLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4488#define DVLOG_IF(condition, vlevel) DCVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4489// Hit counts based logs
4490#define DLOG_EVERY_N(n, LEVEL) DCLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4491#define DVLOG_EVERY_N(n, vlevel) DCVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4492#define DLOG_AFTER_N(n, LEVEL) DCLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4493#define DVLOG_AFTER_N(n, vlevel) DCVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4494#define DLOG_N_TIMES(n, LEVEL) DCLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID)
4495#define DVLOG_N_TIMES(n, vlevel) DCVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID)
4496#endif // defined(ELPP_NO_DEBUG_MACROS)
4497#if !defined(ELPP_NO_CHECK_MACROS)
4498// Check macros
4499#undef CCHECK
4500#undef CPCHECK
4501#undef CCHECK_EQ
4502#undef CCHECK_NE
4503#undef CCHECK_LT
4504#undef CCHECK_GT
4505#undef CCHECK_LE
4506#undef CCHECK_GE
4507#undef CCHECK_BOUNDS
4508#undef CCHECK_NOTNULL
4509#undef CCHECK_STRCASEEQ
4510#undef CCHECK_STRCASENE
4511#undef CHECK
4512#undef PCHECK
4513#undef CHECK_EQ
4514#undef CHECK_NE
4515#undef CHECK_LT
4516#undef CHECK_GT
4517#undef CHECK_LE
4518#undef CHECK_GE
4519#undef CHECK_BOUNDS
4520#undef CHECK_NOTNULL
4521#undef CHECK_STRCASEEQ
4522#undef CHECK_STRCASENE
4523#define CCHECK(condition, ...) CLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] "
4524#define CPCHECK(condition, ...) CPLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] "
4525#define CHECK(condition) CCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4526#define PCHECK(condition) CPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4527#define CCHECK_EQ(a, b, ...) CCHECK(a == b, __VA_ARGS__)
4528#define CCHECK_NE(a, b, ...) CCHECK(a != b, __VA_ARGS__)
4529#define CCHECK_LT(a, b, ...) CCHECK(a < b, __VA_ARGS__)
4530#define CCHECK_GT(a, b, ...) CCHECK(a > b, __VA_ARGS__)
4531#define CCHECK_LE(a, b, ...) CCHECK(a <= b, __VA_ARGS__)
4532#define CCHECK_GE(a, b, ...) CCHECK(a >= b, __VA_ARGS__)
4533#define CCHECK_BOUNDS(val, min, max, ...) CCHECK(val >= min && val <= max, __VA_ARGS__)
4534#define CHECK_EQ(a, b) CCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID)
4535#define CHECK_NE(a, b) CCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4536#define CHECK_LT(a, b) CCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4537#define CHECK_GT(a, b) CCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4538#define CHECK_LE(a, b) CCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4539#define CHECK_GE(a, b) CCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4540#define CHECK_BOUNDS(val, min, max) CCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID)
4541#define CCHECK_NOTNULL(ptr, ...) CCHECK((ptr) != nullptr, __VA_ARGS__)
4542#define CCHECK_STREQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \
4543<< "Check failed: [" << #str1 << " == " << #str2 << "] "
4544#define CCHECK_STRNE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \
4545<< "Check failed: [" << #str1 << " != " << #str2 << "] "
4546#define CCHECK_STRCASEEQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \
4547<< "Check failed: [" << #str1 << " == " << #str2 << "] "
4548#define CCHECK_STRCASENE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \
4549<< "Check failed: [" << #str1 << " != " << #str2 << "] "
4550#define CHECK_NOTNULL(ptr) CCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID)
4551#define CHECK_STREQ(str1, str2) CCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4552#define CHECK_STRNE(str1, str2) CCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4553#define CHECK_STRCASEEQ(str1, str2) CCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4554#define CHECK_STRCASENE(str1, str2) CCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4555#undef DCCHECK
4556#undef DCCHECK_EQ
4557#undef DCCHECK_NE
4558#undef DCCHECK_LT
4559#undef DCCHECK_GT
4560#undef DCCHECK_LE
4561#undef DCCHECK_GE
4562#undef DCCHECK_BOUNDS
4563#undef DCCHECK_NOTNULL
4564#undef DCCHECK_STRCASEEQ
4565#undef DCCHECK_STRCASENE
4566#undef DCPCHECK
4567#undef DCHECK
4568#undef DCHECK_EQ
4569#undef DCHECK_NE
4570#undef DCHECK_LT
4571#undef DCHECK_GT
4572#undef DCHECK_LE
4573#undef DCHECK_GE
4574#undef DCHECK_BOUNDS_
4575#undef DCHECK_NOTNULL
4576#undef DCHECK_STRCASEEQ
4577#undef DCHECK_STRCASENE
4578#undef DPCHECK
4579#define DCCHECK(condition, ...) if (ELPP_DEBUG_LOG) CCHECK(condition, __VA_ARGS__)
4580#define DCCHECK_EQ(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_EQ(a, b, __VA_ARGS__)
4581#define DCCHECK_NE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_NE(a, b, __VA_ARGS__)
4582#define DCCHECK_LT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LT(a, b, __VA_ARGS__)
4583#define DCCHECK_GT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GT(a, b, __VA_ARGS__)
4584#define DCCHECK_LE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LE(a, b, __VA_ARGS__)
4585#define DCCHECK_GE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GE(a, b, __VA_ARGS__)
4586#define DCCHECK_BOUNDS(val, min, max, ...) if (ELPP_DEBUG_LOG) CCHECK_BOUNDS(val, min, max, __VA_ARGS__)
4587#define DCCHECK_NOTNULL(ptr, ...) if (ELPP_DEBUG_LOG) CCHECK_NOTNULL((ptr), __VA_ARGS__)
4588#define DCCHECK_STREQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STREQ(str1, str2, __VA_ARGS__)
4589#define DCCHECK_STRNE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRNE(str1, str2, __VA_ARGS__)
4590#define DCCHECK_STRCASEEQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASEEQ(str1, str2, __VA_ARGS__)
4591#define DCCHECK_STRCASENE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASENE(str1, str2, __VA_ARGS__)
4592#define DCPCHECK(condition, ...) if (ELPP_DEBUG_LOG) CPCHECK(condition, __VA_ARGS__)
4593#define DCHECK(condition) DCCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4594#define DCHECK_EQ(a, b) DCCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID)
4595#define DCHECK_NE(a, b) DCCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4596#define DCHECK_LT(a, b) DCCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4597#define DCHECK_GT(a, b) DCCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID)
4598#define DCHECK_LE(a, b) DCCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4599#define DCHECK_GE(a, b) DCCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID)
4600#define DCHECK_BOUNDS(val, min, max) DCCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID)
4601#define DCHECK_NOTNULL(ptr) DCCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID)
4602#define DCHECK_STREQ(str1, str2) DCCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4603#define DCHECK_STRNE(str1, str2) DCCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4604#define DCHECK_STRCASEEQ(str1, str2) DCCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4605#define DCHECK_STRCASENE(str1, str2) DCCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID)
4606#define DPCHECK(condition) DCPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID)
4607#endif // defined(ELPP_NO_CHECK_MACROS)
4608#if defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING)
4609# define ELPP_USE_DEF_CRASH_HANDLER false
4610#else
4611# define ELPP_USE_DEF_CRASH_HANDLER true
4612#endif // defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING)
4613#define ELPP_CRASH_HANDLER_INIT
4614#define ELPP_INIT_EASYLOGGINGPP(val) \
4615namespace el { \
4616namespace base { \
4617el::base::type::StoragePointer elStorage(val); \
4618} \
4619el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER); \
4620}
4621
4622#if ELPP_ASYNC_LOGGING
4623# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()),\
4624new el::base::AsyncDispatchWorker()))
4625#else
4626# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder())))
4627#endif // ELPP_ASYNC_LOGGING
4628#define INITIALIZE_NULL_EASYLOGGINGPP \
4629namespace el {\
4630namespace base {\
4631el::base::type::StoragePointer elStorage;\
4632}\
4633el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\
4634}
4635#define SHARE_EASYLOGGINGPP(initializedStorage)\
4636namespace el {\
4637namespace base {\
4638el::base::type::StoragePointer elStorage(initializedStorage);\
4639}\
4640el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\
4641}
4642
4643#if defined(ELPP_UNICODE)
4644# define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv); std::locale::global(std::locale(""))
4645#else
4646# define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv)
4647#endif // defined(ELPP_UNICODE)
4648#endif // EASYLOGGINGPP_H
#define si(y, x, c)
Definition aesb.c:48
#define s(x, c)
Definition aesb.c:47
std::ostream & operator<<(std::ostream &os, const Student &s)
Definition archivertest.cpp:30
cryptonote::block b
Definition block.cpp:40
JSON writer.
Definition writer.h:89
void setEnabled(bool enabled)
Definition easylogging++.h:2190
bool m_enabled
Definition easylogging++.h:2197
Callback(void)
Definition easylogging++.h:2186
virtual void handle(const T *handlePtr)=0
bool enabled(void) const
Definition easylogging++.h:2187
Static class that contains helper functions for el::ConfigurationType.
Definition easylogging++.h:696
static const char * convertToString(ConfigurationType configurationType)
Converts configuration type to associated const char*.
Definition easylogging++.cc:264
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:305
static ConfigurationType castFromInt(base::type::EnumType c)
Casts int(ushort) to configurationt type, useful for iterating through enum.
Definition easylogging++.h:707
static ConfigurationType convertFromString(const char *configStr)
Converts from configStr to ConfigurationType.
Definition easylogging++.cc:296
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
static base::type::EnumType castToInt(ConfigurationType configurationType)
Casts configuration type to int, useful for iterating through enum.
Definition easylogging++.h:703
static const base::type::EnumType kMinValid
Represents minimum valid configuration type. Useful when iterating through enum.
Definition easylogging++.h:699
bool operator()(const Configuration *conf) const
Definition easylogging++.cc:351
Predicate(Level level, ConfigurationType configurationType)
Used to find configuration from configuration (pointers) repository. Avoid using it.
Definition easylogging++.cc:346
ConfigurationType m_configurationType
Definition easylogging++.h:1757
Level m_level
Definition easylogging++.h:1756
Represents single configuration that has representing level, configuration type and a string based va...
Definition easylogging++.h:1713
void setValue(const std::string &value)
Set string based configuration value.
Definition easylogging++.h:1742
const std::string & value(void) const
Gets string based configuration value.
Definition easylogging++.h:1735
ConfigurationType m_configurationType
Definition easylogging++.h:1762
Level m_level
Definition easylogging++.h:1761
std::string m_value
Definition easylogging++.h:1763
Configuration & operator=(const Configuration &c)
Definition easylogging++.cc:323
Level level(void) const
Gets level of current configuration.
Definition easylogging++.h:1725
Configuration(const Configuration &c)
Definition easylogging++.cc:317
virtual ~Configuration(void)
Definition easylogging++.h:1718
ConfigurationType configurationType(void) const
Gets configuration type of current configuration.
Definition easylogging++.h:1730
Parser used internally to parse configurations from file or text.
Definition easylogging++.h:1879
static bool isConfig(const std::string &line)
Definition easylogging++.cc:550
static bool parseLine(std::string *line, std::string *currConfigStr, std::string *currLevelStr, Level *currLevel, Configurations *conf)
Definition easylogging++.cc:558
static bool parseFromFile(const std::string &configurationFile, Configurations *sender, Configurations *base=nullptr)
Parses configuration from file.
Definition easylogging++.cc:489
static void ignoreComments(std::string *line)
Definition easylogging++.cc:523
static bool isLevel(const std::string &line)
Definition easylogging++.cc:542
static bool parseFromText(const std::string &configurationsString, Configurations *sender, Configurations *base=nullptr)
Parse configurations from configuration string.
Definition easylogging++.cc:507
static bool isComment(const std::string &line)
Definition easylogging++.cc:546
Thread-safe Configuration repository.
Definition easylogging++.h:1769
void unsafeSet(Level level, ConfigurationType configurationType, const std::string &value)
Thread unsafe set.
Definition easylogging++.cc:625
void clear(void)
Clears repository so that all the configurations are unset.
Definition easylogging++.h:1851
Configuration * get(Level level, ConfigurationType configurationType)
Definition easylogging++.h:1837
void setGlobally(ConfigurationType configurationType, const std::string &value)
Sets configuration for all levels.
Definition easylogging++.h:1846
std::string m_configurationFile
Definition easylogging++.h:1915
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:649
void unsafeSetIfNotExist(Level level, ConfigurationType configurationType, const std::string &value)
Unsafely sets configuration if does not already exist.
Definition easylogging++.cc:618
const std::string & configurationFile(void) const
Gets configuration file used in parsing this configurations.
Definition easylogging++.h:1859
bool m_isFromFile
Definition easylogging++.h:1916
Configurations(void)
Default constructor with empty repository.
Definition easylogging++.cc:357
virtual ~Configurations(void)
Definition easylogging++.h:1783
User-provided custom format specifier.
Definition easylogging++.h:1686
const char * formatSpecifier(void) const
Definition easylogging++.h:1690
const FormatSpecifierValueResolver & resolver(void) const
Definition easylogging++.h:1693
CustomFormatSpecifier(const char *formatSpecifier, const FormatSpecifierValueResolver &resolver)
Definition easylogging++.h:1688
const char * m_formatSpecifier
Definition easylogging++.h:1701
FormatSpecifierValueResolver m_resolver
Definition easylogging++.h:1702
bool operator==(const char *formatSpecifier)
Definition easylogging++.h:1696
Static helpers for developers.
Definition easylogging++.h:3717
static base::type::StoragePointer storage()
Definition easylogging++.h:3724
static bool hasCustomFormatSpecifier(const char *formatSpecifier)
Returns true if custom format specifier is installed.
Definition easylogging++.h:3838
static bool uninstallCustomFormatSpecifier(const char *formatSpecifier)
Uninstalls user defined format specifier and handler.
Definition easylogging++.h:3834
static void setThreadName(const std::string &name)
Sets thread name for current thread. Requires std::thread.
Definition easylogging++.h:3736
static bool installLogDispatchCallback(const std::string &id)
Installs post log dispatch callback, this callback is triggered when log is dispatched.
Definition easylogging++.h:3771
static void setArgs(int argc, char **argv)
Sets application arguments and figures out whats active for logging and whats not.
Definition easylogging++.h:3728
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:3801
static T * logDispatchCallback(const std::string &id)
Definition easylogging++.h:3780
static void installCustomFormatSpecifier(const CustomFormatSpecifier &customFormatSpecifier)
Installs user defined format specifier and handler.
Definition easylogging++.h:3830
static const el::base::utils::CommandLineArgs * commandLineArgs(void)
Returns command line arguments (pointer) provided to easylogging++.
Definition easylogging++.h:3821
static void uninstallPreRollOutCallback(void)
Uninstalls pre rollout callback.
Definition easylogging++.h:3766
static void uninstallLogDispatchCallback(const std::string &id)
Uninstalls log dispatch callback.
Definition easylogging++.h:3776
static std::string getThreadName()
Definition easylogging++.h:3739
static void validateFileRolling(Logger *logger, Level level)
Definition easylogging++.h:3841
static void setStorage(base::type::StoragePointer storage)
Shares logging repository (base::Storage).
Definition easylogging++.h:3720
static void setArgs(int argc, const char **argv)
Sets application arguments and figures out whats active for logging and whats not.
Definition easylogging++.h:3732
static void reserveCustomFormatSpecifiers(std::size_t size)
Reserve space for custom format specifiers for performance.
Definition easylogging++.h:3826
Static class that contains helper functions for el::Level.
Definition easylogging++.h:631
static Level castFromInt(base::type::EnumType l)
Casts int(ushort) to level, useful for iterating through enum.
Definition easylogging++.h:642
static Level convertFromString(const char *levelStr)
Converts from levelStr to Level.
Definition easylogging++.cc:223
static const base::type::EnumType kMinValid
Represents minimum valid level. Useful when iterating through enum.
Definition easylogging++.h:634
static base::type::EnumType castToInt(Level level)
Casts level to int, useful for iterating through enum.
Definition easylogging++.h:638
static Level convertFromStringPrefix(const char *levelStr)
Converts from prefix of levelStr to Level.
Definition easylogging++.cc:232
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:252
static const base::type::EnumType kMaxValid
Represents maximum valid level. This is used internally and you should not need it.
Definition easylogging++.h:636
static const char * convertToString(Level level)
Converts level to associated const char*.
Definition easylogging++.cc:194
Definition easylogging++.h:2237
LogBuilder()
Definition easylogging++.h:2239
void convertToColoredOutput(base::type::string_t *logLine, Level level, Color color)
Definition easylogging++.cc:663
virtual base::type::string_t build(const LogMessage *logMessage, bool appendNewLine) const =0
void setColor(Color color, bool bright)
Definition easylogging++.cc:693
virtual ~LogBuilder(void)
Definition easylogging++.h:2240
bool m_termSupportsColor
Definition easylogging++.h:2247
Definition easylogging++.h:2220
base::threading::Mutex & fileHandle(const LogDispatchData *data)
Definition easylogging++.cc:2436
base::threading::Mutex m_fileLocksMapLock
Definition easylogging++.h:2227
std::unordered_map< std::string, std::unique_ptr< base::threading::Mutex > > m_fileLocks
Definition easylogging++.h:2226
virtual void handle(const LogDispatchData *data)
Definition easylogging++.cc:2425
Definition easylogging++.h:2199
void setLogMessage(LogMessage *logMessage)
Definition easylogging++.h:2208
LogDispatchData()
Definition easylogging++.h:2201
base::DispatchAction dispatchAction(void) const
Definition easylogging++.h:2205
base::DispatchAction m_dispatchAction
Definition easylogging++.h:2216
LogMessage * m_logMessage
Definition easylogging++.h:2215
const LogMessage * logMessage(void) const
Definition easylogging++.h:2202
void setDispatchAction(base::DispatchAction dispatchAction)
Definition easylogging++.h:2211
Definition easylogging++.h:2516
const base::type::string_t & message(void) const
Definition easylogging++.h:2544
const std::string & file(void) const
Definition easylogging++.h:2529
base::type::VerboseLevel m_verboseLevel
Definition easylogging++.h:2553
Color m_color
Definition easylogging++.h:2549
Level level(void) const
Definition easylogging++.h:2523
const std::string & func(void) const
Definition easylogging++.h:2535
Color color(void) const
Definition easylogging++.h:2526
std::string m_file
Definition easylogging++.h:2550
base::type::LineNumber line(void) const
Definition easylogging++.h:2532
base::type::VerboseLevel verboseLevel(void) const
Definition easylogging++.h:2538
Logger * m_logger
Definition easylogging++.h:2554
base::type::string_t m_message
Definition easylogging++.h:2555
Logger * logger(void) const
Definition easylogging++.h:2541
Level m_level
Definition easylogging++.h:2548
base::type::LineNumber m_line
Definition easylogging++.h:2551
std::string m_func
Definition easylogging++.h:2552
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:2518
Base of Easylogging++ friendly class.
Definition easylogging++.h:1603
friend el::base::type::ostream_t & operator<<(el::base::type::ostream_t &os, const Loggable &loggable)
Definition easylogging++.h:1608
virtual ~Loggable(void)
Definition easylogging++.h:1605
virtual void log(el::base::type::ostream_t &) const =0
Definition easylogging++.h:2233
Represents a logger holding ID and configurations we need to write logs.
Definition easylogging++.h:2254
base::type::stringstream_t m_stream
Definition easylogging++.h:2342
std::unordered_map< Level, unsigned int > m_unflushedCount
Definition easylogging++.h:2346
Configurations m_configurations
Definition easylogging++.h:2345
const std::string & id(void) const
Definition easylogging++.h:2275
Logger & operator=(const Logger &logger)
Definition easylogging++.cc:732
LogBuilder * logBuilder(void) const
Definition easylogging++.h:2306
Logger(void)
Logger(const std::string &id, base::LogStreamsReferenceMap *logStreamsReference)
Definition easylogging++.cc:702
void setParentApplicationName(const std::string &parentApplicationName)
Definition easylogging++.h:2283
LogBuilderPtr m_logBuilder
Definition easylogging++.h:2348
void setLogBuilder(const LogBuilderPtr &logBuilder)
Definition easylogging++.h:2310
base::TypedConfigurations * typedConfigurations(void)
Definition easylogging++.h:2291
std::string m_id
Definition easylogging++.h:2340
Configurations * configurations(void)
Definition easylogging++.h:2287
base::TypedConfigurations * m_typedConfigurations
Definition easylogging++.h:2341
bool enabled(Level level) const
Definition easylogging++.h:2314
virtual void log(el::base::type::ostream_t &os) const
Definition easylogging++.h:2265
base::LogStreamsReferenceMap * m_logStreamsReference
Definition easylogging++.h:2347
base::type::stringstream_t & stream(void)
Definition easylogging++.h:2380
bool isFlushNeeded(Level level)
Definition easylogging++.h:2302
bool m_isConfigured
Definition easylogging++.h:2344
virtual ~Logger(void)
Definition easylogging++.h:2261
void initUnflushedCount(void)
Definition easylogging++.cc:803
const std::string & parentApplicationName(void) const
Definition easylogging++.h:2279
std::string m_parentApplicationName
Definition easylogging++.h:2343
ScopedAddFlag(LoggingFlag flag)
Definition easylogging++.h:3926
LoggingFlag m_flag
Definition easylogging++.h:3933
~ScopedAddFlag(void)
Definition easylogging++.h:3929
LoggingFlag m_flag
Definition easylogging++.h:3945
~ScopedRemoveFlag(void)
Definition easylogging++.h:3941
ScopedRemoveFlag(LoggingFlag flag)
Definition easylogging++.h:3938
Static helpers to deal with loggers and their configurations.
Definition easylogging++.h:3847
static bool allowed(Level leve, const char *cat)
Determines whether logging will occur at this level and category.
Definition easylogging++.cc:3370
static void reconfigureAllLoggers(ConfigurationType configurationType, const std::string &value)
Reconfigures single configuration for all the loggers.
Definition easylogging++.h:3884
static void removeFlag(LoggingFlag flag)
Removes logging flag used internally.
Definition easylogging++.h:3916
static void reconfigureAllLoggers(const Configurations &configurations)
Reconfigures all the existing loggers with new configurations.
Definition easylogging++.cc:3415
static Logger * getLogger(const std::string &identity, bool registerIfNotAvailable=true)
Gets existing or registers new logger.
Definition easylogging++.cc:3378
static bool hasFlag(LoggingFlag flag)
Determines whether or not certain flag is active.
Definition easylogging++.h:3920
static void uninstallLoggerRegistrationCallback(const std::string &id)
Uninstalls log dispatch callback.
Definition easylogging++.h:3862
static bool installLoggerRegistrationCallback(const std::string &id)
Installs logger registration callback, this callback is triggered when new logger is registered.
Definition easylogging++.h:3857
static void setDefaultLogBuilder(el::LogBuilderPtr &logBuilderPtr)
Changes default log builder for future loggers.
Definition easylogging++.cc:3382
static void addFlag(LoggingFlag flag)
Adds logging flag used internally.
Definition easylogging++.h:3912
static void setLoggingLevel(Level level)
Sets hierarchy for logging. Needs to enable logging flag (HierarchicalLogging).
Definition easylogging++.h:3948
static T * loggerRegistrationCallback(const std::string &id)
Definition easylogging++.h:3866
Definition easylogging++.h:2229
SysLogInitializer(const char *processIdent, int options=0, int facility=0)
Definition easylogging++.h:3700
virtual ~SysLogInitializer(void)
Definition easylogging++.h:3709
Definition easylogging++.h:3970
static const std::string version(void)
Current version number.
Definition easylogging++.cc:3559
static const std::string releaseDate(void)
Release date of current version.
Definition easylogging++.cc:3563
Definition easylogging++.h:2835
base::type::string_t build(const LogMessage *logMessage, bool appendNewLine) const
Definition easylogging++.cc:2788
Definition easylogging++.h:2796
void handle(const LogDispatchData *data)
Definition easylogging++.cc:2457
void dispatch(base::type::string_t &&rawLinePrefix, base::type::string_t &&rawLinePayload, base::type::string_t &&logLine)
Definition easylogging++.cc:2602
const LogDispatchData * m_data
Definition easylogging++.h:2800
Predicate(const char *filename, base::type::LineNumber lineNumber)
Definition easylogging++.h:2137
const char * m_filename
Definition easylogging++.h:2148
base::type::LineNumber m_lineNumber
Definition easylogging++.h:2149
bool operator()(const HitCounter *counter)
Definition easylogging++.h:2141
Class that keeps record of current line hit for occasional logging.
Definition easylogging++.h:2073
void validateHitCounts(std::size_t n)
Validates hit counts and resets it if necessary.
Definition easylogging++.h:2112
HitCounter(const char *filename, base::type::LineNumber lineNumber)
Definition easylogging++.h:2081
HitCounter(void)
Definition easylogging++.h:2075
void resetLocation(const char *filename, base::type::LineNumber lineNumber)
Resets location of current hit counter.
Definition easylogging++.h:2106
base::type::LineNumber m_lineNumber
Definition easylogging++.h:2154
virtual ~HitCounter(void)
Definition easylogging++.h:2102
HitCounter & operator=(const HitCounter &hitCounter)
Definition easylogging++.h:2093
base::type::LineNumber lineNumber(void) const
Definition easylogging++.h:2123
HitCounter(const HitCounter &hitCounter)
Definition easylogging++.h:2087
std::size_t m_hitCounts
Definition easylogging++.h:2155
std::size_t hitCounts(void) const
Definition easylogging++.h:2127
const char * filename(void) const
Definition easylogging++.h:2119
void increment(void)
Definition easylogging++.h:2131
const char * m_filename
Definition easylogging++.h:2153
Dispatches log messages.
Definition easylogging++.h:2840
LogDispatcher(bool proceed, LogMessage *logMessage, base::DispatchAction dispatchAction)
Definition easylogging++.h:2842
LogMessage * m_logMessage
Definition easylogging++.h:2852
bool m_proceed
Definition easylogging++.h:2851
base::DispatchAction m_dispatchAction
Definition easylogging++.h:2853
Represents log format containing flags and date format. This is used internally to start initial log.
Definition easylogging++.h:1615
std::string m_currentUser
Definition easylogging++.h:1676
Level m_level
Definition easylogging++.h:1671
virtual ~LogFormat(void)
Definition easylogging++.h:1622
LogFormat(void)
Definition easylogging++.cc:1545
std::string m_currentHost
Definition easylogging++.h:1677
LogFormat & operator=(const LogFormat &logFormat)
Definition easylogging++.cc:1581
std::string m_dateTimeFormat
Definition easylogging++.h:1674
const base::type::string_t & userFormat(void) const
Definition easylogging++.h:1633
bool hasFlag(base::FormatFlags flag) const
Definition easylogging++.h:1649
base::type::EnumType flags(void) const
Definition easylogging++.h:1645
void addFlag(base::FormatFlags flag)
Definition easylogging++.h:1666
base::type::string_t m_format
Definition easylogging++.h:1673
const std::string & dateTimeFormat(void) const
Definition easylogging++.h:1641
base::type::string_t m_userFormat
Definition easylogging++.h:1672
Level level(void) const
Definition easylogging++.h:1629
base::type::EnumType m_flags
Definition easylogging++.h:1675
virtual void log(el::base::type::ostream_t &os) const
Definition easylogging++.h:1653
const base::type::string_t & format(void) const
Definition easylogging++.h:1637
Definition easylogging++.h:2932
Logger * m_logger
Definition easylogging++.h:3220
MessageBuilder & operator<<(const std::string &msg)
Definition easylogging++.h:2946
MessageBuilder & writeIterator(Iterator begin_, Iterator end_, std::size_t size_)
Definition easylogging++.h:3224
MessageBuilder & operator<<(std::ostream &(*OStreamMani)(std::ostream &))
Definition easylogging++.h:2968
MessageBuilder(void)
Definition easylogging++.h:2934
const base::type::char_t * m_containerLogSeperator
Definition easylogging++.h:3221
Internal helper class that prevent copy constructor for class.
Definition easylogging++.h:569
NoCopy(const NoCopy &)
NoCopy & operator=(const NoCopy &)
NoCopy(void)
Definition easylogging++.h:571
NullWriter & operator<<(std::ostream &(*)(std::ostream &))
Definition easylogging++.h:3246
NullWriter(void)
Definition easylogging++.h:3243
NullWriter & operator<<(const T &)
Definition easylogging++.h:3251
Definition easylogging++.h:3315
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:3317
Repository for hit counters used across the application.
Definition easylogging++.h:2158
const base::HitCounter * getCounter(const char *filename, base::type::LineNumber lineNumber)
Gets hit counter registered at specified position.
Definition easylogging++.h:2173
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:1954
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:1984
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:1967
Loggers repository.
Definition easylogging++.h:2388
std::unordered_map< std::string, base::type::LoggerRegistrationCallbackPtr > m_loggerRegistrationCallbacks
Definition easylogging++.h:2452
Logger * get(const std::string &id, bool forceCreation=true)
Definition easylogging++.cc:2004
void setDefaultConfigurations(const Configurations &configurations)
Definition easylogging++.h:2396
base::LogStreamsReferenceMap * logStreamsReference(void)
Definition easylogging++.h:2434
T * loggerRegistrationCallback(const std::string &id)
Definition easylogging++.h:2419
bool installLoggerRegistrationCallback(const std::string &id)
Definition easylogging++.h:2408
void unsafeFlushAll(void)
Definition easylogging++.cc:2041
Configurations * defaultConfigurations(void)
Definition easylogging++.h:2401
bool has(const std::string &id)
Definition easylogging++.h:2425
void flushAll(void)
Definition easylogging++.h:2438
Configurations m_defaultConfigurations
Definition easylogging++.h:2450
virtual ~RegisteredLoggers(void)
Definition easylogging++.h:2392
void unregister(Logger *&logger)
Definition easylogging++.h:2429
RegisteredLoggers(const LogBuilderPtr &defaultLogBuilder)
Definition easylogging++.cc:1999
void uninstallLoggerRegistrationCallback(const std::string &id)
Definition easylogging++.h:2414
base::LogStreamsReferenceMap m_logStreamsReference
Definition easylogging++.h:2451
LogBuilderPtr m_defaultLogBuilder
Definition easylogging++.h:2449
void setDefaultLogBuilder(LogBuilderPtr &logBuilderPtr)
Definition easylogging++.h:2443
Internal helper class that makes all default constructors private.
Definition easylogging++.h:580
StaticClass & operator=(const StaticClass &)
StaticClass(const StaticClass &)
Easylogging++ management storage.
Definition easylogging++.h:2617
base::threading::Mutex & customFormatSpecifiersLock()
Definition easylogging++.h:2701
base::RegisteredHitCounters * m_registeredHitCounters
Definition easylogging++.h:2761
base::VRegistry * m_vRegistry
Definition easylogging++.h:2764
void setLoggingLevel(Level level)
Definition easylogging++.h:2705
void setThreadName(const std::string &name)
Sets thread name for current thread. Requires std::thread.
Definition easylogging++.h:2743
std::unordered_map< std::string, std::string > m_threadNames
Definition easylogging++.h:2773
bool hasFlag(LoggingFlag flag) const
Definition easylogging++.h:2669
void unsetPreRollOutCallback(void)
Definition easylogging++.h:2685
void uninstallLogDispatchCallback(const std::string &id)
Definition easylogging++.h:2715
void addFlag(LoggingFlag flag)
Definition easylogging++.h:2661
base::RegisteredLoggers * m_registeredLoggers
Definition easylogging++.h:2762
Storage(const LogBuilderPtr &defaultLogBuilder)
Definition easylogging++.cc:2301
PreRollOutCallback m_preRollOutCallback
Definition easylogging++.h:2770
T * logDispatchCallback(const std::string &id)
Definition easylogging++.h:2719
void setFlags(base::type::EnumType flags)
Definition easylogging++.h:2677
const std::vector< CustomFormatSpecifier > * customFormatSpecifiers(void) const
Definition easylogging++.h:2697
const base::utils::CommandLineArgs * commandLineArgs(void) const
Definition easylogging++.h:2657
void setPreRollOutCallback(const PreRollOutCallback &callback)
Definition easylogging++.h:2681
bool validateEveryNCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t occasion)
Definition easylogging++.h:2627
base::RegisteredLoggers * registeredLoggers(void) const
Definition easylogging++.h:2643
std::unordered_map< std::string, base::type::LogDispatchCallbackPtr > m_logDispatchCallbacks
Definition easylogging++.h:2771
void removeFlag(LoggingFlag flag)
Definition easylogging++.h:2665
base::threading::Mutex m_threadNamesLock
Definition easylogging++.h:2776
base::RegisteredHitCounters * hitCounters(void) const
Definition easylogging++.h:2639
std::unordered_map< std::string, base::type::PerformanceTrackingCallbackPtr > m_performanceTrackingCallbacks
Definition easylogging++.h:2772
void setApplicationArguments(int argc, const char **argv)
Definition easylogging++.h:2789
bool validateAfterNCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
Definition easylogging++.h:2631
void setApplicationArguments(int argc, char **argv)
Definition easylogging++.cc:2394
std::vector< CustomFormatSpecifier > m_customFormatSpecifiers
Definition easylogging++.h:2774
Level m_loggingLevel
Definition easylogging++.h:2777
base::VRegistry * vRegistry(void) const
Definition easylogging++.h:2647
base::type::EnumType m_flags
Definition easylogging++.h:2763
bool installLogDispatchCallback(const std::string &id)
Definition easylogging++.h:2710
base::threading::Mutex m_customFormatSpecifiersLock
Definition easylogging++.h:2775
base::type::EnumType flags(void) const
Definition easylogging++.h:2673
std::string getThreadName(const std::string &threadId)
Definition easylogging++.h:2749
PreRollOutCallback & preRollOutCallback(void)
Definition easylogging++.h:2689
bool validateNTimesCounter(const char *filename, base::type::LineNumber lineNumber, std::size_t n)
Definition easylogging++.h:2635
base::utils::CommandLineArgs m_commandLineArgs
Definition easylogging++.h:2769
A subsecond precision class containing actual width and offset of the subsecond part.
Definition easylogging++.h:865
unsigned int m_offset
Definition easylogging++.h:877
bool operator==(const SubsecondPrecision &ssPrec)
Definition easylogging++.h:873
SubsecondPrecision(void)
Definition easylogging++.h:867
int m_width
Definition easylogging++.h:876
void init(int width)
Definition easylogging++.cc:1519
SubsecondPrecision(int width)
Definition easylogging++.h:870
Configurations with data types.
Definition easylogging++.h:1943
Conf_T & getConfigByRef(Level level, std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition easylogging++.h:1998
Conf_T getConfigByVal(Level level, const std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition easylogging++.h:1992
const Configurations * configurations(void) const
Definition easylogging++.h:1955
TypedConfigurations(Configurations *configurations, base::LogStreamsReferenceMap *logStreamsReference)
Constructor to initialize (construct) the object off el::Configurations.
Definition easylogging++.cc:1728
std::unordered_map< Level, base::SubsecondPrecision > m_subsecondPrecisionMap
Definition easylogging++.h:1978
std::unordered_map< Level, std::size_t > m_maxLogFileSizeMap
Definition easylogging++.h:1981
bool unsafeValidateFileRolling(Level level, const PreRollOutCallback &preRollOutCallback)
Definition easylogging++.cc:1933
std::unordered_map< Level, base::LogFormat > m_logFormatMap
Definition easylogging++.h:1977
virtual ~TypedConfigurations(void)
Definition easylogging++.h:1952
Conf_T & unsafeGetConfigByRef(Level level, std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition easylogging++.h:2021
std::unordered_map< Level, bool > m_performanceTrackingMap
Definition easylogging++.h:1979
std::unordered_map< Level, base::FileStreamPtr > m_fileStreamMap
Definition easylogging++.h:1980
std::unordered_map< Level, bool > m_toStandardOutputMap
Definition easylogging++.h:1976
std::unordered_map< Level, bool > m_toFileMap
Definition easylogging++.h:1974
Conf_T unsafeGetConfigByVal(Level level, const std::unordered_map< Level, Conf_T > *confMap, const char *confName)
Definition easylogging++.h:2004
std::unordered_map< Level, std::size_t > m_logFlushThresholdMap
Definition easylogging++.h:1982
Configurations * m_configurations
Definition easylogging++.h:1972
base::LogStreamsReferenceMap * m_logStreamsReference
Definition easylogging++.h:1983
void setValue(Level level, const Conf_T &value, std::unordered_map< Level, Conf_T > *confMap, bool includeGlobalLevel=true)
Definition easylogging++.h:2038
std::unordered_map< Level, std::string > m_filenameMap
Definition easylogging++.h:1975
std::unordered_map< Level, bool > m_enabledMap
Definition easylogging++.h:1973
bool validateFileRolling(Level level, const PreRollOutCallback &preRollOutCallback)
Definition easylogging++.h:2067
Represents registries for verbose logging.
Definition easylogging++.h:2458
const std::string & getFilenameCommonPrefix() const
Definition easylogging++.h:2502
std::map< std::string, int > m_cached_allowed_categories
Definition easylogging++.h:2511
void clearModules(void)
Definition easylogging++.h:2471
base::type::VerboseLevel m_level
Definition easylogging++.h:2507
std::string m_categoriesString
Definition easylogging++.h:2512
std::vector< std::pair< std::string, Level > > m_categories
Definition easylogging++.h:2510
std::string m_filenameCommonPrefix
Definition easylogging++.h:2513
void setFilenameCommonPrefix(const std::string &prefix)
Definition easylogging++.h:2498
const std::unordered_map< std::string, base::type::VerboseLevel > & modules(void) const
Definition easylogging++.h:2487
base::type::VerboseLevel level(void) const
Definition easylogging++.h:2465
base::type::EnumType * m_pFlags
Definition easylogging++.h:2508
std::unordered_map< std::string, base::type::VerboseLevel > m_modules
Definition easylogging++.h:2509
VRegistry(base::type::VerboseLevel level, base::type::EnumType *pFlags)
Definition easylogging++.cc:2052
bool vModulesEnabled(void)
Whether or not vModules enabled.
Definition easylogging++.h:2494
void setLevel(base::type::VerboseLevel level)
Sets verbose level. Accepted range is 0-9.
Definition easylogging++.cc:2056
Main entry point of each logging.
Definition easylogging++.h:3260
void initializeLogger(const std::string &loggerId, bool lookup=true, bool needLock=true)
Definition easylogging++.cc:2959
Logger * m_logger
Definition easylogging++.h:3302
const char * m_file
Definition easylogging++.h:3298
bool m_proceed
Definition easylogging++.h:3303
Level m_level
Definition easylogging++.h:3296
base::type::VerboseLevel m_verboseLevel
Definition easylogging++.h:3301
const char * m_func
Definition easylogging++.h:3300
Writer(LogMessage *msg, base::DispatchAction dispatchAction=base::DispatchAction::NormalLog)
Definition easylogging++.h:3269
base::MessageBuilder m_messageBuilder
Definition easylogging++.h:3304
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:3262
virtual ~Writer(void)
Definition easylogging++.h:3274
std::vector< std::string > m_loggerIds
Definition easylogging++.h:3306
LogMessage * m_msg
Definition easylogging++.h:3295
const base::type::LineNumber m_line
Definition easylogging++.h:3299
Writer & operator<<(const std::string &log)
Definition easylogging++.h:3278
base::threading::ScopedLock m_sync
Definition easylogging++.h:3307
base::DispatchAction m_dispatchAction
Definition easylogging++.h:3305
Color m_color
Definition easylogging++.h:3297
void processDispatch()
Definition easylogging++.cc:3000
void triggerDispatch(void)
Definition easylogging++.cc:3053
CrashHandler(bool)
Definition easylogging++.h:3689
Base of thread safe class, this class is inheritable-only.
Definition easylogging++.h:1033
virtual void acquireLock(void) ELPP_FINAL
Definition easylogging++.h:1035
base::threading::Mutex m_mutex
Definition easylogging++.h:1042
virtual void releaseLock(void) ELPP_FINAL
Definition easylogging++.h:1036
virtual ~ThreadSafe(void)
Definition easylogging++.h:1040
ThreadSafe(void)
Definition easylogging++.h:1039
virtual base::threading::Mutex & lock(void) ELPP_FINAL
Definition easylogging++.h:1037
Mutex wrapper used when multi-threading is disabled.
Definition easylogging++.h:1008
NoMutex(void)
Definition easylogging++.h:1010
void lock(void)
Definition easylogging++.h:1011
bool try_lock(void)
Definition easylogging++.h:1012
void unlock(void)
Definition easylogging++.h:1015
Lock guard wrapper used when multi-threading is disabled.
Definition easylogging++.h:1019
NoScopedLock(Mutex &)
Definition easylogging++.h:1021
virtual ~NoScopedLock(void)
Definition easylogging++.h:1023
virtual const Container & list(void) const ELPP_FINAL
Returns underlying container by constant reference.
Definition easylogging++.h:1386
virtual void unregisterAll(void)=0
Unregisters all the pointers from current repository.
bool operator!=(const AbstractRegistry< T_Ptr, Container > &other)
Definition easylogging++.h:1324
virtual const_iterator cbegin(void) const ELPP_FINAL
Definition easylogging++.h:1361
Container::const_iterator const_iterator
Definition easylogging++.h:1298
virtual bool empty(void) const ELPP_FINAL
Definition easylogging++.h:1371
virtual iterator begin(void) ELPP_FINAL
Definition easylogging++.h:1350
void reinitDeepCopy(const AbstractRegistry< T_Ptr, Container > &sr)
Definition easylogging++.h:1395
Container m_list
Definition easylogging++.h:1401
virtual std::size_t size(void) const ELPP_FINAL
Definition easylogging++.h:1376
Container::iterator iterator
Definition easylogging++.h:1297
virtual iterator end(void) ELPP_FINAL
Definition easylogging++.h:1355
virtual ~AbstractRegistry(void)
Definition easylogging++.h:1346
AbstractRegistry & operator=(AbstractRegistry &&sr)
Assignment move operator.
Definition easylogging++.h:1337
AbstractRegistry(AbstractRegistry &&sr)
Move constructor that is useful for base classes.
Definition easylogging++.h:1304
virtual Container & list(void) ELPP_FINAL
Returns underlying container by reference.
Definition easylogging++.h:1381
virtual void deepCopy(const AbstractRegistry< T_Ptr, Container > &)=0
bool operator==(const AbstractRegistry< T_Ptr, Container > &other)
Definition easylogging++.h:1312
virtual const_iterator cend(void) const ELPP_FINAL
Definition easylogging++.h:1366
AbstractRegistry(void)
Default constructor.
Definition easylogging++.h:1301
Command line arguments for application if specified using el::Helpers::setArgs(..) or START_EASYLOGGI...
Definition easylogging++.h:1251
CommandLineArgs(int argc, char **argv)
Definition easylogging++.h:1259
void setArgs(int argc, const char **argv)
Sets arguments and parses them.
Definition easylogging++.h:1264
int m_argc
Definition easylogging++.h:1283
virtual ~CommandLineArgs(void)
Definition easylogging++.h:1262
std::unordered_map< std::string, std::string > m_paramsWithValue
Definition easylogging++.h:1285
CommandLineArgs(void)
Definition easylogging++.h:1253
CommandLineArgs(int argc, const char **argv)
Definition easylogging++.h:1256
std::vector< std::string > m_params
Definition easylogging++.h:1286
char ** m_argv
Definition easylogging++.h:1284
Contains utilities for cross-platform date/time. This class make use of el::base::utils::Str.
Definition easylogging++.h:1219
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:1298
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:1327
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:1265
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:1309
static std::string getDateTime(const char *format, const base::SubsecondPrecision *ssPrec)
Gets current date and time with a subsecond part.
Definition easylogging++.cc:1292
static struct::tm * buildTimeInfo(struct timeval *currTime, struct ::tm *timeInfo)
Definition easylogging++.cc:1340
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:1366
Definition easylogging++.h:1077
static base::type::fstream_t * newFileStream(const std::string &filename)
Creates new out file stream for specified filename.
Definition easylogging++.cc:830
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:932
static bool pathExists(const char *path, bool considerFile=false)
Determines whether or not provided path exist in current file system.
Definition easylogging++.cc:864
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:948
static bool createPath(const std::string &path)
Creates specified path on file system.
Definition easylogging++.cc:881
static std::size_t getSizeOfFile(base::type::fstream_t *fs)
Gets size of file provided in stream.
Definition easylogging++.cc:854
static std::string extractPathFromFilename(const std::string &fullPath, const char *seperator=base::consts::kFilePathSeperator)
Extracts path of filename with leading slash.
Definition easylogging++.cc:921
Operating System helper static class used internally. You should not use it.
Definition easylogging++.h:1175
static std::string currentHost(void)
Gets current host name or computer name.
Definition easylogging++.cc:1235
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:1198
static const std::string getBashOutput(const char *command)
Runs command on terminal and returns the output.
Definition easylogging++.cc:1170
static std::string currentUser(void)
Gets current username.
Definition easylogging++.cc:1222
static bool termSupportsColor(std::string &term)
Whether or not the named terminal supports colors.
Definition easylogging++.cc:1253
A pointer registry mechanism to manage memory and provide search functionalities. (predicate version)...
Definition easylogging++.h:1486
T_Ptr * get(const T &arg1, const T2 arg2)
Gets pointer from repository with speicifed arguments. Arguments are passed to predicate in order to ...
Definition easylogging++.h:1556
RegistryWithPred(const RegistryWithPred &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
Definition easylogging++.h:1499
RegistryWithPred< T_Ptr, Pred >::iterator iterator
Definition easylogging++.h:1488
virtual void registerNew(T_Ptr *ptr) ELPP_FINAL
Definition easylogging++.h:1549
RegistryWithPred(void)
Definition easylogging++.h:1491
virtual void unregisterAll(void) ELPP_FINAL
Definition easylogging++.h:1525
friend base::type::ostream_t & operator<<(base::type::ostream_t &os, const RegistryWithPred &sr)
Definition easylogging++.h:1517
virtual void deepCopy(const AbstractRegistry< T_Ptr, std::vector< T_Ptr * > > &sr)
Definition easylogging++.h:1565
virtual void unregister(T_Ptr *&ptr) ELPP_FINAL
Definition easylogging++.h:1534
RegistryWithPred< T_Ptr, Pred >::const_iterator const_iterator
Definition easylogging++.h:1489
virtual ~RegistryWithPred(void)
Definition easylogging++.h:1494
RegistryWithPred & operator=(const RegistryWithPred &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
Definition easylogging++.h:1509
A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate vers...
Definition easylogging++.h:1410
virtual void deepCopy(const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * > > &sr) ELPP_FINAL
Definition easylogging++.h:1474
Registry & operator=(const Registry &sr)
Assignment operator that unregisters all the existing registeries and deeply copies each of repo elem...
Definition easylogging++.h:1428
Registry< T_Ptr, T_Key >::const_iterator const_iterator
Definition easylogging++.h:1413
T_Ptr * get(const T_Key &uniqKey)
Definition easylogging++.h:1466
virtual ~Registry(void)
Definition easylogging++.h:1436
Registry< T_Ptr, T_Key >::iterator iterator
Definition easylogging++.h:1412
Registry(void)
Definition easylogging++.h:1415
void unregister(const T_Key &uniqKey)
Definition easylogging++.h:1457
virtual void registerNew(const T_Key &uniqKey, T_Ptr *ptr) ELPP_FINAL
Registers new registry to repository.
Definition easylogging++.h:1451
virtual void unregisterAll(void) ELPP_FINAL
Definition easylogging++.h:1441
Registry(const Registry &sr)
Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor...
Definition easylogging++.h:1418
String utilities helper class used internally. You should not use it.
Definition easylogging++.h:1104
static bool isDigit(char c)
Checks if character is digit. Dont use libc implementation of it to prevent locale issues.
Definition easylogging++.h:1107
Definition easylogging++.h:1571
static T * callback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
Definition easylogging++.h:1590
static bool installCallback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
Definition easylogging++.h:1574
static void uninstallCallback(const std::string &id, std::unordered_map< std::string, TPtr > *mapT)
Definition easylogging++.h:1583
wallet init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled)
#define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp)
Definition easylogging++.h:2977
#define ELPP_FINAL
Definition easylogging++.h:284
#define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp)
Definition easylogging++.h:2987
#define ELPP_INTERNAL_ERROR(msg, pe)
Definition easylogging++.h:207
#define ELPP_EXPORT
Definition easylogging++.h:252
#define ELPP_UNUSED(x)
Definition easylogging++.h:240
#define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp)
Definition easylogging++.h:2972
#define ELPP_LITERAL(txt)
Definition easylogging++.h:539
#define ELPP_SIMPLE_LOG(LOG_TYPE)
Definition easylogging++.h:2937
#define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp)
Definition easylogging++.h:2982
#define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp)
Definition easylogging++.h:2992
#define ELPP
Definition easylogging++.h:2795
#define ELPP_INTERNAL_INFO(lvl, msg)
Definition easylogging++.h:221
bool operator==(expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
Definition expect.h:402
conn start()
#define true
#define false
#define inline
Definition inline_c.h:34
void get(std::istream &input, bool &res)
Definition io.h:61
Definition base.py:1
args
Definition build_protob.py:10
log
Definition coin_info.py:14
t
Definition console.py:33
next(obj)
Definition ast.py:58
declaration and default definition for the functions used the API
Definition expect.cpp:34
static const int kCrashSignalsCount
Definition easylogging++.h:836
static const char kFormatSpecifierChar
Definition easylogging++.h:764
const struct el::base::consts::@316026342360375017143256044144076315127247255074 kCrashSignals[]
static const std::size_t kSourceLineMaxLength
Definition easylogging++.h:794
static const char * kDefaultLoggerId
Definition easylogging++.h:772
static const char * kFilePathSeperator
Definition easylogging++.h:790
const struct el::base::consts::@241223351030321172077157116072250137006277251154 kTimeFormats[]
static const unsigned int kDefaultSubsecondPrecision
Definition easylogging++.h:767
static const Level kPerformanceTrackerDefaultLevel
Definition easylogging++.h:795
static const char kFormatSpecifierCharValue
Definition easylogging++.h:763
static const unsigned int kMaxLogPerCounter
Definition easylogging++.h:765
static const std::size_t kSourceFilenameMaxLength
Definition easylogging++.h:793
static const unsigned int kMaxLogPerContainer
Definition easylogging++.h:766
static const int kTimeFormatsCount
Definition easylogging++.h:807
base::threading::internal::NoScopedLock< base::threading::Mutex > ScopedLock
Definition easylogging++.h:1030
base::threading::internal::NoMutex Mutex
Definition easylogging++.h:1029
static std::string getCurrentThreadId(void)
Definition easylogging++.h:1071
Data types used by Easylogging++.
Definition easylogging++.h:521
std::shared_ptr< PerformanceTrackingCallback > PerformanceTrackingCallbackPtr
Definition easylogging++.h:562
std::unique_ptr< el::base::PerformanceTracker > PerformanceTrackerPtr
Definition easylogging++.h:564
std::stringstream stringstream_t
Definition easylogging++.h:548
unsigned short VerboseLevel
Definition easylogging++.h:558
base::Storage * StoragePointer
Definition easylogging++.h:560
std::fstream fstream_t
Definition easylogging++.h:549
std::string string_t
Definition easylogging++.h:547
std::ostream ostream_t
Definition easylogging++.h:550
unsigned long int LineNumber
Definition easylogging++.h:559
std::shared_ptr< LogDispatchCallback > LogDispatchCallbackPtr
Definition easylogging++.h:561
unsigned int EnumType
Definition easylogging++.h:557
std::shared_ptr< LoggerRegistrationCallback > LoggerRegistrationCallbackPtr
Definition easylogging++.h:563
char char_t
Definition easylogging++.h:546
Bitwise operations for C++11 strong enum class. This casts e into Flag_T and returns value after bitw...
Definition easylogging++.h:897
static base::type::EnumType Or(Enum e, base::type::EnumType flag)
Definition easylogging++.h:907
static base::type::EnumType And(Enum e, base::type::EnumType flag)
Definition easylogging++.h:899
static base::type::EnumType Not(Enum e, base::type::EnumType flag)
Definition easylogging++.h:903
Namespace containing utility functions/static classes used internally.
Definition easylogging++.cc:119
base::type::ostream_t & operator<<(base::type::ostream_t &os, const CommandLineArgs &c)
Definition easylogging++.cc:1483
static bool hasFlag(Enum e, base::type::EnumType flag)
Definition easylogging++.h:920
static void removeFlag(Enum e, base::type::EnumType *flag)
Definition easylogging++.h:916
static void addFlag(Enum e, base::type::EnumType *flag)
Definition easylogging++.h:912
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
Namespace containing base/internal functionality used by Easylogging++.
Definition easylogging++.cc:31
void sanitize(std::string &s)
Definition easylogging++.cc:2587
ELPP_EXPORT base::type::StoragePointer elStorage
TimestampUnit
Enum to represent timestamp unit.
Definition easylogging++.h:843
@ Day
Definition easylogging++.h:844
@ Microsecond
Definition easylogging++.h:844
@ Minute
Definition easylogging++.h:844
@ Millisecond
Definition easylogging++.h:844
@ Hour
Definition easylogging++.h:844
@ Second
Definition easylogging++.h:844
FormatFlags
Format flags used to determine specifiers that are active for performance improvements.
Definition easylogging++.h:847
@ File
Definition easylogging++.h:850
@ LoggerId
Definition easylogging++.h:849
@ FileBase
Definition easylogging++.h:861
@ Line
Definition easylogging++.h:851
@ ThreadId
Definition easylogging++.h:859
@ Function
Definition easylogging++.h:853
@ DateTime
Definition easylogging++.h:848
@ User
Definition easylogging++.h:854
@ LevelShort
Definition easylogging++.h:862
@ AppName
Definition easylogging++.h:858
@ Host
Definition easylogging++.h:855
@ Location
Definition easylogging++.h:852
DispatchAction
Action to be taken for dispatching.
Definition easylogging++.h:2179
@ NormalLog
Definition easylogging++.h:2180
@ FileOnlyLog
Definition easylogging++.h:2180
@ None
Definition easylogging++.h:2180
@ SysLog
Definition easylogging++.h:2180
std::unordered_map< std::string, FileStreamPtr > LogStreamsReferenceMap
Definition easylogging++.h:1936
std::shared_ptr< base::type::fstream_t > FileStreamPtr
Definition easylogging++.h:1935
SubsecondPrecision MillisecondsWidth
Type alias of SubsecondPrecision.
Definition easylogging++.h:882
static void defaultPreRollOutCallback(const char *, std::size_t)
Definition easylogging++.h:841
Easylogging++ entry namespace.
Definition easylogging++.cc:28
LoggingFlag
Flags used while writing logs. This flags are set by user.
Definition easylogging++.h:725
@ DisableVModulesExtensions
Disable VModules extensions.
Definition easylogging++.h:748
@ DisablePerformanceTrackingCheckpointComparison
Disables comparing performance tracker's checkpoints.
Definition easylogging++.h:744
@ DisableVModules
Disable VModules.
Definition easylogging++.h:746
@ CreateLoggerAutomatically
Creates logger automatically when not available.
Definition easylogging++.h:752
@ AutoSpacing
Adds spaces b/w logs that separated by left-shift operator.
Definition easylogging++.h:754
@ HierarchicalLogging
Enables hierarchical logging.
Definition easylogging++.h:750
@ ImmediateFlush
Flushes log with every log-entry (performance sensative) - Disabled by default.
Definition easylogging++.h:736
@ LogDetailedCrashReason
When handling crashes by default, detailed crash reason will be logged as well.
Definition easylogging++.h:732
@ NewLineForContainer
Makes sure we have new line for each container log entry.
Definition easylogging++.h:727
@ StrictLogFileSizeCheck
Enables strict file rolling.
Definition easylogging++.h:738
@ DisableApplicationAbortOnFatalLog
Allows to disable application abortion when logged using FATAL level.
Definition easylogging++.h:734
@ MultiLoggerSupport
Supports use of multiple logging in same macro, e.g, CLOG(INFO, "default", "network").
Definition easylogging++.h:742
@ IgnoreSigInt
Definition easylogging++.h:758
@ AllowVerboseIfModuleNotSpecified
Makes sure if -vmodule is used and does not specifies a module, then verbose logging is allowed via t...
Definition easylogging++.h:730
@ FixedTimeFormat
Preserves time format and does not convert it to sec, hour etc (performance tracking only).
Definition easylogging++.h:756
@ ColoredTerminalOutput
Make terminal output colorful for supported terminals.
Definition easylogging++.h:740
ConfigurationType
Represents enumeration of ConfigurationType used to configure or access certain aspect of logging.
Definition easylogging++.h:664
@ Enabled
Determines whether or not corresponding level and logger of logging is enabled You may disable all lo...
Definition easylogging++.h:667
@ Filename
Determines log file (full path) to write logs to for correponding level and logger.
Definition easylogging++.h:676
@ MaxLogFileSize
Specifies log file max size.
Definition easylogging++.h:689
@ Format
Determines format of logging corresponding level and logger.
Definition easylogging++.h:674
@ SubsecondPrecision
Specifies precision of the subsecond part. It should be within range (1-6).
Definition easylogging++.h:678
@ ToStandardOutput
Whether or not to write corresponding level and logger log to standard output. By standard output mea...
Definition easylogging++.h:672
@ PerformanceTracking
Determines whether or not performance tracking is enabled.
Definition easylogging++.h:684
@ LogFlushThreshold
Specifies number of log entries to hold until we flush pending log data.
Definition easylogging++.h:691
@ ToFile
Whether or not to write corresponding log to log file.
Definition easylogging++.h:669
std::function< std::string(const LogMessage *)> FormatSpecifierValueResolver
Resolving function for format specifier.
Definition easylogging++.h:1682
Level
Represents enumeration for severity level used to determine level of logging.
Definition easylogging++.h:591
@ Warning
Useful when application has potentially harmful situtaions.
Definition easylogging++.h:603
@ Info
Mainly useful to represent current progress of application.
Definition easylogging++.h:607
@ Global
Generic level that represents all the levels. Useful when setting global configuration for all levels...
Definition easylogging++.h:593
@ Unknown
Represents unknown level.
Definition easylogging++.h:609
@ Fatal
Severe error information that will presumably abort application.
Definition easylogging++.h:599
@ Error
Information representing errors in application but application will keep running.
Definition easylogging++.h:601
@ Debug
Informational events most useful for developers to debug application.
Definition easylogging++.h:597
@ Verbose
Information that can be highly useful and vary with verbose logging level.
Definition easylogging++.h:605
@ Trace
Information that can be useful to back-trace certain events - mostly useful than debug logs.
Definition easylogging++.h:595
base::debug::CrashHandler elCrashHandler
std::shared_ptr< LogBuilder > LogBuilderPtr
Definition easylogging++.h:2250
Color
Definition easylogging++.h:611
@ Cyan
Definition easylogging++.h:618
@ Yellow
Definition easylogging++.h:615
@ Default
Definition easylogging++.h:612
@ Blue
Definition easylogging++.h:616
@ Magenta
Definition easylogging++.h:617
@ Green
Definition easylogging++.h:614
@ Red
Definition easylogging++.h:613
std::function< void(const char *, std::size_t)> PreRollOutCallback
Definition easylogging++.h:839
Definition document.h:406
@ empty
Definition readline_buffer.h:9
Definition enums.h:68
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
Definition gmock-generated-matchers.h:481
c
Definition wide_difficulty.py:9
const GenericPointer< typename T::ValueType > T2 value
Definition pointer.h:1225
const GenericPointer< typename T::ValueType > & pointer
Definition pointer.h:1124
#define M(w0, w14, w9, w1)
Definition sha512-blocks.c:41
tools::wallet2::message_signature_result_t result
Definition signature.cpp:62
CXA_THROW_INFO_T * info
Definition stack_trace.cpp:91
const base::type::char_t * unit
std::size_t operator()(const el::Level &l) const
Definition easylogging++.h:624
std::string data
Definition base58.cpp:37
#define T(x)