通过cocoapods安装的XMPPFramework没有日志输出

3

如果我有所疏漏,抱歉,但我没有收到任何日志输出。

我从Cocoapods安装了XMPPFramework。

以下是我安装框架和设置Xcode(版本5.0.2)的步骤。

1.Podfile:

platform :ios, '7.0'
pod 'XMPPFramework', '~> 3.6.3'

2. Pod 安装

Output:

Analyzing dependencies
Downloading dependencies
Installing CocoaAsyncSocket (7.3.2)
Installing CocoaLumberjack (1.6.5.1)
Installing XMPPFramework (3.6.3)
Generating Pods project
Integrating client project

[!] From now on use `XMPPFramworkTemplate.xcworkspace`.
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.

3.AppDelegate.h

#import <DDLog.h>
#import <DDTTYLogger.h>
#import <DDASLLogger.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.

        [DDLog addLogger:[DDASLLogger sharedInstance]];
        [DDLog addLogger:[DDTTYLogger sharedInstance]];
          return YES;
    }

4.ViewController.m

#import <XMPPFramework.h>
#import <DDLog.h>
#import <DDTTYLogger.h>
#import <DDASLLogger.h>

static const int ddLogLevel = LOG_LEVEL_VERBOSE;

@interface ViewController ()
@property (strong, nonatomic) XMPPStream *xmppStream;
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    //This works....
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

    //Testing
    [[self xmppStream] setMyJID:[ XMPPJID jidWithString:@"hidden@hidden.com"]];

    //Testing
    NSError *error = nil;
    [[self xmppStream] connectWithTimeout:XMPPStreamTimeoutNone error:&error];
}

...

5.控制台输出:

2013-12-07 12:54:46:449 XMPPFramworkTemplate[43458:70b] ViewController: viewDidLoad

所以日志功能在ViewController内可以正常工作,但似乎没有从XMPPFramework输出任何内容。

看起来XMPPLogSend没有触发。我在sendOpeningNegotiation中加了一个断点,所以我期望会有一个输出

NSString *s1 = @"<?xml version='1.0'?>";

NSData *outgoingData = [s1 dataUsingEncoding:NSUTF8StringEncoding];

XMPPLogSend(@"SEND: %@", s1);
numberOfBytesSent += [outgoingData length];
.....

提醒一下,我对Objective-C/Xcode等技术非常陌生,如果有什么显而易见的问题,请告诉我。

有什么想法吗?

谢谢大家。

1个回答

1

此处在Github上提到的,您可以使用以下方法为宏XMPPLogSend重新启用日志记录。

#if DEBUG
    const int ddLogLevel = (LOG_LEVEL_VERBOSE | XMPP_LOG_FLAG_SEND);
#else
    const int ddLogLevel = LOG_LEVEL_INFO;
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [DDLog addLogger:[DDTTYLogger sharedInstance] withLogLevel:ddLogLevel];

    return YES;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接