Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
kvyatkovskys committed Feb 20, 2023
1 parent 6dada40 commit e6b65c0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 105 deletions.
54 changes: 0 additions & 54 deletions Sources/KVKLogger/KVKLogDetailVM.swift

This file was deleted.

56 changes: 14 additions & 42 deletions Sources/KVKLogger/KVKLogNetworkDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ struct KVKLogNetworkDetailView: View {

private let maxLimitCountInText = 50
@State private var isCopied = false
@State private var resultLinelimit: Int? = 10
@State private var requestLinelimit: Int? = 10
@State private var text: String
@ObservedObject var log: ItemLog

init(log: ItemLog) {
self.log = log
var txtDetails = log.items
if let response = try? log.getNetworkJson(), !response.isEmpty {
txtDetails += "\n\n[RESULT]:\n\n\(response)"
}
text = txtDetails
}

var body: some View {
VStack(alignment: .leading, spacing: 10) {
if let size = log.size {
Expand All @@ -30,46 +38,10 @@ struct KVKLogNetworkDetailView: View {
Spacer()
}
}
ScrollView {
VStack(alignment: .leading, spacing: 10) {
Text("REQUEST:")
.foregroundColor(.gray)
.multilineTextAlignment(.leading)
Text(log.items)
.lineLimit(log.items.count <= maxLimitCountInText ? nil : requestLinelimit)
.multilineTextAlignment(.leading)
if log.items.count > maxLimitCountInText && requestLinelimit != nil {
HStack {
Spacer()
Button("Expand Request") {
requestLinelimit = nil
}
Spacer()
}
.padding()
}
if let json = try? log.getNetworkJson(), !json.isEmpty {
VStack(alignment: .leading) {
Text("RESULT:")
.foregroundColor(.gray)
.multilineTextAlignment(.leading)
Text(json)
.lineLimit(json.count <= maxLimitCountInText ? nil : resultLinelimit)
.multilineTextAlignment(.leading)
if json.count > maxLimitCountInText && resultLinelimit != nil {
HStack {
Spacer()
Button("Expand Result") {
resultLinelimit = nil
}
Spacer()
}
.padding()
}
}
}
}
}
Text("REQUEST:")
.foregroundColor(.gray)
.multilineTextAlignment(.leading)
TextEditor(text: $text)
}
.padding(.leading)
.navigationTitle(log.formattedShortCreatedAt)
Expand Down
22 changes: 13 additions & 9 deletions Sources/KVKLogger/KVKLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ open class KVKLogger {
/// if #DEBUG isn't setup in a project
public var isDebugMode: Bool?

public var isEnableSaveIntoDB: Bool = true

@ObservedObject var vm = KVKLoggerVM()

public init() {}
Expand Down Expand Up @@ -60,15 +62,17 @@ open class KVKLogger {
logType: KVKLogType,
details: String?) {
let date = Date()
let item = ItemLog(context: store.backgroundContext)
item.createdAt = date
item.status_ = status?.rawValue
item.logType = logType
item.type = type
item.details = details
item.items = items
item.data = data
store.save()
if isEnableSaveIntoDB {
let item = ItemLog(context: store.backgroundContext)
item.createdAt = date
item.status_ = status?.rawValue
item.logType = logType
item.type = type
item.details = details
item.items = items
item.data = data
store.save()
}

if isDebugMode != false {
printLog(items, details: details, status: status, type: logType, date: date)
Expand Down

0 comments on commit e6b65c0

Please sign in to comment.