File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,13 @@ public struct Logger {
49
49
) {
50
50
guard let desktopDir = NSSearchPathForDirectoriesInDomains ( . desktopDirectory, . userDomainMask, true ) . last else { return }
51
51
let string = event. icon + " \( Date ( ) ) : " + messages. map { " \( $0) " } . joined ( )
52
- try ? string. write ( toFile: desktopDir + " //log.txt " , atomically: true , encoding: . utf8)
53
- }
54
-
55
- public func log( _ str: String ) {
52
+ guard let desktopUrl = URL ( string: desktopDir) else { return }
53
+ let fileContent = ( try ? String ( contentsOf: desktopUrl. appendingPathComponent ( " log.txt " ) ) ) ?? " "
54
+ let finalLog = fileContent. appending ( " \n " + string)
56
55
56
+ try ? finalLog. write ( toFile: desktopDir + " //log.txt " , atomically: true , encoding: . utf8)
57
57
}
58
+
58
59
59
60
}
60
61
Original file line number Diff line number Diff line change @@ -17,19 +17,19 @@ public struct Highlighter {
17
17
. map { $0. kind. rawValue + " \( $0. range. lowerBound) \( $0. range. upperBound) " }
18
18
. joined ( separator: " " )
19
19
Logger . log ( event: . debug, destination: . disk, messages: log)
20
- tokens. forEach ( { token in
20
+ tokens. forEach { token in
21
21
let color = self . color ( for: token. kind)
22
22
code. highlight ( token. text, with: color, at: token. range)
23
- } )
23
+ }
24
24
25
25
Logger . log ( event: . debug, destination: . disk, messages: code)
26
26
return code
27
27
}
28
28
}
29
29
30
30
private extension Highlighter {
31
- func color( for key : TokenType ) -> Color {
32
- config. theme. highlights [ key ] ?? Color ( r: 250 , g: 141 , b: 87 )
31
+ func color( for token : TokenType ) -> Color {
32
+ config. theme. highlights [ token ] ?? Color ( r: 250 , g: 141 , b: 87 )
33
33
}
34
34
}
35
35
You can’t perform that action at this time.
0 commit comments