source: s10k/CommonLibs/plog/Log.h@ 1128

Last change on this file since 1128 was 1096, checked in by s10k, 7 years ago

Added zlib, quazip, basicxmlsyntaxhighlighter, conditionalsemaphore and linenumberdisplay libraries. zlib and quazip are pre-compiled, but you can compile them yourself, just delete the dll files (or equivalent binary files to your OS)

File size: 5.2 KB
Line 
1//////////////////////////////////////////////////////////////////////////
2// Plog - portable and simple log for C++
3// Documentation and sources: https://github.com/SergiusTheBest/plog
4// License: MPL 2.0, http://mozilla.org/MPL/2.0/
5
6#pragma once
7#include <plog/Logger.h>
8#include <plog/Init.h>
9
10//////////////////////////////////////////////////////////////////////////
11// Helper macros that get context info
12
13#if _MSC_VER >= 1600 && !defined(__INTELLISENSE__) // >= Visual Studio 2010 and skip IntelliSense
14# define PLOG_GET_THIS() __if_exists(this) { this } __if_not_exists(this) { 0 }
15#else
16# define PLOG_GET_THIS() 0
17#endif
18
19#ifdef _MSC_VER
20# define PLOG_GET_FUNC() __FUNCTION__
21#elif defined(__BORLANDC__)
22# define PLOG_GET_FUNC() __FUNC__
23#else
24# define PLOG_GET_FUNC() __PRETTY_FUNCTION__
25#endif
26
27#if PLOG_CAPTURE_FILE
28# define PLOG_GET_FILE() __FILE__
29#else
30# define PLOG_GET_FILE() ""
31#endif
32
33//////////////////////////////////////////////////////////////////////////
34// Log severity level checker
35
36#define IF_LOG_(instance, severity) !(plog::get<instance>() && plog::get<instance>()->checkSeverity(severity)) ? (void)0 :
37#define IF_LOG(severity) IF_LOG_(PLOG_DEFAULT_INSTANCE, severity)
38
39//////////////////////////////////////////////////////////////////////////
40// Main logging macros
41
42#define LOG_(instance, severity) IF_LOG_(instance, severity) (*plog::get<instance>()) += plog::Record(severity, PLOG_GET_FUNC(), __LINE__, PLOG_GET_FILE(), PLOG_GET_THIS())
43#define LOG(severity) LOG_(PLOG_DEFAULT_INSTANCE, severity)
44
45#define LOG_VERBOSE LOG(plog::verbose)
46#define LOG_DEBUG LOG(plog::debug)
47#define LOG_INFO LOG(plog::info)
48#define LOG_WARNING LOG(plog::warning)
49#define LOG_ERROR LOG(plog::error)
50#define LOG_FATAL LOG(plog::fatal)
51
52#define LOG_VERBOSE_(instance) LOG_(instance, plog::verbose)
53#define LOG_DEBUG_(instance) LOG_(instance, plog::debug)
54#define LOG_INFO_(instance) LOG_(instance, plog::info)
55#define LOG_WARNING_(instance) LOG_(instance, plog::warning)
56#define LOG_ERROR_(instance) LOG_(instance, plog::error)
57#define LOG_FATAL_(instance) LOG_(instance, plog::fatal)
58
59#define LOGV LOG_VERBOSE
60#define LOGD LOG_DEBUG
61#define LOGI LOG_INFO
62#define LOGW LOG_WARNING
63#define LOGE LOG_ERROR
64#define LOGF LOG_FATAL
65
66#define LOGV_(instance) LOG_VERBOSE_(instance)
67#define LOGD_(instance) LOG_DEBUG_(instance)
68#define LOGI_(instance) LOG_INFO_(instance)
69#define LOGW_(instance) LOG_WARNING_(instance)
70#define LOGE_(instance) LOG_ERROR_(instance)
71#define LOGF_(instance) LOG_FATAL_(instance)
72
73//////////////////////////////////////////////////////////////////////////
74// Conditional logging macros
75
76#define LOG_IF_(instance, severity, condition) !(condition) ? void(0) : LOG_(instance, severity)
77#define LOG_IF(severity, condition) LOG_IF_(PLOG_DEFAULT_INSTANCE, severity, condition)
78
79#define LOG_VERBOSE_IF(condition) LOG_IF(plog::verbose, condition)
80#define LOG_DEBUG_IF(condition) LOG_IF(plog::debug, condition)
81#define LOG_INFO_IF(condition) LOG_IF(plog::info, condition)
82#define LOG_WARNING_IF(condition) LOG_IF(plog::warning, condition)
83#define LOG_ERROR_IF(condition) LOG_IF(plog::error, condition)
84#define LOG_FATAL_IF(condition) LOG_IF(plog::fatal, condition)
85
86#define LOG_VERBOSE_IF_(instance, condition) LOG_IF_(instance, plog::verbose, condition)
87#define LOG_DEBUG_IF_(instance, condition) LOG_IF_(instance, plog::debug, condition)
88#define LOG_INFO_IF_(instance, condition) LOG_IF_(instance, plog::info, condition)
89#define LOG_WARNING_IF_(instance, condition) LOG_IF_(instance, plog::warning, condition)
90#define LOG_ERROR_IF_(instance, condition) LOG_IF_(instance, plog::error, condition)
91#define LOG_FATAL_IF_(instance, condition) LOG_IF_(instance, plog::fatal, condition)
92
93#define LOGV_IF(condition) LOG_VERBOSE_IF(condition)
94#define LOGD_IF(condition) LOG_DEBUG_IF(condition)
95#define LOGI_IF(condition) LOG_INFO_IF(condition)
96#define LOGW_IF(condition) LOG_WARNING_IF(condition)
97#define LOGE_IF(condition) LOG_ERROR_IF(condition)
98#define LOGF_IF(condition) LOG_FATAL_IF(condition)
99
100#define LOGV_IF_(instance, condition) LOG_VERBOSE_IF_(instance, condition)
101#define LOGD_IF_(instance, condition) LOG_DEBUG_IF_(instance, condition)
102#define LOGI_IF_(instance, condition) LOG_INFO_IF_(instance, condition)
103#define LOGW_IF_(instance, condition) LOG_WARNING_IF_(instance, condition)
104#define LOGE_IF_(instance, condition) LOG_ERROR_IF_(instance, condition)
105#define LOGF_IF_(instance, condition) LOG_FATAL_IF_(instance, condition)
Note: See TracBrowser for help on using the repository browser.