27 #include <olp/core/logging/Format.h>
28 #include <olp/core/logging/Level.h>
30 #include <olp/core/CoreApi.h>
33 #include <boost/optional.hpp>
43 #ifdef LOGGING_DISABLE_LOCATION
45 #define OLP_SDK_LOG_FUNCTION_SIGNATURE ""
46 #define OLP_SDK_LOG_FILE ""
47 #define OLP_SDK_LOG_LINE 0
48 #define OLP_SDK_LOG_FUNCTION ""
52 #if __GNUC__ >= 3 || defined(__clang__)
53 #define OLP_SDK_LOG_FUNCTION_SIGNATURE __PRETTY_FUNCTION__
54 #elif defined(_MSC_VER)
55 #define OLP_SDK_LOG_FUNCTION_SIGNATURE __FUNCSIG__
57 #define OLP_SDK_LOG_FUNCTION_SIGNATURE __FUNCTION__
60 #define OLP_SDK_LOG_FILE __FILE__
61 #define OLP_SDK_LOG_LINE __LINE__
62 #define OLP_SDK_LOG_FUNCTION __FUNCTION__
76 #define OLP_SDK_DO_LOG(level, tag, message) \
78 std::ostringstream __strm; \
80 ::olp::logging::Log::logMessage( \
81 level, tag, __strm.str(), OLP_SDK_LOG_FILE, OLP_SDK_LOG_LINE, \
82 OLP_SDK_LOG_FUNCTION, OLP_SDK_LOG_FUNCTION_SIGNATURE); \
84 OLP_SDK_CORE_LOOP_ONCE()
96 #define OLP_SDK_LOG_CRITICAL(level, tag, message) \
97 OLP_SDK_DO_LOG(level, tag, message)
108 #define OLP_SDK_LOG_CRITICAL_INFO(tag, message) \
109 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Info, tag, message)
120 #define OLP_SDK_LOG_CRITICAL_WARNING(tag, message) \
121 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Warning, tag, message)
132 #define OLP_SDK_LOG_CRITICAL_ERROR(tag, message) \
133 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Error, tag, message)
144 #define OLP_SDK_LOG_FATAL(tag, message) \
145 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Fatal, tag, message)
154 #define OLP_SDK_LOG_ABORT(tag, message) \
156 OLP_SDK_LOG_FATAL(tag, message); \
159 OLP_SDK_CORE_LOOP_ONCE()
170 #define OLP_SDK_DO_LOG_F(level, tag, ...) \
172 std::string __message = ::olp::logging::format(__VA_ARGS__); \
173 ::olp::logging::Log::logMessage(level, tag, __message, OLP_SDK_LOG_FILE, \
174 OLP_SDK_LOG_LINE, OLP_SDK_LOG_FUNCTION, \
175 OLP_SDK_LOG_FUNCTION_SIGNATURE); \
177 OLP_SDK_CORE_LOOP_ONCE()
188 #define OLP_SDK_LOG_CRITICAL_F(level, tag, ...) \
189 OLP_SDK_DO_LOG_F(level, tag, __VA_ARGS__)
199 #define OLP_SDK_LOG_CRITICAL_INFO_F(tag, ...) \
200 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Info, tag, __VA_ARGS__)
210 #define OLP_SDK_LOG_CRITICAL_WARNING_F(tag, ...) \
211 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Warning, tag, __VA_ARGS__)
221 #define OLP_SDK_LOG_CRITICAL_ERROR_F(tag, ...) \
222 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Error, tag, __VA_ARGS__)
233 #define OLP_SDK_LOG_FATAL_F(tag, ...) \
234 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Fatal, tag, __VA_ARGS__)
242 #define OLP_SDK_LOG_ABORT_F(tag, ...) \
244 OLP_SDK_LOG_FATAL_F(tag, __VA_ARGS__); \
247 OLP_SDK_CORE_LOOP_ONCE()
249 #ifdef OLP_SDK_LOGGING_DISABLED
250 #define OLP_SDK_LOG(level, tag, message) \
253 OLP_SDK_CORE_LOOP_ONCE()
263 #define OLP_SDK_LOG(level, tag, message) \
265 if (::olp::logging::Log::isEnabled(level, tag)) { \
266 OLP_SDK_DO_LOG(level, tag, message); \
269 OLP_SDK_CORE_LOOP_ONCE()
273 #ifdef LOGGING_DISABLE_DEBUG_LEVEL
274 #define OLP_SDK_LOG_TRACE(tag, message) \
276 ::olp::logging::NullLogStream __strm; \
278 OLP_SDK_CORE_UNUSED(tag, __strm); \
280 OLP_SDK_CORE_LOOP_ONCE()
282 #define OLP_SDK_LOG_DEBUG(tag, message) \
284 ::olp::logging::NullLogStream __strm; \
286 OLP_SDK_CORE_UNUSED(tag, __strm); \
288 OLP_SDK_CORE_LOOP_ONCE()
297 #define OLP_SDK_LOG_TRACE(tag, message) \
298 OLP_SDK_LOG(::olp::logging::Level::Trace, tag, message)
306 #define OLP_SDK_LOG_DEBUG(tag, message) \
307 OLP_SDK_LOG(::olp::logging::Level::Debug, tag, message)
317 #define OLP_SDK_LOG_INFO(tag, message) \
318 OLP_SDK_LOG(::olp::logging::Level::Info, tag, message)
326 #define OLP_SDK_LOG_WARNING(tag, message) \
327 OLP_SDK_LOG(::olp::logging::Level::Warning, tag, message)
335 #define OLP_SDK_LOG_ERROR(tag, message) \
336 OLP_SDK_LOG(::olp::logging::Level::Error, tag, message)
338 #ifdef OLP_SDK_LOGGING_DISABLED
339 #define OLP_SDK_LOG_F(level, tag, ...) \
342 OLP_SDK_CORE_LOOP_ONCE()
350 #define OLP_SDK_LOG_F(level, tag, ...) \
352 if (::olp::logging::Log::isEnabled(level, tag)) { \
353 OLP_SDK_DO_LOG_F(level, tag, __VA_ARGS__); \
356 OLP_SDK_CORE_LOOP_ONCE()
360 #ifdef LOGGING_DISABLE_DEBUG_LEVEL
361 #define OLP_SDK_LOG_TRACE_F(tag, ...) OLP_SDK_CORE_UNUSED(tag, __VA_ARGS__)
362 #define OLP_SDK_LOG_DEBUG_F(tag, ...) OLP_SDK_CORE_UNUSED(tag, __VA_ARGS__)
369 #define OLP_SDK_LOG_TRACE_F(tag, ...) \
370 OLP_SDK_LOG_F(::olp::logging::Level::Trace, tag, __VA_ARGS__)
377 #define OLP_SDK_LOG_DEBUG_F(tag, ...) \
378 OLP_SDK_LOG_F(::olp::logging::Level::Debug, tag, __VA_ARGS__)
387 #define OLP_SDK_LOG_INFO_F(tag, ...) \
388 OLP_SDK_LOG_F(::olp::logging::Level::Info, tag, __VA_ARGS__)
395 #define OLP_SDK_LOG_WARNING_F(tag, ...) \
396 OLP_SDK_LOG_F(::olp::logging::Level::Warning, tag, __VA_ARGS__)
403 #define OLP_SDK_LOG_ERROR_F(tag, ...) \
404 OLP_SDK_LOG_F(::olp::logging::Level::Error, tag, __VA_ARGS__)
419 template <
typename T>
479 static void setLevel(Level level,
const std::string& tag);
490 static void setLevel(
const std::string& level,
const std::string& tag);
501 static boost::optional<Level>
getLevel(
const std::string& tag);
545 static bool isEnabled(Level level,
const std::string& tag);
563 const std::string& message,
const char* file,
564 unsigned int line,
const char*
function,
565 const char* fullFunction);
Contains utilities used to work around compiler warnings.
Configures appenders and loggers available in the logging system.
Definition: Configuration.h:36
Groups together log levels for different tags.
Definition: FilterGroup.h:40
A primary interface for log messages.
Definition: Log.h:432
static bool isEnabled(Level level)
Checks whether a level is enabled by default.
static void setLevel(Level level, const std::string &tag)
Sets the log level for a tag.
static bool isEnabled(Level level, const std::string &tag)
Checks whether a log tag is enabled for a level.
static bool configure(Configuration configuration)
Configures the log system.
static void setLevel(Level level)
Sets the default log level.
static Level getLevel()
Gets the default log level.
static boost::optional< Level > getLevel(const std::string &tag)
Gets the log level for a tag.
static Configuration getConfiguration()
Gets a copy of the current configuration.
static void clearLevel(const std::string &tag)
Clears the log level for a tag and sets it to the default value.
static void clearLevels()
Clears the log levels for all tags and sets them to the default value.
static void applyFilterGroup(const FilterGroup &filters)
Applies a filter group.
static void logMessage(Level level, const std::string &tag, const std::string &message, const char *file, unsigned int line, const char *function, const char *fullFunction)
Logs a message to the registered appenders.
static void setLevel(const std::string &level, const std::string &tag)
Sets the log level for a tag.
Used for disabled logs at compile time.
Definition: Log.h:417
NullLogStream & operator<<(const T &)
The stream operator to print or serialize the given log stream.
Definition: Log.h:424
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24