-
Notifications
You must be signed in to change notification settings - Fork 5
/
GoDLogManager.swift
56 lines (48 loc) · 1.09 KB
/
GoDLogManager.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// GoDToolExtensions.swift
// GoD Tool
//
// Created by The Steez on 16/09/2017.
//
//
import Foundation
let date = Date(timeIntervalSinceNow: 0)
var logString = ""
var silentLogs = false
func displayAlert(title: String, description: String) {
#if GUI
GoDAlertViewController.displayAlert(title: title, text: description)
#else
printg("\nAlert: \(title)\n\(description)\n>> Press enter to continue...")
_ = readLine()
#endif
}
func printg(_ args: Any...) {
var newString = ""
for arg in args {
print(arg, separator: " ", terminator: " ")
newString = newString + String(describing: arg) + " "
}
print("") // automatically adds new line
newString += "\n"
logString += newString
#if GUI
if !silentLogs {
XGThreadManager.manager.runInForegroundAsync {
let hvc = appDelegate.homeViewController
if hvc != nil {
let log = hvc!.logView!
log.string = log.string + newString
}
}
}
#endif
if !fileDecodingMode && XGISO.inputISOFile != nil {
XGUtility.saveString(logString, toFile: .log(date))
}
}
extension CustomStringConvertible {
func println() {
printg(self)
}
}