Belle II Software
light-2406-ragdoll
Logger.h
1
/**************************************************************************
2
* basf2 (Belle II Analysis Software Framework) *
3
* Author: The Belle II Collaboration *
4
* *
5
* See git log for contributors and copyright holders. *
6
* This file is licensed under LGPL-3.0, see LICENSE.md. *
7
**************************************************************************/
8
9
#pragma once
10
11
#include <framework/logging/LogConfig.h>
12
#include <framework/logging/LogMessage.h>
13
#include <framework/logging/LogSystem.h>
14
#include <framework/logging/LogVariableStream.h>
15
16
21
#define _B2_DO_NOTHING do { } while(false)
22
27
#ifdef _PACKAGE_
28
#define PACKAGENAME() _PACKAGE_
29
#else
30
#define PACKAGENAME() nullptr
31
#endif
32
37
#if defined(__GNUC__)
38
#define FUNCTIONNAME() __PRETTY_FUNCTION__
39
#elif defined(__ICC) || defined(__ECC) || defined(__APPLE__)
40
#define FUNCTIONNAME() __FUNCTION__
41
#else
42
#define FUNCTIONNAME() "???"
43
#endif
44
46
#define _B2LOGMESSAGE(loglevel, debuglevel, logTextAndVariables, package, function, file, line) { \
47
LogVariableStream varStream; varStream << logTextAndVariables; \
48
Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage(loglevel, std::move(varStream), package, function, file, line, debuglevel)); \
49
}
50
52
#define _B2LOGMESSAGE_IFENABLED(loglevel, debuglevel, logTextAndVariables, package, function, file, line) do { \
53
if (Belle2::LogSystem::Instance().isLevelEnabled(loglevel, debuglevel, package)) { \
54
_B2LOGMESSAGE(loglevel, debuglevel, logTextAndVariables, package, function, file, line); \
55
} } while(false)
56
58
#define B2LOG(loglevel, debuglevel, streamText) \
59
_B2LOGMESSAGE_IFENABLED(loglevel, debuglevel, streamText, PACKAGENAME(), FUNCTIONNAME(), __FILE__, __LINE__)
60
65
#ifdef LOG_NO_B2DEBUG
66
#define B2DEBUG(level, streamText) _B2_DO_NOTHING
67
#else
68
#define B2DEBUG(level, streamText) do { if (Belle2::LogSystem::debugEnabled()) B2LOG(Belle2::LogConfig::c_Debug, level, streamText); } while(false)
69
#endif
70
76
#define B2DEBUG_MODIFIABLE(level, streamText) B2DEBUG(Belle2::LogConfig::c_Debug, level, streamText)
77
78
83
#ifdef LOG_NO_B2INFO
84
#define B2INFO(streamText) _B2_DO_NOTHING
85
#else
86
#define B2INFO(streamText) B2LOG(Belle2::LogConfig::c_Info, 0, streamText)
87
#endif
88
93
#ifdef LOG_NO_B2RESULT
94
#define B2RESULT(streamText) _B2_DO_NOTHING
95
#else
96
#define B2RESULT(streamText) B2LOG(Belle2::LogConfig::c_Result, 0, streamText)
97
#endif
98
103
#ifdef LOG_NO_B2WARNING
104
#define B2WARNING(streamText) _B2_DO_NOTHING
105
#else
106
#define B2WARNING(streamText) B2LOG(Belle2::LogConfig::c_Warning, 0, streamText)
107
#endif
108
113
#define B2ERROR(streamText) do { \
114
_B2LOGMESSAGE(Belle2::LogConfig::c_Error, 0, streamText, PACKAGENAME(), FUNCTIONNAME(), __FILE__, __LINE__) \
115
} while(false)
116
117
122
#define B2FATAL(streamText) do { \
123
_B2LOGMESSAGE(Belle2::LogConfig::c_Fatal, 0, streamText, PACKAGENAME(), FUNCTIONNAME(), __FILE__, __LINE__); \
124
exit(1); \
125
} while(false)
126
127
#ifdef LOG_NO_B2ASSERT
128
#define B2ASSERT(message, condition) _B2_DO_NOTHING
129
#else
134
#define B2ASSERT(message, condition) do { \
135
if (!(condition)) { \
136
B2FATAL(message); \
137
} \
138
} while(false)
139
#endif
framework
logging
include
Logger.h
Generated on Tue Jul 9 2024 23:28:35 for Belle II Software by
1.9.6