Skip to content

Commit

Permalink
Allow logging statements to be conditionally compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyRyabinin committed Mar 15, 2024
1 parent e9d0d24 commit 966c094
Showing 1 changed file with 79 additions and 12 deletions.
91 changes: 79 additions & 12 deletions src/aws-cpp-sdk-core/include/aws/core/utils/logging/LogMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,49 @@
} \
}

#define AWS_LOG_FATAL(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Fatal, tag, __VA_ARGS__)
#define AWS_LOG_ERROR(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Error, tag, __VA_ARGS__)
#define AWS_LOG_WARN(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Warn, tag, __VA_ARGS__)
#define AWS_LOG_INFO(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Info, tag, __VA_ARGS__)
#define AWS_LOG_DEBUG(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Debug, tag, __VA_ARGS__)
#define AWS_LOG_TRACE(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Trace, tag, __VA_ARGS__)
#define AWS_SDK_LOG_LEVEL_NONE 0
#define AWS_SDK_LOG_LEVEL_FATAL 1
#define AWS_SDK_LOG_LEVEL_ERROR 2
#define AWS_SDK_LOG_LEVEL_WARN 3
#define AWS_SDK_LOG_LEVEL_INFO 4
#define AWS_SDK_LOG_LEVEL_DEBUG 5
#define AWS_SDK_LOG_LEVEL_TRACE 6

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_FATAL)
#define AWS_LOG_FATAL(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Fatal, tag, __VA_ARGS__)
#else
#define AWS_LOG_FATAL(tag, ...)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_ERROR)
#define AWS_LOG_ERROR(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Error, tag, __VA_ARGS__)
#else
#define AWS_LOG_ERROR(tag, ...)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_WARN)
#define AWS_LOG_WARN(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Warn, tag, __VA_ARGS__)
#else
#define AWS_LOG_WARN(tag, ...)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_INFO)
#define AWS_LOG_INFO(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Info, tag, __VA_ARGS__)
#else
#define AWS_LOG_INFO(tag, ...)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_DEBUG)
#define AWS_LOG_DEBUG(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Debug, tag, __VA_ARGS__)
#else
#define AWS_LOG_DEBUG(tag, ...)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_TRACE)
#define AWS_LOG_TRACE(tag, ...) AWS_LOG(Aws::Utils::Logging::LogLevel::Trace, tag, __VA_ARGS__)
#else
#define AWS_LOG_TRACE(tag, ...)
#endif

#define AWS_LOGSTREAM(level, tag, streamExpression) \
{ \
Expand All @@ -76,12 +113,42 @@
} \
}

#define AWS_LOGSTREAM_FATAL(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Fatal, tag, streamExpression)
#define AWS_LOGSTREAM_ERROR(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Error, tag, streamExpression)
#define AWS_LOGSTREAM_WARN(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Warn, tag, streamExpression)
#define AWS_LOGSTREAM_INFO(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Info, tag, streamExpression)
#define AWS_LOGSTREAM_DEBUG(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Debug, tag, streamExpression)
#define AWS_LOGSTREAM_TRACE(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Trace, tag, streamExpression)
#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_FATAL)
#define AWS_LOGSTREAM_FATAL(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Fatal, tag, streamExpression)
#else
#define AWS_LOGSTREAM_FATAL(tag, streamExpression)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_ERROR)
#define AWS_LOGSTREAM_ERROR(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Error, tag, streamExpression)
#else
#define AWS_LOGSTREAM_ERROR(tag, streamExpression)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_WARN)
#define AWS_LOGSTREAM_WARN(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Warn, tag, streamExpression)
#else
#define AWS_LOGSTREAM_WARN(tag, streamExpression)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_INFO)
#define AWS_LOGSTREAM_INFO(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Info, tag, streamExpression)
#else
#define AWS_LOGSTREAM_INFO(tag, streamExpression)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_DEBUG)
#define AWS_LOGSTREAM_DEBUG(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Debug, tag, streamExpression)
#else
#define AWS_LOGSTREAM_DEBUG(tag, streamExpression)
#endif

#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_SDK_LOG_LEVEL_TRACE)
#define AWS_LOGSTREAM_TRACE(tag, streamExpression) AWS_LOGSTREAM(Aws::Utils::Logging::LogLevel::Trace, tag, streamExpression)
#else
#define AWS_LOGSTREAM_TRACE(tag, streamExpression)
#endif

#define AWS_LOGSTREAM_FLUSH() AWS_LOG_FLUSH()

#endif // DISABLE_AWS_LOGGING

0 comments on commit 966c094

Please sign in to comment.