@@ -47,22 +47,24 @@ typedef NS_ERROR_ENUM(ETCoreMLErrorDomain, ETCoreMLError) {
4747#pragma clang diagnostic push
4848#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
4949
50- #if ET_LOG_ENABLED
51- #define ETCoreMLLogError (error, formatString, ...) \
52- ET_LOG (Error, \
53- " %s " , \
54- [NSString stringWithFormat: @" [Core ML] " formatString " %@" , ##__VA_ARGS__, error.localizedDescription] \
55- .UTF8String);
50+ #if ET_LOG_ENABLED
51+ #define ETCoreMLLogError (error, formatString, ...) \
52+ do { \
53+ NSString *message = error.localizedDescription ; \
54+ message = [NSString stringWithFormat: @" [Core ML] " formatString " %@" , ##__VA_ARGS__, message]; \
55+ ET_LOG (Error, " %s " , message.UTF8String ); \
56+ } while (0 ) \
5657#else
57- #define ETCoreMLLogError (error, formatString, ...) \
58+ #define ETCoreMLLogError (error, formatString, ...) \
5859 os_log_error (ETCoreMLErrorUtils.loggingChannel, formatString " %@" , ##__VA_ARGS__, error.localizedDescription);
5960#endif
6061
6162#if ET_LOG_ENABLED
62- #define ETCoreMLLogInfo (formatString, ...) \
63+ #define ETCoreMLLogInfo (formatString, ...) \
6364 ET_LOG (Info, " %s " , [NSString stringWithFormat: formatString, ##__VA_ARGS__].UTF8String);
6465#else
65- #define ETCoreMLLogInfo (formatString, ...) os_log_info(ETCoreMLErrorUtils.loggingChannel, formatString, ##__VA_ARGS__);
66+ #define ETCoreMLLogInfo (formatString, ...) \
67+ os_log_info (ETCoreMLErrorUtils.loggingChannel, formatString, ##__VA_ARGS__);
6668#endif
6769
6870// / Record the error with `os_log_error` and fills `*errorOut` with `NSError`.
@@ -79,11 +81,14 @@ typedef NS_ERROR_ENUM(ETCoreMLErrorDomain, ETCoreMLError) {
7981
8082// / Record the error and its underlying error with `os_log_error` and fills `*errorOut` with `NSError`.
8183#define ETCoreMLLogUnderlyingErrorAndSetNSError (errorOut, errorCode, underlyingNSError, formatString, ...) \
82- ETCoreMLLogError (underlyingNSError, formatString, ##__VA_ARGS__) if (errorOut) { \
83- *errorOut = [ETCoreMLErrorUtils errorWithCode: errorCode \
84- underlyingError: underlyingNSError \
85- format: @formatString, ##__VA_ARGS__]; \
86- }
84+ do { \
85+ ETCoreMLLogError (underlyingNSError, formatString, ##__VA_ARGS__); \
86+ if (errorOut) { \
87+ *errorOut = [ETCoreMLErrorUtils errorWithCode: errorCode \
88+ underlyingError: underlyingNSError \
89+ format: @formatString, ##__VA_ARGS__]; \
90+ } \
91+ } while (0 ) \
8792
8893
8994#pragma clang diagnostic pop
0 commit comments