27#include <olp/core/logging/Format.h>
28#include <olp/core/logging/Level.h>
30#include <olp/core/CoreApi.h>
31#include <olp/core/porting/optional.h>
42#ifdef LOGGING_DISABLE_LOCATION
44#define OLP_SDK_LOG_FUNCTION_SIGNATURE ""
45#define OLP_SDK_LOG_FILE ""
46#define OLP_SDK_LOG_LINE 0
47#define OLP_SDK_LOG_FUNCTION ""
51#if __GNUC__ >= 3 || defined(__clang__)
52#define OLP_SDK_LOG_FUNCTION_SIGNATURE __PRETTY_FUNCTION__
53#elif defined(_MSC_VER)
54#define OLP_SDK_LOG_FUNCTION_SIGNATURE __FUNCSIG__
56#define OLP_SDK_LOG_FUNCTION_SIGNATURE __FUNCTION__
59#define OLP_SDK_LOG_FILE __FILE__
60#define OLP_SDK_LOG_LINE __LINE__
61#define OLP_SDK_LOG_FUNCTION __FUNCTION__
75#define OLP_SDK_DO_LOG(level, tag, message) \
77 std::ostringstream __strm; \
79 ::olp::logging::Log::logMessage( \
80 level, tag, __strm.str(), OLP_SDK_LOG_FILE, OLP_SDK_LOG_LINE, \
81 OLP_SDK_LOG_FUNCTION, OLP_SDK_LOG_FUNCTION_SIGNATURE); \
83 OLP_SDK_CORE_LOOP_ONCE()
95#define OLP_SDK_LOG_CRITICAL(level, tag, message) \
96 OLP_SDK_DO_LOG(level, tag, message)
107#define OLP_SDK_LOG_CRITICAL_INFO(tag, message) \
108 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Info, tag, message)
119#define OLP_SDK_LOG_CRITICAL_WARNING(tag, message) \
120 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Warning, tag, message)
131#define OLP_SDK_LOG_CRITICAL_ERROR(tag, message) \
132 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Error, tag, message)
143#define OLP_SDK_LOG_FATAL(tag, message) \
144 OLP_SDK_LOG_CRITICAL(::olp::logging::Level::Fatal, tag, message)
153#define OLP_SDK_LOG_ABORT(tag, message) \
155 OLP_SDK_LOG_FATAL(tag, message); \
158 OLP_SDK_CORE_LOOP_ONCE()
169#define OLP_SDK_DO_LOG_F(level, tag, ...) \
171 std::string __message = ::olp::logging::format(__VA_ARGS__); \
172 ::olp::logging::Log::logMessage(level, tag, __message, OLP_SDK_LOG_FILE, \
173 OLP_SDK_LOG_LINE, OLP_SDK_LOG_FUNCTION, \
174 OLP_SDK_LOG_FUNCTION_SIGNATURE); \
176 OLP_SDK_CORE_LOOP_ONCE()
187#define OLP_SDK_LOG_CRITICAL_F(level, tag, ...) \
188 OLP_SDK_DO_LOG_F(level, tag, __VA_ARGS__)
198#define OLP_SDK_LOG_CRITICAL_INFO_F(tag, ...) \
199 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Info, tag, __VA_ARGS__)
209#define OLP_SDK_LOG_CRITICAL_WARNING_F(tag, ...) \
210 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Warning, tag, __VA_ARGS__)
220#define OLP_SDK_LOG_CRITICAL_ERROR_F(tag, ...) \
221 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Error, tag, __VA_ARGS__)
232#define OLP_SDK_LOG_FATAL_F(tag, ...) \
233 OLP_SDK_LOG_CRITICAL_F(::olp::logging::Level::Fatal, tag, __VA_ARGS__)
241#define OLP_SDK_LOG_ABORT_F(tag, ...) \
243 OLP_SDK_LOG_FATAL_F(tag, __VA_ARGS__); \
246 OLP_SDK_CORE_LOOP_ONCE()
248#ifdef OLP_SDK_LOGGING_DISABLED
249#define OLP_SDK_LOG(level, tag, message) \
252 OLP_SDK_CORE_LOOP_ONCE()
262#define OLP_SDK_LOG(level, tag, message) \
264 if (::olp::logging::Log::isEnabled(level, tag)) { \
265 OLP_SDK_DO_LOG(level, tag, message); \
268 OLP_SDK_CORE_LOOP_ONCE()
272#ifdef LOGGING_DISABLE_DEBUG_LEVEL
273#define OLP_SDK_LOG_TRACE(tag, message) \
275 ::olp::logging::NullLogStream __strm; \
277 OLP_SDK_CORE_UNUSED(tag, __strm); \
279 OLP_SDK_CORE_LOOP_ONCE()
281#define OLP_SDK_LOG_DEBUG(tag, message) \
283 ::olp::logging::NullLogStream __strm; \
285 OLP_SDK_CORE_UNUSED(tag, __strm); \
287 OLP_SDK_CORE_LOOP_ONCE()
296#define OLP_SDK_LOG_TRACE(tag, message) \
297 OLP_SDK_LOG(::olp::logging::Level::Trace, tag, message)
305#define OLP_SDK_LOG_DEBUG(tag, message) \
306 OLP_SDK_LOG(::olp::logging::Level::Debug, tag, message)
316#define OLP_SDK_LOG_INFO(tag, message) \
317 OLP_SDK_LOG(::olp::logging::Level::Info, tag, message)
325#define OLP_SDK_LOG_WARNING(tag, message) \
326 OLP_SDK_LOG(::olp::logging::Level::Warning, tag, message)
334#define OLP_SDK_LOG_ERROR(tag, message) \
335 OLP_SDK_LOG(::olp::logging::Level::Error, tag, message)
337#ifdef OLP_SDK_LOGGING_DISABLED
338#define OLP_SDK_LOG_F(level, tag, ...) \
341 OLP_SDK_CORE_LOOP_ONCE()
349#define OLP_SDK_LOG_F(level, tag, ...) \
351 if (::olp::logging::Log::isEnabled(level, tag)) { \
352 OLP_SDK_DO_LOG_F(level, tag, __VA_ARGS__); \
355 OLP_SDK_CORE_LOOP_ONCE()
359#ifdef LOGGING_DISABLE_DEBUG_LEVEL
360#define OLP_SDK_LOG_TRACE_F(tag, ...) OLP_SDK_CORE_UNUSED(tag, __VA_ARGS__)
361#define OLP_SDK_LOG_DEBUG_F(tag, ...) OLP_SDK_CORE_UNUSED(tag, __VA_ARGS__)
368#define OLP_SDK_LOG_TRACE_F(tag, ...) \
369 OLP_SDK_LOG_F(::olp::logging::Level::Trace, tag, __VA_ARGS__)
376#define OLP_SDK_LOG_DEBUG_F(tag, ...) \
377 OLP_SDK_LOG_F(::olp::logging::Level::Debug, tag, __VA_ARGS__)
386#define OLP_SDK_LOG_INFO_F(tag, ...) \
387 OLP_SDK_LOG_F(::olp::logging::Level::Info, tag, __VA_ARGS__)
394#define OLP_SDK_LOG_WARNING_F(tag, ...) \
395 OLP_SDK_LOG_F(::olp::logging::Level::Warning, tag, __VA_ARGS__)
402#define OLP_SDK_LOG_ERROR_F(tag, ...) \
403 OLP_SDK_LOG_F(::olp::logging::Level::Error, tag, __VA_ARGS__)
418 template <
typename T>
478 static void setLevel(Level level,
const std::string& tag);
489 static void setLevel(
const std::string& level,
const std::string& tag);
500 static porting::optional<Level>
getLevel(
const std::string& tag);
544 static bool isEnabled(Level level,
const std::string& tag);
562 const std::string& message,
const char* file,
563 unsigned int line,
const char* function,
564 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:38
A primary interface for log messages.
Definition Log.h:431
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 void removeCensor(const std::string &message)
Removes a line from censoring out from the log.
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 void addCensor(const std::string &message)
Adds a line to be censored out from the log.
static Configuration getConfiguration()
Gets a copy of the current configuration.
static porting::optional< Level > getLevel(const std::string &tag)
Gets the log level for a tag.
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:416
NullLogStream & operator<<(const T &)
The stream operator to print or serialize the given log stream.
Definition Log.h:423
Rules all the other namespaces.
Definition AppleSignInProperties.h:24