mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-17 11:00:07 +00:00
38 lines
911 B
Objective-C
38 lines
911 B
Objective-C
#import "NetworkLogging.h"
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#if TARGET_OS_IOS
|
|
# import <MTProtoKitDynamic/MTLogging.h>
|
|
#else
|
|
# import <MTProtoKitMac/MTLogging.h>
|
|
#endif
|
|
|
|
static void (*bridgingTrace)(NSString *, NSString *);
|
|
void setBridgingTraceFunction(void (*f)(NSString *, NSString *)) {
|
|
bridgingTrace = f;
|
|
}
|
|
|
|
#if TARGET_IPHONE_SIMULATOR
|
|
static bool loggingEnabled = true;
|
|
#elif defined(DEBUG)
|
|
static bool loggingEnabled = true;
|
|
#else
|
|
static bool loggingEnabled = true;
|
|
#endif
|
|
|
|
static void TGTelegramLoggingFunction(NSString *format, va_list args) {
|
|
if (bridgingTrace) {
|
|
bridgingTrace(@"MT", [[NSString alloc] initWithFormat:format arguments:args]);
|
|
}
|
|
}
|
|
|
|
void NetworkRegisterLoggingFunction() {
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
if (loggingEnabled) {
|
|
MTLogSetLoggingFunction(&TGTelegramLoggingFunction);
|
|
}
|
|
});
|
|
}
|