iOS開源:GodEye - iOS監控編程
使用基于Swift的一行代碼自動顯示日志,崩潰,網絡,ANR,泄漏,CPU,RAM,FPS,NetFlow,文件夾等。 就像上帝打開他的眼睛。
為了盡量復用代碼,這個項目中的某些組件之間有比較強的依賴關系。為了方便其他開發者使用,我從中拆分出以下獨立組件:
- Log4G — Simple, lightweight logging framework written in Swift.
- AssistiveButton — Simple Assistive Button.
- AppBaseKit — A handy kit of Swift extensions and wrapped class to boost your productivity.
- AppSwizzle — lightweight and flexible method swizzling wrapped by swift.
- LeakEye — LeakEye is a memory leak monitor.
- NetworkEye — NetworkEye is a network monitor,automatic catch the request and response infomation of all kinds of request send.
- ANREye — ANREye is an ANR (Application Not Responding) monitor,automatic catch the ANR and return stacktrace of all threads.
- ASLEye — ASLEye is an ASL(Apple System Log) monitor, automatic catch the log from NSLog by asl module.
- CrashEye — CrashEye is an ios crash monitor,automatic catch exception crash & signal crash and return the stacktrace.
- SystemEye — SystemEye is a system monitor,automatic catch the infomation of cpu,memory....etc.
功能
- 監控日志并區分日志類型.
- 監控崩潰, 包括Uncatched Exception和Signal崩潰.
- 監控網絡, 包括請求和響應的所有信息.
- 監控卡頓, 并告訴你卡頓時候的所有線程的堆棧.
- 監控內存泄露, 告訴你泄露的對象的類名.
- 提供一個可以自定義指令和輸出的控制臺.
- 監控系統和應用自身的CPU使用率.
- 監控系統與應用自身的內存使用率.
- 監控幀率FPS.
- 監控系統和應用自身的網絡流量.
- 提供一個文件瀏覽器可用于查看沙盒,.app 以及系統根目錄的文件.
- 運行時自定義設置
特點
- 豐富: 功能全面
- 方便: 一行代碼接入
- 自動: 零代碼入侵
- 安全: Release包可不打入一行代碼
預覽
安裝
GodEye目前可以通過 CocoaPods來安裝.只需要將下面的代碼加入到你的Podfile中即可:
pod "GodEye"
在使用GodEye的開源App
CocoaChinaPlus是一款用Swift編寫的開源的CocoaChina第三方客戶端,目前已經接入GodEye,并且可以很好的工作。
使用
在AppDelegate
中用下面的代碼導入進來:
import GodEye
然后在 application:didFinishLaunchingWithOptions
初始化GodEye:
GodEye.makeEye(with:self.window!)
當然,一行代碼接入是一種默認配置的接入,讀者也可以通過傳入自己的Configuration
來精細化配置各個細節:
let configuration = Configuration() configuration.command.add(command: "test", description: "test command") { () -> (String) in return "this is test command result" } configuration.command.add(command: "info", description: "print test info") { () -> (String) in return "info" } GodEye.makeEye(with: self.window!, configuration: configuration)
上面的示例是自定義命令的配置,我們也可以自定義control
和switch
的配置,詳細的配置項可以看ControlConfiguration
和 SwitchConfiguration
兩個類。
示例
clone這個庫,在Example目錄下運行pod install
就可以跑工程自帶的示例工程了。
開源協議
GodEye開源在 MIT 協議下,詳細請查看 LICENSE 文件。
本文由用戶 liuruirui 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!