From d81dea1d84eff5d78683e04843b2b7b3a8d20f25 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 27 Aug 2018 11:11:01 -0400 Subject: [PATCH] Add OWS log macros. --- SignalServiceKit/src/Util/OWSLogger.h | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/SignalServiceKit/src/Util/OWSLogger.h b/SignalServiceKit/src/Util/OWSLogger.h index a8e79e399..0b49607b6 100644 --- a/SignalServiceKit/src/Util/OWSLogger.h +++ b/SignalServiceKit/src/Util/OWSLogger.h @@ -44,4 +44,35 @@ static inline BOOL ShouldLogError() @end +#define OWSLogPrefix() \ + ([NSString stringWithFormat:@"[%@:%d %s]: ", \ + [[NSString stringWithUTF8String:__FILE__] lastPathComponent], \ + __LINE__, \ + __PRETTY_FUNCTION__]) + +#define OWSLogVerbose(_messageFormat, ...) \ + do { \ + DDLogVerbose(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ + } while (0) + +#define OWSLogDebug(_messageFormat, ...) \ + do { \ + DDLogDebug(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ + } while (0) + +#define OWSLogInfo(_messageFormat, ...) \ + do { \ + DDLogInfo(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ + } while (0) + +#define OWSLogWarn(_messageFormat, ...) \ + do { \ + DDLogWarn(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ + } while (0) + +#define OWSLogError(_messageFormat, ...) \ + do { \ + DDLogError(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ + } while (0) + NS_ASSUME_NONNULL_END