TDSLog.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // TDSLog.h
  3. // TDSCommon
  4. //
  5. // Created by Insomnia on 2020/10/26.
  6. //
  7. #import <Foundation/Foundation.h>
  8. NS_ASSUME_NONNULL_BEGIN
  9. #ifndef TDSLogInfo
  10. #define TDSLogInfo(model, format, ...) TDSLogInfoFunc(model, [NSString stringWithFormat:format, ## __VA_ARGS__], __PRETTY_FUNCTION__)
  11. #endif
  12. #ifndef TDSLogCustom
  13. #define TDSLogCustom(model, tag, format, ...) TDSLogCustomFunc(model, tag, [NSString stringWithFormat:format, ## __VA_ARGS__], __PRETTY_FUNCTION__)
  14. #endif
  15. #ifndef TDSLogCrash
  16. #define TDSLogCrash(model, format, ...) TDSLogCustomFunc(model, @"Crash", [NSString stringWithFormat:format, ## __VA_ARGS__], __PRETTY_FUNCTION__)
  17. #endif
  18. @interface TDSLogModel : NSObject
  19. @property (nonatomic, copy, nonnull) NSString *sdkName;
  20. @property (nonatomic, copy, nonnull) NSString *sdkCode;
  21. @property (nonatomic, copy, nonnull) NSString *sdkVersion;
  22. @end
  23. @protocol TDSLogDelegate <NSObject>
  24. @optional
  25. - (void)reciveLogWithModel:(TDSLogModel * _Nullable)model tag:(NSString * _Nullable)tag content:(id)content;
  26. @end
  27. @interface TDSLog : NSObject
  28. @property (nonatomic, weak) id<TDSLogDelegate> delegate;
  29. + (instancetype)sharedInstance;
  30. - (void)tdsLogWithModel:(TDSLogModel * _Nonnull)model tag:(NSString *)tag content:(NSString *)content;
  31. @end
  32. /** 记录Info标签日志 */
  33. FOUNDATION_EXPORT void TDSLogInfoFunc(TDSLogModel* _Nonnull model, NSString* _Nonnull log, const char * func);
  34. /** 记录自定义标签日志 */
  35. FOUNDATION_EXPORT void TDSLogCustomFunc(TDSLogModel* _Nonnull model, NSString *_Nonnull tag, NSString* _Nonnull log,const char * func);
  36. NS_ASSUME_NONNULL_END