在ipod5上的IOS7中使用Lumberjack,我向DDLog添加了DDASLLogger,并记录了一些内容。并使用“asl_search”来获取日志,但什么也没得到。当我在ios7 iphone模拟器上做到这一点时,我得到了我所记录的内容。这是DDASLLogger的错误吗?
答案 0 :(得分: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);
有效。感谢。