我正在使用iOS中的xmppframework处理聊天应用。该框架包含打印xml发送和接收日志的示例演示。现在我在我的应用程序中实现相同的东西,但没有显示日志。
示例应用程序的日志示例
2014-05-08 16:34:15:993 iPhoneXMPP[4839:1403] SEND: <?xml version='1.0'?>
2014-05-08 16:34:15:994 iPhoneXMPP[4839:1403] SEND: <stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='meinantrieb.net'>
2014-05-08 16:34:16:384 iPhoneXMPP[4839:3503] RECV: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="1364620848" from="meinantrieb.net" version="1.0" stream1:lang="en"/>
2014-05-08 16:34:16:384 iPhoneXMPP[4839:3503] RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>SCRAM-SHA-1</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="GgBjinftMQ4H81m+4jSVXMg/dVU="/><register xmlns="http://jabber.org/features/iq-register"/></stream:features>
在AppDelegate.m中添加日志的代码
#import "DDLog.h" #import "DDTTYLogger.h" // Log levels: off, error, warn, info, verbose #if DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_INFO; #endif
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Configure logging framework
[DDLog addLogger:[DDTTYLogger sharedInstance]];
}
任何帮助或建议都将受到赞赏。
答案 0 :(得分:2)
使用此行替换配置日志框架的代码
[DDLog addLogger:[DDTTYLogger sharedInstance] withLogLevel:XMPP_LOG_FLAG_SEND_RECV]
它是从XMPPFramework
的演示代码中复制的答案 1 :(得分:1)
使用Swift 3.x时,DDLog
日志级别是一个枚举,因此无法立即应用XMPPFramework日志级别。
可以启用所有日志消息:
DDLog.add(DDTTYLogger.sharedInstance, with: .all)