Skip to content
This repository was archived by the owner on Jun 13, 2019. It is now read-only.

Commit 0fbc937

Browse files
committed
Merge remote-tracking branch 'remirobert/master'
2 parents 1803462 + c6ad964 commit 0fbc937

24 files changed

+298
-31
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
## Build generated
66
build/
77
DerivedData/
8+
*.DS_Store
9+
.idea
810

911
## Various settings
1012
*.pbxuser

Dotzu.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Dotzu'
3-
s.version = '0.9'
3+
s.version = '1.7'
44
s.license = 'MIT'
55
s.summary = 'iOS debugger tool for iOS developer. Display logs, network request, device informations, crash logs while using the app.'
66
s.homepage = 'https://github.com/remirobert/Dotzu'

Dotzu.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
BB2040721E4E5A9E0022E8D6 /* RequestDataHttpBodyTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2040701E4E5A9E0022E8D6 /* RequestDataHttpBodyTableViewCell.xib */; };
7878
BB67A0AE1E4B2914008EABE9 /* RequestLatencyTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB67A0AC1E4B2914008EABE9 /* RequestLatencyTableViewCell.swift */; };
7979
BB67A0AF1E4B2914008EABE9 /* RequestLatencyTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB67A0AD1E4B2914008EABE9 /* RequestLatencyTableViewCell.xib */; };
80+
BBD93F201E7D4B1C00EF9026 /* LogGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD93F1F1E7D4B1C00EF9026 /* LogGenerator.swift */; };
8081
/* End PBXBuildFile section */
8182

8283
/* Begin PBXContainerItemProxy section */
@@ -163,6 +164,7 @@
163164
BB2040701E4E5A9E0022E8D6 /* RequestDataHttpBodyTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RequestDataHttpBodyTableViewCell.xib; sourceTree = "<group>"; };
164165
BB67A0AC1E4B2914008EABE9 /* RequestLatencyTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestLatencyTableViewCell.swift; sourceTree = "<group>"; };
165166
BB67A0AD1E4B2914008EABE9 /* RequestLatencyTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RequestLatencyTableViewCell.xib; sourceTree = "<group>"; };
167+
BBD93F1F1E7D4B1C00EF9026 /* LogGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogGenerator.swift; sourceTree = "<group>"; };
166168
/* End PBXFileReference section */
167169

168170
/* Begin PBXFrameworksBuildPhase section */
@@ -291,6 +293,7 @@
291293
children = (
292294
BB1B40A01E429B6100DF4E57 /* LogProtocol.swift */,
293295
BB1B40901E429B6100DF4E57 /* LogCellProtocol.swift */,
296+
BBD93F1F1E7D4B1C00EF9026 /* LogGenerator.swift */,
294297
);
295298
name = Protocols;
296299
sourceTree = "<group>";
@@ -525,6 +528,7 @@
525528
BB1B40BE1E429B6200DF4E57 /* CrashListTableViewCell.swift in Sources */,
526529
BB1B40C41E429B6200DF4E57 /* DeviceModel.swift in Sources */,
527530
BB1B40E81E429B6200DF4E57 /* ManagerListLogViewController.swift in Sources */,
531+
BBD93F201E7D4B1C00EF9026 /* LogGenerator.swift in Sources */,
528532
BB1B40CB1E429B6200DF4E57 /* Log.swift in Sources */,
529533
BB1B40F11E429B6200DF4E57 /* ResponseDataTableViewCell.swift in Sources */,
530534
BB1B40CA1E429B6200DF4E57 /* ListLogViewModel.swift in Sources */,

Dotzu/Application.storyboard

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="OYf-mT-x66">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="OYf-mT-x66">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
7-
<deployment identifier="iOS"/>
87
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
98
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
109
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -140,7 +139,7 @@
140139
<rect key="frame" x="8" y="8" width="359" height="27"/>
141140
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
142141
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
143-
<fontDescription key="fontDescription" type="system" pointSize="11"/>
142+
<fontDescription key="fontDescription" type="system" pointSize="8"/>
144143
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
145144
</textView>
146145
</subviews>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"filename" : "scrollDown.png",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
Loading

