Skip to content

Commit 20110fc

Browse files
committed
fix privacy
1 parent 8edd797 commit 20110fc

10 files changed

+40
-31
lines changed

DDLoggerSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = 'DDLoggerSwift'
33
s.swift_version = '5.0'
4-
s.version = '5.3.2'
4+
s.version = '5.3.3'
55
s.license= { :type => "MIT", :file => "LICENSE" }
66
s.summary = 'The iOS side displays the output log log on the screen, and can generate log file sharing, which is convenient for debugging information'
77
s.homepage = 'https://github.com/DamonHu/DDLoggerSwift'

example/DDLoggerSwift/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ViewController: UIViewController {
8888
let startTime = DispatchTime.now()
8989
for i in 0..<100 {
9090
// print("\(i)")
91-
printLog("\(i)")
91+
// printLog("\(i)")
9292
// printLog("测试输出,默认不会写入数据库","222222","3333333")
9393
// //普通输出
9494
// printInfo("点击了按钮111")

example/Pods/DDUtils/Sources/core/utils/Data+zx.swift

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pod/DDContentViewController.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import UIKit
10+
import DDUtils
1011

1112
class DDContentViewController: UIViewController {
1213
private var mDisplayLogDataArray = [DDLoggerSwiftTableCellModel]() //tableview显示的logger
@@ -66,7 +67,7 @@ class DDContentViewController: UIViewController {
6667
private lazy var mContentBGView: UIView = {
6768
let mContentBGView = UIView()
6869
mContentBGView.translatesAutoresizingMaskIntoConstraints = false
69-
mContentBGView.backgroundColor = UIColor.dd.color(hexValue: 0x000000, alpha: 0.7)
70+
mContentBGView.backgroundColor = UIColor.dd.color(hexValue: 0x2d353b)
7071
return mContentBGView
7172
}()
7273

@@ -122,6 +123,7 @@ class DDContentViewController: UIViewController {
122123
tableView.register(DDLoggerSwiftTableViewCell.self, forCellReuseIdentifier: "DDLoggerSwiftTableViewCell")
123124
//添加下拉刷新
124125
let refreshControl = UIRefreshControl()
126+
refreshControl.tintColor = UIColor.dd.color(hexValue: 0xffffff)
125127
refreshControl.addTarget(self, action: #selector(_resetData), for: .valueChanged)
126128
tableView.refreshControl = refreshControl
127129
//底部距离
@@ -382,11 +384,12 @@ private extension DDContentViewController {
382384
}
383385

384386
@objc private func _dbUpdate(notice: Notification) {
385-
guard let object = notice.object as? [String: Any], let type = object["type"] as? String else { return }
386-
if type == "insert" && self.mPullImageBGView.isHidden {
387-
self.mPullImageBGView.isHidden = false
387+
guard let object = notice.object as? [String: Any], let type = object["type"] as? String, type == "insert" else { return }
388+
DDUtils.shared.runInMainThread {
389+
if self.mPullImageBGView.isHidden {
390+
self.mPullImageBGView.isHidden = false
391+
}
388392
}
389-
390393
}
391394
}
392395

pod/DDLoggerSwift.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import DDUtils
1212
///log的级别,对应不同的颜色
1313
public struct DDLogType : OptionSet {
1414
public static let debug = DDLogType([]) //only show in debug output
15-
public static let info = DDLogType(rawValue: 1) //textColor #50d890
15+
public static let info = DDLogType(rawValue: 1) //textColor #42e6a4
1616
public static let warn = DDLogType(rawValue: 2) //textColor #f6f49d
1717
public static let error = DDLogType(rawValue: 4) //textColor #ff7676
18-
public static let privacy = DDLogType(rawValue: 8) //textColor #42e6a4
18+
public static let privacy = DDLogType(rawValue: 8) //textColor #409eff
1919

2020
public let rawValue: Int
2121
public init(rawValue: Int) {
@@ -29,13 +29,13 @@ extension DDLogType {
2929
case .debug:
3030
return UIColor.dd.color(hexValue: 0xD1B6E1)
3131
case .info:
32-
return UIColor(red: 80.0/255.0, green: 216.0/255.0, blue: 144.0/255.0, alpha: 1.0)
32+
return UIColor.dd.color(hexValue: 0x42e6a4)
3333
case .warn:
34-
return UIColor(red: 246.0/255.0, green: 244.0/255.0, blue: 157.0/255.0, alpha: 1.0)
34+
return UIColor.dd.color(hexValue: 0xf6f49d)
3535
case .error:
36-
return UIColor.dd.color(hexValue: 0xFFAFAF)
36+
return UIColor.dd.color(hexValue: 0xE67E80)
3737
case .privacy:
38-
return UIColor(red: 66.0/255.0, green: 230.0/255.0, blue: 164.0/255.0, alpha: 1.0)
38+
return UIColor.dd.color(hexValue: 0x409eff)
3939
default:
4040
return UIColor.black
4141
}
@@ -128,7 +128,7 @@ public class DDLoggerSwift {
128128
**/
129129
public static var privacyLogPassword = "12345678901234561234567890123456"
130130
public static var privacyLogIv = "abcdefghijklmnop"
131-
public static var privacyResultEncodeType = DDUtilsEncodeType.hex
131+
public static var privacyResultEncodeType = DDUtilsEncodeType.base64
132132

133133
//MARK: 内部
134134
static var fileSelectedComplete: ((URL, String) ->Void)? //选择历史文件过滤回调
@@ -187,6 +187,10 @@ public class DDLoggerSwift {
187187
loggerItem.mLogLine = "\(lineNum)"
188188
loggerItem.mLogFunction = funcName
189189
loggerItem.mLogContent = log
190+
if logType == .privacy {
191+
//转换加密
192+
loggerItem.mLogContent = loggerItem.getLogContent().dd.aesCBCEncrypt(password: DDLoggerSwift.privacyLogPassword, ivString: DDLoggerSwift.privacyLogIv, encodeType: DDLoggerSwift.privacyResultEncodeType) ?? "Invalid encryption".ZXLocaleString
193+
}
190194

191195
if self.isSyncConsole {
192196
print(loggerItem.getFullContentString())

pod/DDLoggerSwiftPickerWindow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DDLoggerSwiftPickerWindow: UIWindow {
5252
private lazy var mContentBGView: UIView = {
5353
let mContentBGView = UIView()
5454
mContentBGView.translatesAutoresizingMaskIntoConstraints = false
55-
mContentBGView.backgroundColor = UIColor.dd.color(hexValue: 0x333333)
55+
mContentBGView.backgroundColor = UIColor.dd.color(hexValue: 0x2d353b)
5656
return mContentBGView
5757
}()
5858

pod/DDLoggerSwiftWindow.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ extension String{
3131
}
3232
}
3333

34+
35+
3436
class DDLoggerSwiftWindow: UIWindow {
3537
var currentVC = DDContentViewController()
3638
required init?(coder: NSCoder) {

pod/model/DDLoggerSwiftItem.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ public extension DDLoggerSwiftItem {
7272
} else {
7373
contentString = "\(mContent)"
7474
}
75-
if self.mLogItemType == .privacy {
76-
contentString = contentString.dd.aesCBCEncrypt(password: DDLoggerSwift.privacyLogPassword, ivString: DDLoggerSwift.privacyLogIv, encodeType: DDLoggerSwift.privacyResultEncodeType) ?? "Invalid encryption".ZXLocaleString
77-
}
7875
}
7976
return contentString
8077
}
@@ -83,8 +80,12 @@ public extension DDLoggerSwiftItem {
8380
func getFullContentString() -> String {
8481
//日期
8582
let dateStr = DDLoggerSwift.dateFormatterISO8601.string(from: mCreateDate)
83+
var logContent = self.getLogContent()
84+
if self.mLogItemType == .privacy && DDLoggerSwift.shared.isPasswordCorrect {
85+
logContent = logContent.dd.aesCBCDecrypt(password: DDLoggerSwift.privacyLogPassword, ivString: DDLoggerSwift.privacyLogIv, encodeType: DDLoggerSwift.privacyResultEncodeType) ?? logContent
86+
}
8687
//所有的内容
87-
return "\(self.icon())" + " " + "[\(dateStr)]" + " " + "[\(self.level())]" + " " + "File: \(mLogFile) | Line: \(mLogLine) | Function: \(mLogFunction) " + "\n---------------------------------\n" + self.getLogContent() + "\n"
88+
return "\(self.icon())" + " " + "[\(dateStr)]" + " " + "[\(self.level())]" + " " + "File: \(mLogFile) | Line: \(mLogLine) | Function: \(mLogFunction) " + "\n---------------------------------\n" + logContent + "\n"
8889
}
8990

9091
//根据需要高亮内容查询组装高亮内容

pod/view/DDLoggerSwiftMenuCollectionViewCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class DDLoggerSwiftMenuCollectionViewCell: UICollectionViewCell {
6868

6969
private extension DDLoggerSwiftMenuCollectionViewCell {
7070
func _createUI() {
71-
self.backgroundColor = UIColor.dd.color(hexValue: 0x3333331)
71+
self.backgroundColor = UIColor.dd.color(hexValue: 0x1a1a1a)
7272
self.layer.cornerRadius = 15
7373
self.contentView.addSubview(mImageView)
7474
mImageView.centerXAnchor.constraint(equalTo: self.contentView.centerXAnchor).isActive = true

pod/view/DDLoggerSwiftMenuView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class DDLoggerSwiftMenuView: UIView {
4242

4343
private extension DDLoggerSwiftMenuView {
4444
func _createUI() {
45-
self.backgroundColor = UIColor.dd.color(hexValue: 0x000000, alpha: 0.7)
45+
self.backgroundColor = UIColor.dd.color(hexValue: 0x2d353b)
4646
self.addSubview(mCollectionView)
4747
mCollectionView.topAnchor.constraint(equalTo: self.topAnchor, constant: 20).isActive = true
4848
mCollectionView.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true

0 commit comments

Comments
 (0)