APLogAddions.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // APLogAddions.h
  3. // APRemoteLogging
  4. //
  5. // Created by tashigaofei on 15/10/13.
  6. // Copyright © 2015年 Alipay. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "AntLogInterface.h"
  10. #import "MPLogCryptDelegate.h"
  11. @interface APLogAdditions : NSObject<AntLogInterceptor>
  12. /**
  13. * UUID、UTDID、clientID、deviceModel,language,接入方无须重写,由mPaaS自动获取。
  14. */
  15. @property (nonatomic, strong, readonly) NSString *UUID __deprecated_msg("业务方需要自定义UUID时,请覆盖实现getBrandNewUUID方法."); // 默认实现为调用系统方法获取UUID
  16. @property (nonatomic, strong, readonly) NSString *UTDID; // 默认实现为从APMobileIdentifier获取,如果没有APMobileIdentifier,会反射式调用UTDID库的[UTDevice utdid]方法
  17. @property (nonatomic, strong, readonly) NSString *clientID; // 默认实现为从APMobileIdentifier获取,如果没有APMobileIdentifier,会返回@""
  18. @property (nonatomic, strong) NSString *deviceModel; // 默认实现为从APMobileIdentifier获取,如果没有APMobileIdentifier,会调用系统方法获取设备型号
  19. @property (nonatomic, strong) NSString *language; // 默认实现为读取NSUserDefaults中kAPLanguageSettingKey。如果使用钱包或mPaaS多语言模块,该方法不需要重写
  20. /**
  21. * userID为可选参数,当前登录的用户,接入方在Category中覆盖实现。
  22. */
  23. @property (nonatomic, strong) NSString *userID;
  24. /**
  25. * log日志服务器地址,默认返回@"",需要接入方在Category中覆盖。格式为http://mdap.alipaylog.com/loggw/log.do
  26. */
  27. @property (nonatomic, strong) NSString *logServerURL;
  28. /**
  29. * log日志服务器配置地址,默认返回@"",需要接入方在Category中覆盖。格式为http://mdap.alipaylog.com/loggw/config.do
  30. * 一般只需要重写logServerURL即可,configServerURL系统会自动根据logServerURL进行修改。
  31. */
  32. @property (nonatomic, strong) NSString *configServerURL;
  33. /**
  34. * log日志服务器配置获取间隔,需要接入方在Category中覆盖,默认为600s
  35. */
  36. @property (nonatomic, assign) CFAbsoluteTime configGetInterval;
  37. /**
  38. * 客户端日志产品ID,默认返回[[NSBundle mainBundle] objectForInfoDictionaryKey:@"Product ID"],如果不同需要接入方在Category中覆盖。
  39. */
  40. @property (nonatomic, strong) NSString *platformID;
  41. /**
  42. * 客户端版本号,默认返回[[NSBundle mainBundle] objectForInfoDictionaryKey:@"Product Version"],如果不同需要接入方在Category中覆盖。
  43. */
  44. @property (nonatomic, strong) NSString *clientVersion;
  45. /**
  46. * 本地日志文件大小上限,达到上限时删除历史文件的四分之一. 默认返回 1024*1024*30L (30MB), 如果不同需要接入方在Category中覆盖。
  47. */
  48. @property (nonatomic, assign) NSInteger maximumSizeOfLog;
  49. /**
  50. * 本地日志文件个数上限,达到上限时删除历史文件的四分之一. 默认返回256, 如果不同需要接入方在Category中覆盖。
  51. */
  52. @property (nonatomic, assign) NSInteger maximumNumberOfLogFiles;
  53. /**
  54. 单行日志长度上限,超过上限的日志被丢弃. 默认16K.
  55. */
  56. @property (nonatomic, assign) NSInteger maximumLengthOfLine;
  57. @property (nonatomic, strong) id<MPLogCryptDelegate> logCryptDelegate;
  58. + (instancetype)sharedInstance;
  59. /**
  60. * 默认实现为返回 @[]
  61. * @return @[@(APLogTypeXXX), @(APLogTypeYYY)]数组。数组元素为NSNumber类型
  62. */
  63. - (NSArray*)defaultUploadLogTypes __deprecated_msg("All logs will write & upload without server config now. The return value of this method is ignored.");
  64. /**
  65. * 输出诊断日志到本地日志文件,方便定位问题。
  66. * 该方法默认实现为空,由外部覆盖实现为指定日志方法。
  67. */
  68. - (void)logToFile:(NSString*)logStr;
  69. /**
  70. 生成一个新的UUID.
  71. 每次后台回前台会检查当前UUID的时间戳是否超过了30分钟,若超过了,该方法会被调用.
  72. 默认的实现为调用系统方法生成一个新的UUID: [NSUUID UUID].UUIDString
  73. @return 新的UUID字符串.
  74. */
  75. - (NSString *)getBrandNewUUID;
  76. /**
  77. * 是否存在Interceptor实现. 默认返回NO.
  78. * 接入方需要介入写入/上报时在Category中覆盖该方法返回YES,并覆盖 beforeWrite: 和 beforeUpload: 方法.
  79. * @return 默认返回NO
  80. */
  81. - (BOOL)hasInterceptor;
  82. /**
  83. * 默认实现为空. 接入方需要介入写入时在Category中覆盖该方法.
  84. */
  85. - (void)beforeWrite:(AntLogWriteOperation *)operations;
  86. /**
  87. * 默认实现为空. 接入方需要介入上报时在Category中覆盖该方法.
  88. */
  89. - (void)beforeUpload:(AntLogUploadOperation *)operation;
  90. /**
  91. IDFA值,可选,默认实现返回nil,接入方可在Category里覆盖实现.
  92. */
  93. - (NSString *)idfa;
  94. /**
  95. 获取是否授权 yes代表授权 no代表未授权
  96. */
  97. - (BOOL)privacyAuthed;
  98. /**
  99. 埋点本地加密开关
  100. */
  101. + (void)enableLogEncrypt:(BOOL)enable;
  102. + (BOOL)logEncrypt;
  103. /**
  104. 埋点本地加密算法 Delegate
  105. */
  106. + (void)setLogCryptDelegate:(id<MPLogCryptDelegate>)delegate;
  107. @end