Skip to content

Commit

Permalink
Add RELEASE_LOG_DEBUG macros.
Browse files Browse the repository at this point in the history
https://webkit.org/b/260395

Reviewed by Darin Adler.

* Source/WTF/wtf/Assertions.h: Added RELEASE_LOG_DEBUG and RELEASE_LOG_DEBUG_IF for debug
logging that does not persist to storage.

Canonical link: https://commits.webkit.org/267058@main
  • Loading branch information
xeenon committed Aug 18, 2023
1 parent ee34378 commit de03252
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/WTF/wtf/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,12 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
#define RELEASE_LOG_ERROR(channel, ...) LOG_ERROR(__VA_ARGS__)
#define RELEASE_LOG_FAULT(channel, ...) LOG_ERROR(__VA_ARGS__)
#define RELEASE_LOG_INFO(channel, ...) ((void)0)
#define RELEASE_LOG_DEBUG(channel, ...) ((void)0)

#define RELEASE_LOG_IF(isAllowed, channel, ...) ((void)0)
#define RELEASE_LOG_ERROR_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, __VA_ARGS__); } while (0)
#define RELEASE_LOG_INFO_IF(isAllowed, channel, ...) ((void)0)
#define RELEASE_LOG_DEBUG_IF(isAllowed, channel, ...) ((void)0)

#define RELEASE_LOG_WITH_LEVEL(channel, level, ...) ((void)0)
#define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, level, ...) do { if (isAllowed) RELEASE_LOG_WITH_LEVEL(channel, level, __VA_ARGS__); } while (0)
Expand All @@ -581,6 +583,7 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
#define RELEASE_LOG_ERROR(channel, ...) os_log_error(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
#define RELEASE_LOG_FAULT(channel, ...) os_log_fault(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
#define RELEASE_LOG_INFO(channel, ...) os_log_info(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
#define RELEASE_LOG_DEBUG(channel, ...) os_log_debug(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
if (LOG_CHANNEL(channel).level >= (logLevel)) \
os_log(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__); \
Expand All @@ -607,6 +610,7 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
#define RELEASE_LOG_ERROR(channel, ...) SD_JOURNAL_SEND(channel, LOG_ERR, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
#define RELEASE_LOG_FAULT(channel, ...) SD_JOURNAL_SEND(channel, LOG_CRIT, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
#define RELEASE_LOG_INFO(channel, ...) SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
#define RELEASE_LOG_DEBUG(channel, ...) SD_JOURNAL_SEND(channel, LOG_DEBUG, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)

#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
if (LOG_CHANNEL(channel).level >= (logLevel)) \
Expand All @@ -633,6 +637,7 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
#define RELEASE_LOG_ERROR(channel, ...) LOGF(channel, 1, __VA_ARGS__)
#define RELEASE_LOG_FAULT(channel, ...) LOGF(channel, 2, __VA_ARGS__)
#define RELEASE_LOG_INFO(channel, ...) LOGF(channel, 3, __VA_ARGS__)
#define RELEASE_LOG_DEBUG(channel, ...) LOGF(channel, 4, __VA_ARGS__)

#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
if (LOG_CHANNEL(channel).level >= (logLevel)) \
Expand All @@ -651,6 +656,7 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
#define RELEASE_LOG_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG(channel, __VA_ARGS__); } while (0)
#define RELEASE_LOG_ERROR_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, __VA_ARGS__); } while (0)
#define RELEASE_LOG_INFO_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_INFO(channel, __VA_ARGS__); } while (0)
#define RELEASE_LOG_DEBUG_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_DEBUG(channel, __VA_ARGS__); } while (0)

#define RELEASE_LOG_STACKTRACE(channel) WTFReleaseLogStackTrace(&LOG_CHANNEL(channel))
#endif
Expand Down

0 comments on commit de03252

Please sign in to comment.