Dotzu/DotzuManager.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import UIKit
1010

11-
public class Dotzu {
11+
public class Dotzu: NSObject {
1212
public static let sharedManager = Dotzu()
1313
private var window: ManagerWindow
1414
fileprivate let controller = ManagerViewController()
@@ -23,23 +23,32 @@ public class Dotzu {
2323
}
2424
}
2525

26-
public func displayWindow() {
26+
public func enable() {
2727
initLogsManager()
2828
self.window.rootViewController = self.controller
2929
self.window.makeKeyAndVisible()
3030
self.window.delegate = self
31-
if LogsSettings.shared.network {
32-
LoggerNetwork.register()
33-
}
34-
LoggerCrash.register()
31+
LoggerNetwork.shared.enable = LogsSettings.shared.network
32+
Logger.shared.enable = true
33+
LoggerCrash.shared.enable = true
34+
}
35+
36+
public func disable() {
37+
self.window.rootViewController = nil
38+
self.window.resignKey()
39+
self.window.removeFromSuperview()
40+
Logger.shared.enable = false
41+
LoggerCrash.shared.enable = false
42+
LoggerNetwork.shared.enable = false
3543
}
3644

3745
public func addLogger(session: URLSessionConfiguration) {
3846
session.protocolClasses?.insert(LoggerNetwork.self, at: 0)
3947
}
4048

41-
init() {
49+
override init() {
4250
self.window = ManagerWindow(frame: UIScreen.main.bounds)
51+
super.init()
4352
}
4453
}
4554

Dotzu/LogGenerator.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// LogGenerator.swift
3+
// Dotzu
4+
//
5+
// Created by Remi Robert on 18/03/2017.
6+
// Copyright © 2017 Remi Robert. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
protocol LogGenerator: class {
12+
var enable: Bool {get set}
13+
}

Dotzu/LogLevel.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ extension LogLevel {
3434
}
3535
}
3636

37+
var logColorConsole: String {
38+
switch self {
39+
case .verbose: return "◽️"
40+
case .info: return "🔷"
41+
case .warning: return "⚠️"
42+
case .error: return ""
43+
}
44+
}
45+
3746
var color: UIColor {
3847
return LogLevel.colorFor(type: self)
3948
}

Dotzu/Logger.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@
99
import Foundation
1010

1111
public func print(_ items: Any...) {
12-
if LogsSettings.shared.overridePrint {
12+
if LogsSettings.shared.overridePrint && Logger.shared.enable {
1313
Logger.handleLog(items, level: .verbose, file: nil, function: nil, line: nil)
1414
} else {
1515
Swift.print(items.first ?? "")
1616
}
1717
}
1818

19-
public class Logger {
19+
public class Logger: LogGenerator {
2020

2121
static let shared = Logger()
2222
private let store = StoreManager<Log>(store: .log)
2323
private let queue = DispatchQueue(label: "logprint.log.queue")
2424

25+
var enable: Bool = true
26+
2527
public static func verbose(_ items: Any..., file: String = #file, function: String = #function, line: Int = #line) {
2628
handleLog(items, level: .verbose, file: file, function: function, line: line)
2729
}
@@ -45,6 +47,9 @@ public class Logger {
4547
}
4648

4749
fileprivate static func handleLog(_ items: Any..., level: LogLevel, file: String?, function: String?, line: Int?) {
50+
if !Logger.shared.enable {
51+
return
52+
}
4853
let fileInfo = parseFileInfo(file: file, function: function, line: line)
4954
let stringContent = (items.first as? [Any] ?? []).reduce("") { result, next -> String in
5055
return "\(result)\(result.characters.count > 0 ? " " : "")\(next)"

Dotzu/LoggerCrash.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,26 @@ func handleSignal(signal: Int32) {
3737
LoggerCrash.addCrash(name: "SIGSYS", reason: nil)
3838
case SIGPIPE:
3939
LoggerCrash.addCrash(name: "SIGPIPE", reason: nil)
40+
case SIGTRAP:
41+
LoggerCrash.addCrash(name: "SIGTRAP", reason: nil)
4042
default: break
4143
}
4244
}
4345

44-
class LoggerCrash {
46+
class LoggerCrash: LogGenerator {
4547

4648
static let shared = LoggerCrash()
4749
var crashed = false
50+
var enable: Bool = true {
51+
didSet {
52+
if enable {
53+
LoggerCrash.register()
54+
}
55+
else {
56+
LoggerCrash.unregister()
57+
}
58+
}
59+
}
4860

4961
static func register() {
5062
NSSetUncaughtExceptionHandler(exceptionHandler)
@@ -55,6 +67,7 @@ class LoggerCrash {
5567
signal(SIGSEGV, handleSignal)
5668
signal(SIGSYS, handleSignal)
5769
signal(SIGPIPE, handleSignal)
70+
signal(SIGTRAP, handleSignal)
5871
}
5972

6073
static func unregister() {
@@ -66,6 +79,7 @@ class LoggerCrash {
6679
signal(SIGSEGV, SIG_DFL)
6780
signal(SIGSYS, SIG_DFL)
6881
signal(SIGPIPE, SIG_DFL)
82+
signal(SIGTRAP, SIG_DFL)
6983
}
7084

7185
static func addCrash(name: String, reason: String?) {

Dotzu/LoggerFormat.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class LoggerFormat {
2222
var lenghtDate: Int?
2323
let stringContent = NSMutableString()
2424

25+
stringContent.append("\(log.level.logColorConsole) ")
2526
if let date = log.date, LogsSettings.shared.date {
2627
stringContent.append("[\(formatDate(date: date))] ")
2728
lenghtDate = stringContent.length

Dotzu/LoggerNetwork.swift

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ extension NSMutableURLRequest {
1919
}
2020

2121
@objc func httpBodyHackSetHttpBody(body: NSData?) {
22+
defer {
23+
httpBodyHackSetHttpBody(body: body)
24+
}
2225
let keyRequest = "\(hashValue)"
2326
guard let body = body, bodyValues[keyRequest] == nil else { return }
2427
bodyValues[keyRequest] = body as Data
25-
httpBodyHackSetHttpBody(body: body)
2628
}
2729
}
2830

29-
class LoggerNetwork: URLProtocol {
31+
class LoggerNetwork: URLProtocol, LogGenerator {
3032

3133
var connection: NSURLConnection?
3234
var sessionTask: URLSessionTask?
@@ -36,6 +38,16 @@ class LoggerNetwork: URLProtocol {
3638
var currentLog: LogRequest?
3739
let store = StoreManager<LogRequest>(store: .network)
3840

41+
var enable: Bool = true {
42+
didSet {
43+
if enable {
44+
LoggerNetwork.register()
45+
} else {
46+
LoggerNetwork.unregister()
47+
}
48+
}
49+
}
50+
3951
static let shared = LoggerNetwork()
4052

4153
lazy var queue: OperationQueue = {
@@ -49,15 +61,17 @@ class LoggerNetwork: URLProtocol {
4961

5062
open class func register() {
5163
NSMutableURLRequest.httpBodyHackSwizzle()
52-
URLProtocol.registerClass(self)
64+
URLProtocol.registerClass(LoggerNetwork.classForCoder())
5365
}
5466

5567
open class func unregister() {
56-
URLProtocol.unregisterClass(self)
68+
URLProtocol.unregisterClass(LoggerNetwork.classForCoder())
5769
}
5870

5971
open override class func canInit(with request: URLRequest) -> Bool {
60-
if !LogsSettings.shared.network && self.property(forKey: "MyURLProtocolHandledKey", in: request) != nil {
72+
if !LogsSettings.shared.network ||
73+
!LoggerNetwork.shared.enable ||
74+
self.property(forKey: "MyURLProtocolHandledKey", in: request) != nil {
6175
return false
6276
}
6377
return true

Dotzu/Logs.storyboard

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
7-
<deployment identifier="iOS"/>
87
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
98
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
109
<capability name="Navigation items with more than one left or right bar item" minToolsVersion="7.0"/>
@@ -84,7 +83,7 @@
8483
<rect key="frame" x="0.0" y="20" width="375" height="603"/>
8584
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
8685
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
87-
<fontDescription key="fontDescription" type="system" pointSize="14"/>
86+
<fontDescription key="fontDescription" type="system" pointSize="13"/>
8887
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
8988
<dataDetectorType key="dataDetectorTypes" link="YES"/>
9089
</textView>
@@ -134,6 +133,18 @@
134133
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
135134
<nil key="highlightedColor"/>
136135
</label>
136+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zMK-tr-ShO">
137+
<rect key="frame" x="309" y="533" width="50" height="50"/>
138+
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
139+
<constraints>
140+
<constraint firstAttribute="width" constant="50" id="JTp-4e-c51"/>
141+
<constraint firstAttribute="height" constant="50" id="Qdv-kv-CNH"/>
142+
</constraints>
143+
<state key="normal" image="scroll-down"/>
144+
<connections>
145+
<action selector="scrollDown:" destination="fto-va-uFc" eventType="touchUpInside" id="LuV-CK-jlS"/>
146+
</connections>
147+
</button>
137148
</subviews>
138149
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
139150
<constraints>
@@ -143,6 +154,8 @@
143154
<constraint firstItem="OuG-GD-vjx" firstAttribute="trailing" secondItem="XEb-Ml-Yki" secondAttribute="trailingMargin" id="OuI-Zg-Tmj"/>
144155
<constraint firstItem="R96-YX-hcO" firstAttribute="top" secondItem="Ecr-Nv-94t" secondAttribute="bottom" id="TlB-s6-hrj"/>
145156
<constraint firstItem="Ecr-Nv-94t" firstAttribute="top" secondItem="XEb-Ml-Yki" secondAttribute="top" id="c3T-oy-jf4"/>
157+
<constraint firstItem="zMK-tr-ShO" firstAttribute="trailing" secondItem="XEb-Ml-Yki" secondAttribute="trailingMargin" id="gKn-8w-gji"/>
158+
<constraint firstItem="R96-YX-hcO" firstAttribute="top" secondItem="zMK-tr-ShO" secondAttribute="bottom" constant="20" id="o9V-F5-YjZ"/>
146159
<constraint firstItem="OuG-GD-vjx" firstAttribute="leading" secondItem="XEb-Ml-Yki" secondAttribute="leadingMargin" id="rj6-SY-b7U"/>
147160
</constraints>
148161
</view>
@@ -172,6 +185,7 @@
172185
</rightBarButtonItems>
173186
</navigationItem>
174187
<connections>
188+
<outlet property="buttonScrollDown" destination="zMK-tr-ShO" id="ZOv-wV-Drz"/>
175189
<outlet property="labelEmptyState" destination="OuG-GD-vjx" id="JsK-ED-ZAX"/>
176190
<outlet property="segment" destination="m5B-Ti-NBe" id="bcc-Yl-slr"/>
177191
<outlet property="tableview" destination="Ecr-Nv-94t" id="uog-QX-pyC"/>
@@ -182,7 +196,7 @@
182196
</viewController>
183197
<placeholder placeholderIdentifier="IBFirstResponder" id="7Xf-kz-irU" userLabel="First Responder" sceneMemberID="firstResponder"/>
184198
</objects>
185-
<point key="canvasLocation" x="-740" y="2267"/>
199+
<point key="canvasLocation" x="-740" y="2266.4167916041979"/>
186200
</scene>
187201
<!--Container Filter View Controller-->
188202
<scene sceneID="0og-qw-MfJ">
@@ -754,6 +768,7 @@
754768
</scenes>
755769
<resources>
756770
<image name="filter" width="30" height="30"/>
771+
<image name="scroll-down" width="50" height="50"/>
757772
<image name="tabbar-logs" width="30" height="30"/>
758773
</resources>
759774
</document>

0 commit comments

Comments
 (0)