Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent bc23e38efc
commit e1049fdfcc

@ -623,7 +623,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
// Range instead of indexSet since it's contiguous? // Range instead of indexSet since it's contiguous?
var fetchedIndexSet = IndexSet() { var fetchedIndexSet = IndexSet() {
didSet { didSet {
Logger.debug("\(oldValue) -> \(fetchedIndexSet)") Logger.debug("\(oldValue) -> \(self.fetchedIndexSet)")
} }
} }

@ -146,7 +146,7 @@ private class SignalCallData: NSObject {
didSet { didSet {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.debug(".peerConnectionClient setter: \(oldValue != nil) -> \(peerConnectionClient != nil) \(String(describing: peerConnectionClient))") Logger.debug(".peerConnectionClient setter: \(oldValue != nil) -> \(self.peerConnectionClient != nil) \(String(describing: self.peerConnectionClient))")
} }
} }
@ -253,7 +253,7 @@ private class SignalCallData: NSObject {
} }
} }
Logger.debug(".callData setter: \(oldValue?.call.identifiersForLogs as Optional) -> \(callData?.call.identifiersForLogs as Optional)") Logger.debug(".callData setter: \(oldValue?.call.identifiersForLogs as Optional) -> \(self.callData?.call.identifiersForLogs as Optional)")
for observer in observers { for observer in observers {
observer.value?.didUpdateCall(call: callData?.call) observer.value?.didUpdateCall(call: callData?.call)

@ -121,7 +121,7 @@ protocol CallObserver: class {
var audioSource: AudioSource? = nil { var audioSource: AudioSource? = nil {
didSet { didSet {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.debug("audioSource changed: \(String(describing: oldValue)) -> \(String(describing: audioSource))") Logger.debug("audioSource changed: \(String(describing: oldValue)) -> \(String(describing: self.audioSource))")
for observer in observers { for observer in observers {
observer.value?.audioSourceDidChange(call: self, audioSource: audioSource) observer.value?.audioSourceDidChange(call: self, audioSource: audioSource)

@ -82,7 +82,7 @@ extension GiphyError: LocalizedError {
} }
public func log() { public func log() {
Logger.verbose("\t \(format), \(name), \(width), \(height), \(fileSize)") Logger.verbose("\t \(self.format), \(self.name), \(self.width), \(self.height), \(self.fileSize)")
} }
} }
@ -114,7 +114,7 @@ extension GiphyError: LocalizedError {
} }
public func log() { public func log() {
Logger.verbose("giphyId: \(giphyId), \(renditions.count)") Logger.verbose("giphyId: \(self.giphyId), \(self.renditions.count)")
for rendition in renditions { for rendition in renditions {
rendition.log() rendition.log()
} }

@ -28,13 +28,13 @@ public class DisappearingTimerConfigurationView: UIView {
override public var frame: CGRect { override public var frame: CGRect {
didSet { didSet {
Logger.verbose("\(oldValue) -> \(frame)") Logger.verbose("\(oldValue) -> \(self.frame)")
} }
} }
override public var bounds: CGRect { override public var bounds: CGRect {
didSet { didSet {
Logger.verbose("\(oldValue) -> \(bounds)") Logger.verbose("\(oldValue) -> \(self.bounds)")
} }
} }

@ -160,7 +160,7 @@ public class SignalAttachment: NSObject {
AssertIsOnMainThread() AssertIsOnMainThread()
assert(oldValue == nil) assert(oldValue == nil)
Logger.verbose("Attachment has error: \(String(describing: error))") Logger.verbose("Attachment has error: \(String(describing: self.error))")
} }
} }

@ -142,7 +142,7 @@ public class OWSAudioSession: NSObject {
} }
guard currentActivities.isEmpty else { guard currentActivities.isEmpty else {
Logger.debug("not deactivating due to currentActivities: \(currentActivities)") Logger.debug("not deactivating due to currentActivities: \(self.currentActivities)")
return return
} }

@ -4,16 +4,18 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef NSString * (^OWSLogBlock)(void);
/** /**
* A minimal DDLog wrapper for swift. * A minimal DDLog wrapper for swift.
*/ */
@interface OWSLogger : NSObject @interface OWSLogger : NSObject
+ (void)verbose:(NSString *)logString; + (void)verbose:(OWSLogBlock)logBlock;
+ (void)debug:(NSString *)logString; + (void)debug:(OWSLogBlock)logBlock;
+ (void)info:(NSString *)logString; + (void)info:(OWSLogBlock)logBlock;
+ (void)warn:(NSString *)logString; + (void)warn:(OWSLogBlock)logBlock;
+ (void)error:(NSString *)logString; + (void)error:(OWSLogBlock)logBlock;
+ (void)flush; + (void)flush;
@end @end

@ -8,29 +8,29 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSLogger @implementation OWSLogger
+ (void)verbose:(NSString *)logString + (void)verbose:(OWSLogBlock)logBlock;
{ {
DDLogVerbose(@"%@", logString); DDLogVerbose(@"%@", logBlock());
} }
+ (void)debug:(NSString *)logString + (void)debug:(OWSLogBlock)logBlock;
{ {
DDLogDebug(@"%@", logString); DDLogDebug(@"%@", logBlock());
} }
+ (void)info:(NSString *)logString + (void)info:(OWSLogBlock)logBlock;
{ {
DDLogInfo(@"%@", logString); DDLogInfo(@"%@", logBlock());
} }
+ (void)warn:(NSString *)logString + (void)warn:(OWSLogBlock)logBlock;
{ {
DDLogWarn(@"%@", logString); DDLogWarn(@"%@", logBlock());
} }
+ (void)error:(NSString *)logString + (void)error:(OWSLogBlock)logBlock;
{ {
DDLogError(@"%@", logString); DDLogError(@"%@", logBlock());
} }
+ (void)flush + (void)flush

@ -21,23 +21,25 @@ public func owsFormatLogMessage(_ logString: String,
*/ */
open class Logger: NSObject { open class Logger: NSObject {
open class func verbose(_ logString: @autoclosure () -> String, open class func verbose(_ logString: @escaping @autoclosure () -> String,
file: String = #file, file: String = #file,
function: String = #function, function: String = #function,
line: Int = #line) { line: Int = #line) {
#if DEBUG #if DEBUG
let message = owsFormatLogMessage(logString(), file: file, function: function, line: line) OWSLogger.verbose({
OWSLogger.verbose(message) return owsFormatLogMessage(logString(), file: file, function: function, line: line)
})
#endif #endif
} }
open class func debug(_ logString: @autoclosure () -> String, open class func debug(_ logString: @escaping @autoclosure () -> String,
file: String = #file, file: String = #file,
function: String = #function, function: String = #function,
line: Int = #line) { line: Int = #line) {
#if DEBUG #if DEBUG
let message = owsFormatLogMessage(logString(), file: file, function: function, line: line) OWSLogger.debug({
OWSLogger.debug(message) return owsFormatLogMessage(logString(), file: file, function: function, line: line)
})
#endif #endif
} }
@ -45,24 +47,27 @@ open class Logger: NSObject {
file: String = #file, file: String = #file,
function: String = #function, function: String = #function,
line: Int = #line) { line: Int = #line) {
let message = owsFormatLogMessage(logString, file: file, function: function, line: line) OWSLogger.info({
OWSLogger.info(message) return owsFormatLogMessage(logString, file: file, function: function, line: line)
})
} }
open class func warn(_ logString: String, open class func warn(_ logString: String,
file: String = #file, file: String = #file,
function: String = #function, function: String = #function,
line: Int = #line) { line: Int = #line) {
let message = owsFormatLogMessage(logString, file: file, function: function, line: line) OWSLogger.warn({
OWSLogger.warn(message) return owsFormatLogMessage(logString, file: file, function: function, line: line)
})
} }
open class func error(_ logString: String, open class func error(_ logString: String,
file: String = #file, file: String = #file,
function: String = #function, function: String = #function,
line: Int = #line) { line: Int = #line) {
let message = owsFormatLogMessage(logString, file: file, function: function, line: line) OWSLogger.error({
OWSLogger.error(message) return owsFormatLogMessage(logString, file: file, function: function, line: line)
})
} }
open class func flush() { open class func flush() {

Loading…
Cancel
Save