GHConsole
中文版本请参看这里
一种简单且无线的获取您已记录并希望在应用中查看的内容的方法。
GHConsole/Swift
安装
简单地将 GHConsole 文件夹中的文件添加到您的项目中,或者使用 CocoaPods。
CocoaPods
您可以使用 CocoaPods 通过将其添加到您的 Podfile
来安装 GHConsole
platform :ios, '7.0'
use_frameworks!
#you need to update your CocoaPods version if you can't find this pod.
target 'your_project_name' do
pod 'GHConsole'
end
使用示例
只需在您的应用中启动 GHConsole。GHConsole 视图将以查看的形式添加到主窗口上方。
您可以在此处找到示例项目:这里
在 GHConsole 上启动日志
当您的应用启动时,只需在 appDelegate.m 中初始化 GHConsole。Objective-C 使用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[GHConsole sharedConsole]startPrintLog];
return YES;
}
Swift 使用
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
GHConsole.sharedConsole.startPrintLog()
return true
}
然后,您可以使用 GGLog(),就像 NSLog() 一样
Objective-C 使用
GGLog(@"This is some log I just want to show in GHConsole");
NSDictionary *parameterDict = @{@"paraKey1":@"paraValue1",
@"paraKey2":@"paraValue2",
@"paraKey3":@"paraValue2"
}
GGLog(@"%@",parametersDict);
//if you want to see the responsJSon from the API, you can just use GGLog( ) like NSLog( ) here.
GGLog(@"%@",responsJSON);
Swift 使用
GGLog("This is a log I just want to show in GHConsole")
let parameterDict = ["paraKey1":"paraValue1","paraKey2":"paraValue2","paraKey3":"paraValue3"] as [String:Any]
GGLog("\(parameterDict)")
//if you want to see the responsJSon from the API, you can just use GGLog( ) like NSLog( ) here.
GGLog("if you want to see the responsJSon from the API, you can just use GGLog( ) like NSLog( ) here!")
在您的应用中双击 GHConsole,然后它的外观就像这样。
停止日志
完成 GHConsole 后,请调用它。
Objective-C 使用
[GHConsole shareConsole]stop];
Swift 使用
GHConsole.sharedConsole.stopPrinting()
如果您不想看到 GHConsole,只需对其进行注释即可。
//[[GHConsole sharedConsole]startPrintLog];
性能
GHConsole 基于一刀 C 中的 printf。比 NSLog 有更好的性能。
打印字符串 10000 次的耗时
测试环境:iPhone 6
系统版本:iOS 11.2.5
时间单位:毫秒
功能
-
GHConsole 在您的应用中的位置不显眼。在 GHConsole 中添加了多个手势。双击可使其全屏并恢复。
-
此框架只包含两个文件
GHConsole.h
GHConsole.m
-
易于使用和卸载。
-
您可以在 GHConslole 清楚地看到 GGLog() 的行号和 函数名。
-
GHConsole 上的 清除按钮 可以删除一些无用的日志。
-
保存按钮 和 加载按钮 可以保存日志,并读取已保存的日志。这便于检查您应用中的问题。
-
在 发布模式 下,控制台将不再输出任何日志。
-
完全 线程安全。
配置
抱歉,GHConsole的配置太简单了。如果您有任何好的想法或需求,可以告诉我或在我的github或邮箱中留言。
需求
- iOS 7.0+
贡献者名单
周少文 - https://github.com/zhoushaowen
Kane - https://github.com/KaneLanF
元信息
GHConsole采用MIT许可协议。有关更多信息,请参阅LICENSE文件。