iOS: Move AppRTC logging methods to public headers.
BUG=
Review URL: https://codereview.webrtc.org/1241283004
Cr-Commit-Position: refs/heads/master@{#9629}
diff --git a/talk/examples/objc/AppRTCDemo/ARDAppClient.m b/talk/examples/objc/AppRTCDemo/ARDAppClient.m
index 5b905c6..e043da2 100644
--- a/talk/examples/objc/AppRTCDemo/ARDAppClient.m
+++ b/talk/examples/objc/AppRTCDemo/ARDAppClient.m
@@ -32,17 +32,16 @@
#endif
#import "RTCFileLogger.h"
#import "RTCICEServer.h"
+#import "RTCLogging.h"
#import "RTCMediaConstraints.h"
#import "RTCMediaStream.h"
#import "RTCPair.h"
#import "RTCPeerConnectionInterface.h"
#import "RTCVideoCapturer.h"
-#import "RTCAVFoundationVideoSource.h"
#import "ARDAppEngineClient.h"
#import "ARDCEODTURNClient.h"
#import "ARDJoinResponse.h"
-#import "ARDLogging.h"
#import "ARDMessageResponse.h"
#import "ARDSDPUtils.h"
#import "ARDSignalingMessage.h"
@@ -162,7 +161,8 @@
[_turnClient requestServersWithCompletionHandler:^(NSArray *turnServers,
NSError *error) {
if (error) {
- ARDLog("Error retrieving TURN servers: %@", error.localizedDescription);
+ RTCLogError("Error retrieving TURN servers: %@",
+ error.localizedDescription);
}
ARDAppClient *strongSelf = weakSelf;
[strongSelf.iceServers addObjectsFromArray:turnServers];
@@ -181,12 +181,12 @@
NSError *joinError =
[[strongSelf class] errorForJoinResultType:response.result];
if (joinError) {
- ARDLog(@"Failed to join room:%@ on room server.", roomId);
+ RTCLogError(@"Failed to join room:%@ on room server.", roomId);
[strongSelf disconnect];
[strongSelf.delegate appClient:strongSelf didError:joinError];
return;
}
- ARDLog(@"Joined room:%@ on room server.", roomId);
+ RTCLog(@"Joined room:%@ on room server.", roomId);
strongSelf.roomId = response.roomId;
strongSelf.clientId = response.clientId;
strongSelf.isInitiator = response.isInitiator;
@@ -278,13 +278,13 @@
- (void)peerConnection:(RTCPeerConnection *)peerConnection
signalingStateChanged:(RTCSignalingState)stateChanged {
- ARDLog(@"Signaling state changed: %d", stateChanged);
+ RTCLog(@"Signaling state changed: %d", stateChanged);
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
addedStream:(RTCMediaStream *)stream {
dispatch_async(dispatch_get_main_queue(), ^{
- ARDLog(@"Received %lu video tracks and %lu audio tracks",
+ RTCLog(@"Received %lu video tracks and %lu audio tracks",
(unsigned long)stream.videoTracks.count,
(unsigned long)stream.audioTracks.count);
if (stream.videoTracks.count) {
@@ -296,17 +296,17 @@
- (void)peerConnection:(RTCPeerConnection *)peerConnection
removedStream:(RTCMediaStream *)stream {
- ARDLog(@"Stream was removed.");
+ RTCLog(@"Stream was removed.");
}
- (void)peerConnectionOnRenegotiationNeeded:
(RTCPeerConnection *)peerConnection {
- ARDLog(@"WARNING: Renegotiation needed but unimplemented.");
+ RTCLog(@"WARNING: Renegotiation needed but unimplemented.");
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
iceConnectionChanged:(RTCICEConnectionState)newState {
- ARDLog(@"ICE state changed: %d", newState);
+ RTCLog(@"ICE state changed: %d", newState);
dispatch_async(dispatch_get_main_queue(), ^{
[_delegate appClient:self didChangeConnectionState:newState];
});
@@ -314,7 +314,7 @@
- (void)peerConnection:(RTCPeerConnection *)peerConnection
iceGatheringChanged:(RTCICEGatheringState)newState {
- ARDLog(@"ICE gathering state changed: %d", newState);
+ RTCLog(@"ICE gathering state changed: %d", newState);
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
@@ -339,7 +339,7 @@
error:(NSError *)error {
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
- ARDLog(@"Failed to create session description. Error: %@", error);
+ RTCLogError(@"Failed to create session description. Error: %@", error);
[self disconnect];
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: @"Failed to create session description.",
@@ -368,7 +368,7 @@
didSetSessionDescriptionWithError:(NSError *)error {
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
- ARDLog(@"Failed to set session description. Error: %@", error);
+ RTCLogError(@"Failed to set session description. Error: %@", error);
[self disconnect];
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: @"Failed to set session description.",
diff --git a/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m b/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m
index 0b33325..de3f9f7 100644
--- a/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m
+++ b/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m
@@ -27,8 +27,9 @@
#import "ARDAppEngineClient.h"
+#import "RTCLogging.h"
+
#import "ARDJoinResponse.h"
-#import "ARDLogging.h"
#import "ARDMessageResponse.h"
#import "ARDSignalingMessage.h"
#import "ARDUtilities.h"
@@ -58,7 +59,7 @@
NSString *urlString =
[NSString stringWithFormat:kARDRoomServerJoinFormat, roomId];
NSURL *roomURL = [NSURL URLWithString:urlString];
- ARDLog(@"Joining room:%@ on room server.", roomId);
+ RTCLog(@"Joining room:%@ on room server.", roomId);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
request.HTTPMethod = @"POST";
__weak ARDAppEngineClient *weakSelf = self;
@@ -102,7 +103,7 @@
[NSString stringWithFormat:
kARDRoomServerMessageFormat, roomId, clientId];
NSURL *url = [NSURL URLWithString:urlString];
- ARDLog(@"C->RS POST: %@", message);
+ RTCLog(@"C->RS POST: %@", message);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
request.HTTPBody = data;
@@ -148,19 +149,19 @@
NSError *error = nil;
// We want a synchronous request so that we know that we've left the room on
// room server before we do any further work.
- ARDLog(@"C->RS: BYE");
+ RTCLog(@"C->RS: BYE");
[NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
if (error) {
- ARDLog(@"Error leaving room %@ on room server: %@",
+ RTCLogError(@"Error leaving room %@ on room server: %@",
roomId, error.localizedDescription);
if (completionHandler) {
completionHandler(error);
}
return;
}
- ARDLog(@"Left room:%@ on room server.", roomId);
+ RTCLog(@"Left room:%@ on room server.", roomId);
if (completionHandler) {
completionHandler(nil);
}
diff --git a/talk/examples/objc/AppRTCDemo/ARDSDPUtils.m b/talk/examples/objc/AppRTCDemo/ARDSDPUtils.m
index 481b6ce..25e8d4e 100644
--- a/talk/examples/objc/AppRTCDemo/ARDSDPUtils.m
+++ b/talk/examples/objc/AppRTCDemo/ARDSDPUtils.m
@@ -27,7 +27,7 @@
#import "ARDSDPUtils.h"
-#import "ARDLogging.h"
+#import "RTCLogging.h"
#import "RTCSessionDescription.h"
@implementation ARDSDPUtils
@@ -71,11 +71,11 @@
}
}
if (mLineIndex == -1) {
- ARDLog(@"No m=video line, so can't prefer %@", codec);
+ RTCLog(@"No m=video line, so can't prefer %@", codec);
return description;
}
if (!codecRtpMap) {
- ARDLog(@"No rtpmap for %@", codec);
+ RTCLog(@"No rtpmap for %@", codec);
return description;
}
NSArray *origMLineParts =
@@ -99,7 +99,7 @@
[lines replaceObjectAtIndex:mLineIndex
withObject:newMLine];
} else {
- ARDLog(@"Wrong SDP media description format: %@", lines[mLineIndex]);
+ RTCLogWarning(@"Wrong SDP media description format: %@", lines[mLineIndex]);
}
NSString *mangledSdpString = [lines componentsJoinedByString:lineSeparator];
return [[RTCSessionDescription alloc] initWithType:description.type
diff --git a/talk/examples/objc/AppRTCDemo/ARDSignalingMessage.m b/talk/examples/objc/AppRTCDemo/ARDSignalingMessage.m
index dc00e8f..4d49a2e 100644
--- a/talk/examples/objc/AppRTCDemo/ARDSignalingMessage.m
+++ b/talk/examples/objc/AppRTCDemo/ARDSignalingMessage.m
@@ -27,7 +27,8 @@
#import "ARDSignalingMessage.h"
-#import "ARDLogging.h"
+#import "RTCLogging.h"
+
#import "ARDUtilities.h"
#import "RTCICECandidate+JSON.h"
#import "RTCSessionDescription+JSON.h"
@@ -53,7 +54,7 @@
+ (ARDSignalingMessage *)messageFromJSONString:(NSString *)jsonString {
NSDictionary *values = [NSDictionary dictionaryWithJSONString:jsonString];
if (!values) {
- ARDLog(@"Error parsing signaling message JSON.");
+ RTCLogError(@"Error parsing signaling message JSON.");
return nil;
}
@@ -72,7 +73,7 @@
} else if ([typeString isEqualToString:@"bye"]) {
message = [[ARDByeMessage alloc] init];
} else {
- ARDLog(@"Unexpected type: %@", typeString);
+ RTCLogError(@"Unexpected type: %@", typeString);
}
return message;
}
diff --git a/talk/examples/objc/AppRTCDemo/ARDWebSocketChannel.m b/talk/examples/objc/AppRTCDemo/ARDWebSocketChannel.m
index f25e9d0..a089ff8 100644
--- a/talk/examples/objc/AppRTCDemo/ARDWebSocketChannel.m
+++ b/talk/examples/objc/AppRTCDemo/ARDWebSocketChannel.m
@@ -27,10 +27,11 @@
#import "ARDWebSocketChannel.h"
-#import "ARDLogging.h"
-#import "ARDUtilities.h"
+#import "RTCLogging.h"
#import "SRWebSocket.h"
+#import "ARDUtilities.h"
+
// TODO(tkchin): move these to a configuration object.
static NSString const *kARDWSSMessageErrorKey = @"error";
static NSString const *kARDWSSMessagePayloadKey = @"msg";
@@ -58,7 +59,7 @@
_delegate = delegate;
_socket = [[SRWebSocket alloc] initWithURL:url];
_socket.delegate = self;
- ARDLog(@"Opening WebSocket.");
+ RTCLog(@"Opening WebSocket.");
[_socket open];
}
return self;
@@ -105,12 +106,12 @@
NSString *messageString =
[[NSString alloc] initWithData:messageJSONObject
encoding:NSUTF8StringEncoding];
- ARDLog(@"C->WSS: %@", messageString);
+ RTCLog(@"C->WSS: %@", messageString);
[_socket send:messageString];
} else {
NSString *dataString =
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
- ARDLog(@"C->WSS POST: %@", dataString);
+ RTCLog(@"C->WSS POST: %@", dataString);
NSString *urlString =
[NSString stringWithFormat:@"%@/%@/%@",
[_restURL absoluteString], _roomId, _clientId];
@@ -127,7 +128,7 @@
return;
}
[_socket close];
- ARDLog(@"C->WSS DELETE rid:%@ cid:%@", _roomId, _clientId);
+ RTCLog(@"C->WSS DELETE rid:%@ cid:%@", _roomId, _clientId);
NSString *urlString =
[NSString stringWithFormat:@"%@/%@/%@",
[_restURL absoluteString], _roomId, _clientId];
@@ -141,7 +142,7 @@
#pragma mark - SRWebSocketDelegate
- (void)webSocketDidOpen:(SRWebSocket *)webSocket {
- ARDLog(@"WebSocket connection opened.");
+ RTCLog(@"WebSocket connection opened.");
self.state = kARDSignalingChannelStateOpen;
if (_roomId.length && _clientId.length) {
[self registerWithCollider];
@@ -155,24 +156,24 @@
options:0
error:nil];
if (![jsonObject isKindOfClass:[NSDictionary class]]) {
- ARDLog(@"Unexpected message: %@", jsonObject);
+ RTCLogError(@"Unexpected message: %@", jsonObject);
return;
}
NSDictionary *wssMessage = jsonObject;
NSString *errorString = wssMessage[kARDWSSMessageErrorKey];
if (errorString.length) {
- ARDLog(@"WSS error: %@", errorString);
+ RTCLogError(@"WSS error: %@", errorString);
return;
}
NSString *payload = wssMessage[kARDWSSMessagePayloadKey];
ARDSignalingMessage *signalingMessage =
[ARDSignalingMessage messageFromJSONString:payload];
- ARDLog(@"WSS->C: %@", payload);
+ RTCLog(@"WSS->C: %@", payload);
[_delegate channel:self didReceiveMessage:signalingMessage];
}
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error {
- ARDLog(@"WebSocket error: %@", error);
+ RTCLogError(@"WebSocket error: %@", error);
self.state = kARDSignalingChannelStateError;
}
@@ -180,7 +181,7 @@
didCloseWithCode:(NSInteger)code
reason:(NSString *)reason
wasClean:(BOOL)wasClean {
- ARDLog(@"WebSocket closed with code: %ld reason:%@ wasClean:%d",
+ RTCLog(@"WebSocket closed with code: %ld reason:%@ wasClean:%d",
(long)code, reason, wasClean);
NSParameterAssert(_state != kARDSignalingChannelStateError);
self.state = kARDSignalingChannelStateClosed;
@@ -205,7 +206,7 @@
error:nil];
NSString *messageString =
[[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding];
- ARDLog(@"Registering on WSS for rid:%@ cid:%@", _roomId, _clientId);
+ RTCLog(@"Registering on WSS for rid:%@ cid:%@", _roomId, _clientId);
// Registration can fail if server rejects it. For example, if the room is
// full.
[_socket send:messageString];
diff --git a/talk/examples/objc/AppRTCDemo/RTCICECandidate+JSON.m b/talk/examples/objc/AppRTCDemo/RTCICECandidate+JSON.m
index 01d666d..f7bb211 100644
--- a/talk/examples/objc/AppRTCDemo/RTCICECandidate+JSON.m
+++ b/talk/examples/objc/AppRTCDemo/RTCICECandidate+JSON.m
@@ -27,7 +27,7 @@
#import "RTCICECandidate+JSON.h"
-#import "ARDLogging.h"
+#import "RTCLogging.h"
static NSString const *kRTCICECandidateTypeKey = @"type";
static NSString const *kRTCICECandidateTypeValue = @"candidate";
@@ -58,7 +58,7 @@
options:NSJSONWritingPrettyPrinted
error:&error];
if (error) {
- ARDLog(@"Error serializing JSON: %@", error);
+ RTCLogError(@"Error serializing JSON: %@", error);
return nil;
}
return data;
diff --git a/talk/examples/objc/AppRTCDemo/common/ARDLogging.h b/talk/examples/objc/AppRTCDemo/common/ARDLogging.h
deleted file mode 100644
index dfb31d8..0000000
--- a/talk/examples/objc/AppRTCDemo/common/ARDLogging.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * libjingle
- * Copyright 2015 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-// We route all logging through the WebRTC logger. By doing this we will get
-// both app and WebRTC logs in the same place, which we can then route to a
-// file if we need to. A side effect of this is that we get severity for free.
-typedef NS_ENUM(NSInteger, ARDLogSeverity) {
- kARDLogSeverityVerbose,
- kARDLogSeverityInfo,
- kARDLogSeverityWarning,
- kARDLogSeverityError,
-};
-
-#if defined(__cplusplus)
-extern "C" void ARDLogToWebRTCLogger(ARDLogSeverity severity,
- NSString *logString);
-extern "C" NSString *ARDFileName(const char *filePath);
-extern "C" void ARDLogInit();
-#else
-// Logs |logString| to the WebRTC logger at the given severity.
-extern void ARDLogToWebRTCLogger(ARDLogSeverity severity, NSString *logString);
-// Returns the filename with the path prefix removed.
-extern NSString *ARDFileName(const char *filePath);
-// Initializes the correct logging levels. This should be called once on app
-// startup.
-extern void ARDLogInit();
-#endif
-
-#define ARDLogString(format, ...) \
- [NSString stringWithFormat:@"(%@:%d %s): " format, \
- ARDFileName(__FILE__), \
- __LINE__, \
- __FUNCTION__, \
- ##__VA_ARGS__]
-
-#define ARDLogEx(severity, format, ...) \
- do { \
- NSString *logString = ARDLogString(format, ##__VA_ARGS__); \
- ARDLogToWebRTCLogger(severity, logString); \
- } while (false)
-
-#define ARDLogVerbose(format, ...) \
- ARDLogEx(kARDLogSeverityVerbose, format, ##__VA_ARGS__) \
-
-#define ARDLogInfo(format, ...) \
- ARDLogEx(kARDLogSeverityInfo, format, ##__VA_ARGS__) \
-
-#define ARDLogWarning(format, ...) \
- ARDLogEx(kARDLogSeverityWarning, format, ##__VA_ARGS__) \
-
-#define ARDLogError(format, ...) \
- ARDLogEx(kARDLogSeverityError, format, ##__VA_ARGS__) \
-
-#ifdef _DEBUG
-#define ARDLogDebug(format, ...) ARDLogInfo(format, ##__VA_ARGS__)
-#else
-#define ARDLogDebug(format, ...) \
- do { \
- } while (false)
-#endif
-
-#define ARDLog(format, ...) ARDLogInfo(format, ##__VA_ARGS__)
diff --git a/talk/examples/objc/AppRTCDemo/common/ARDLogging.mm b/talk/examples/objc/AppRTCDemo/common/ARDLogging.mm
deleted file mode 100644
index 7bd773d..0000000
--- a/talk/examples/objc/AppRTCDemo/common/ARDLogging.mm
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * libjingle
- * Copyright 2015 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "ARDLogging.h"
-
-#include "webrtc/base/logging.h"
-
-void ARDLogInit() {
-#ifndef _DEBUG
- // In debug builds the default level is LS_INFO and in non-debug builds it is
- // disabled. Continue to log to console in non-debug builds, but only
- // warnings and errors.
- rtc::LogMessage::LogToDebug(rtc::LS_WARNING);
-#endif
-}
-
-void ARDLogToWebRTCLogger(ARDLogSeverity severity, NSString *logString) {
- if (logString.length) {
- const char* utf8String = logString.UTF8String;
- switch (severity) {
- case kARDLogSeverityVerbose:
- LOG(LS_VERBOSE) << utf8String;
- break;
- case kARDLogSeverityInfo:
- LOG(LS_INFO) << utf8String;
- break;
- case kARDLogSeverityWarning:
- LOG(LS_WARNING) << utf8String;
- break;
- case kARDLogSeverityError:
- LOG(LS_ERROR) << utf8String;
- break;
- }
- }
-}
-
-NSString *ARDFileName(const char *filePath) {
- NSString *nsFilePath =
- [[NSString alloc] initWithBytesNoCopy:const_cast<char *>(filePath)
- length:strlen(filePath)
- encoding:NSUTF8StringEncoding
- freeWhenDone:NO];
- return nsFilePath.lastPathComponent;
-}
diff --git a/talk/examples/objc/AppRTCDemo/common/ARDUtilities.m b/talk/examples/objc/AppRTCDemo/common/ARDUtilities.m
index 066ee02..39010da 100644
--- a/talk/examples/objc/AppRTCDemo/common/ARDUtilities.m
+++ b/talk/examples/objc/AppRTCDemo/common/ARDUtilities.m
@@ -25,9 +25,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import "ARDLogging.h"
#import "ARDUtilities.h"
+#import "RTCLogging.h"
+
@implementation NSDictionary (ARDUtilites)
+ (NSDictionary *)dictionaryWithJSONString:(NSString *)jsonString {
@@ -37,7 +38,7 @@
NSDictionary *dict =
[NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if (error) {
- ARDLog(@"Error parsing JSON: %@", error.localizedDescription);
+ RTCLogError(@"Error parsing JSON: %@", error.localizedDescription);
}
return dict;
}
@@ -47,7 +48,7 @@
NSDictionary *dict =
[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
if (error) {
- ARDLog(@"Error parsing JSON: %@", error.localizedDescription);
+ RTCLogError(@"Error parsing JSON: %@", error.localizedDescription);
}
return dict;
}
@@ -85,7 +86,7 @@
NSData *data,
NSError *error) {
if (error) {
- ARDLog(@"Error posting data: %@", error.localizedDescription);
+ RTCLogError(@"Error posting data: %@", error.localizedDescription);
if (completionHandler) {
completionHandler(NO, data);
}
@@ -96,7 +97,7 @@
NSString *serverResponse = data.length > 0 ?
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] :
nil;
- ARDLog(@"Received bad response: %@", serverResponse);
+ RTCLogError(@"Received bad response: %@", serverResponse);
if (completionHandler) {
completionHandler(NO, data);
}
diff --git a/talk/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m b/talk/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m
index 352ade6..09e4374 100644
--- a/talk/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m
+++ b/talk/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m
@@ -27,10 +27,11 @@
#import "ARDAppDelegate.h"
-#import "ARDLogging.h"
-#import "ARDMainViewController.h"
+#import "RTCLogging.h"
#import "RTCPeerConnectionFactory.h"
+#import "ARDMainViewController.h"
+
@implementation ARDAppDelegate {
UIWindow *_window;
}
@@ -44,7 +45,14 @@
[_window makeKeyAndVisible];
ARDMainViewController *viewController = [[ARDMainViewController alloc] init];
_window.rootViewController = viewController;
- ARDLogInit();
+
+#ifndef _DEBUG
+ // In debug builds the default level is LS_INFO and in non-debug builds it is
+ // disabled. Continue to log to console in non-debug builds, but only
+ // warnings and errors.
+ RTCSetMinDebugLogLevel(kRTCLoggingSeverityWarning);
+#endif
+
return YES;
}
diff --git a/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m b/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m
index 149beef..d919d75 100644
--- a/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m
+++ b/talk/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m
@@ -28,9 +28,9 @@
#import "ARDVideoCallViewController.h"
#import "RTCAVFoundationVideoSource.h"
+#import "RTCLogging.h"
#import "ARDAppClient.h"
-#import "ARDLogging.h"
#import "ARDVideoCallView.h"
@interface ARDVideoCallViewController () <ARDAppClientDelegate,
@@ -70,13 +70,13 @@
didChangeState:(ARDAppClientState)state {
switch (state) {
case kARDAppClientStateConnected:
- ARDLog(@"Client connected.");
+ RTCLog(@"Client connected.");
break;
case kARDAppClientStateConnecting:
- ARDLog(@"Client connecting.");
+ RTCLog(@"Client connecting.");
break;
case kARDAppClientStateDisconnected:
- ARDLog(@"Client disconnected.");
+ RTCLog(@"Client disconnected.");
[self hangup];
break;
}
@@ -84,7 +84,7 @@
- (void)appClient:(ARDAppClient *)client
didChangeConnectionState:(RTCICEConnectionState)state {
- ARDLog(@"ICE state changed: %d", state);
+ RTCLog(@"ICE state changed: %d", state);
__weak ARDVideoCallViewController *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
ARDVideoCallViewController *strongSelf = weakSelf;