Index: webrtc/examples/objc/AppRTCDemo/common/ARDLogging.mm |
diff --git a/webrtc/examples/objc/AppRTCDemo/common/ARDLogging.mm b/webrtc/examples/objc/AppRTCDemo/common/ARDLogging.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3fd147c39a56988c03b2fae00fd68963739849c3 |
--- /dev/null |
+++ b/webrtc/examples/objc/AppRTCDemo/common/ARDLogging.mm |
@@ -0,0 +1,51 @@ |
+/* |
+ * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#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; |
+} |