2013-11-27 60 views

回答

2

我終於找到答案了:是的。這是一個記錄到「asl_search only finds messages with ReadUID set」的錯誤。發送給ASL時,我們需要爲消息設置ReadUID屬性。否則,asl_search無法找到它。

在DDASLLogger發送消息的代碼如下:

- (void)logMessage:(DDLogMessage *)logMessage 
{ 
    NSString *logMsg = logMessage->logMsg; 

    if (formatter) 
    { 
     logMsg = [formatter formatLogMessage:logMessage]; 
    } 

    if (logMsg) 
    { 
     const char *msg = [logMsg UTF8String]; 

     int aslLogLevel; 
     switch (logMessage->logFlag) 
     { 
      // Note: By default ASL will filter anything above level 5 (Notice). 
      // So our mappings shouldn't go above that level. 

      case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_ALERT; break; 
      case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_CRIT; break; 
      case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_ERR;  break; 
      case LOG_FLAG_DEBUG : aslLogLevel = ASL_LEVEL_WARNING; break; 
      default    : aslLogLevel = ASL_LEVEL_NOTICE; break; 
     } 

     asl_log(client, NULL, aslLogLevel, "%s", msg); 
    } 
} 

我們只需要改變

 asl_log(client, NULL, aslLogLevel, "%s", msg); 

 aslmsg m = asl_new(ASL_TYPE_MSG); 
     asl_set(m, ASL_KEY_READ_UID, "501"); 
     asl_log(client, m, aslLogLevel, "%s", msg); 

它的工作原理。謝謝。

+0

偉大的答案和問題仍然發生在iOS 7.1。更糟的是,ASL_KEY_READ_UID似乎完全沒有記錄。 –

+0

上週我在github上做了一個pull請求。所以最新版本沒有這個問題。 – Andrew