Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98da599302 | ||
|
|
c68ca3376b | ||
|
|
46997ab9fc | ||
|
|
e5ae0c250e | ||
|
|
20af028cc3 | ||
|
|
f3f6616280 | ||
|
|
04b5b4228b | ||
|
|
62f9abb5e5 | ||
|
|
df7cdecda5 | ||
|
|
d96cec2ab1 | ||
|
|
843bc56f69 | ||
|
|
82e401b87d | ||
|
|
711519ded5 | ||
|
|
3ccb41ae0f | ||
|
|
e710bcab47 | ||
|
|
815ea3396f | ||
|
|
bf6093e299 | ||
|
|
7c18c73c82 | ||
|
|
65515eb2ce | ||
|
|
62d285364f | ||
|
|
9a3d31ce3b | ||
|
|
a4ddb9d6be | ||
|
|
dd28d21134 | ||
|
|
6b883e9457 | ||
|
|
e7654313f3 | ||
|
|
ab4af784c4 | ||
|
|
dbca8d6434 | ||
|
|
3a2a8c70b9 | ||
|
|
f800975607 | ||
|
|
a76983df36 | ||
|
|
1cdcf0297d | ||
|
|
ca722b8894 | ||
|
|
6e33998fb6 | ||
|
|
cbcbb20077 | ||
|
|
0115a6453e | ||
|
|
3522a64955 | ||
|
|
d9f23f9b44 | ||
|
|
6f1c4f4cf9 | ||
|
|
6ea0782565 | ||
|
|
c18a240ab3 | ||
|
|
399fc8810b | ||
|
|
d82e02dffb | ||
|
|
bf9540a06b | ||
|
|
124d62594f | ||
|
|
4c6c7cbd6a | ||
|
|
11a66d0f8a | ||
|
|
73e273b790 | ||
|
|
c9140cf19f | ||
|
|
6c6c79cdad | ||
|
|
05fa6043fe | ||
|
|
b2180f9235 | ||
|
|
f6452de763 | ||
|
|
653fbeb096 | ||
|
|
e43e017803 | ||
|
|
d055140364 | ||
|
|
c40841fc9b | ||
|
|
58e488c0ad | ||
|
|
088a3b5389 | ||
|
|
199621acf3 | ||
|
|
8f8d46f7aa | ||
|
|
81a7ee06af | ||
|
|
99c57e9927 | ||
|
|
a810a59b20 | ||
|
|
fd524adca1 | ||
|
|
0614ab56cd | ||
|
|
a2e3bf1603 | ||
|
|
54bb6069d6 | ||
|
|
383560ad43 | ||
|
|
aee59f6f47 | ||
|
|
2ea08a8604 | ||
|
|
5a8f1561c9 | ||
|
|
4984311370 | ||
|
|
6986b6ce2b | ||
|
|
b81a453b69 | ||
|
|
ce77e73428 | ||
|
|
bb86ebc606 | ||
|
|
c0fb5dd303 | ||
|
|
63d838728f | ||
|
|
ba1f49a711 | ||
|
|
867bf3fff5 | ||
|
|
ca571096bc | ||
|
|
bd5a0ae061 | ||
|
|
a87387cd1d | ||
|
|
ea324ea7d8 | ||
|
|
164d351c4d | ||
|
|
955763c004 | ||
|
|
8e4989e163 | ||
|
|
8ebebbda15 | ||
|
|
b5d1233778 | ||
|
|
45b89cd391 | ||
|
|
c5d4197562 | ||
|
|
1f5901ed38 | ||
|
|
b0d4cc19c3 | ||
|
|
2b7782a44c | ||
|
|
2b0b7113c2 | ||
|
|
da4dd4cc79 | ||
|
|
5ee4689893 | ||
|
|
8d8d4036dd | ||
|
|
d399f5f99a | ||
|
|
4bea296541 | ||
|
|
eb71cf76a9 | ||
|
|
29f0d419a5 | ||
|
|
3e8accaade | ||
|
|
3fb926ce52 | ||
|
|
eeedb06027 | ||
|
|
4a13fd049f | ||
|
|
89d892eea9 | ||
|
|
af26ffc88f | ||
|
|
ff6bc4d780 | ||
|
|
5d07cf1ae5 | ||
|
|
f4ddb7b776 | ||
|
|
ff66234223 | ||
|
|
af2dbc8c2d | ||
|
|
4743424ac4 | ||
|
|
ed381c56a6 | ||
|
|
34583fbd05 | ||
|
|
1f959b5bb0 | ||
|
|
753827e6c3 | ||
|
|
d6658498ba | ||
|
|
46b45cd3f7 | ||
|
|
0c3ccc278a | ||
|
|
406f1ab78b | ||
|
|
4929a96134 | ||
|
|
79b359fb64 | ||
|
|
2ef0d0b058 | ||
|
|
fd3ca7872e | ||
|
|
61ca2648bb | ||
|
|
583a377655 | ||
|
|
83468e46f7 | ||
|
|
1713ef28d4 | ||
|
|
7bf12bd2f4 | ||
|
|
61e1fe38e6 | ||
|
|
1fb0d86545 | ||
|
|
037f1117e4 | ||
|
|
c28a69ff42 | ||
|
|
e6fc89d050 | ||
|
|
6da986a974 | ||
|
|
90bfcda2f8 |
No files matched your search
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 752 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 752 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 158 KiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 33 KiB |
@@ -0,0 +1,147 @@
|
|||||||
|
//
|
||||||
|
// Logger.swift
|
||||||
|
// QuickDrop
|
||||||
|
//
|
||||||
|
// Created by Leon Böttger on 26.02.25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import os
|
||||||
|
|
||||||
|
fileprivate let loggerQueue = DispatchQueue(label: "loggerQueue")
|
||||||
|
|
||||||
|
/// Manages logging functionality
|
||||||
|
final class LogManager {
|
||||||
|
|
||||||
|
/// The URL of the log file
|
||||||
|
let logFileURL: URL?
|
||||||
|
|
||||||
|
/// The private initializer
|
||||||
|
private init() {
|
||||||
|
|
||||||
|
/// Get documents directory
|
||||||
|
let directory = getDocumentsDirectory()
|
||||||
|
|
||||||
|
/// Create file name from date
|
||||||
|
let formatter = DateFormatter()
|
||||||
|
formatter.dateFormat = "dd-MM-yyyy"
|
||||||
|
let dateString = formatter.string(from: Date())
|
||||||
|
let fileName = "\(dateString).log"
|
||||||
|
|
||||||
|
/// Create file URL from file name
|
||||||
|
self.logFileURL = directory.appendingPathComponent(fileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The shared instance.
|
||||||
|
public static let sharedInstance = LogManager()
|
||||||
|
@Published var loggingEnabled = true
|
||||||
|
|
||||||
|
|
||||||
|
/// Writes a specified string to the log file.
|
||||||
|
func writeToFile(string: String) {
|
||||||
|
|
||||||
|
/// Make sure the URL is not nil
|
||||||
|
guard let logFileURL = logFileURL else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get current timestamp
|
||||||
|
let formatter = DateFormatter()
|
||||||
|
formatter.dateFormat = "HH:mm:ss"
|
||||||
|
let timestamp = formatter.string(from: Date())
|
||||||
|
|
||||||
|
/// Create data from string and timestamp
|
||||||
|
guard let data = (timestamp + " - " + string + "\n").data(using: .utf8) else { return }
|
||||||
|
|
||||||
|
/// a log file exists already
|
||||||
|
if FileManager.default.fileExists(atPath: logFileURL.path) {
|
||||||
|
|
||||||
|
/// we try to get a handle to write to the log file
|
||||||
|
if let file = try? FileHandle(forWritingTo: logFileURL) {
|
||||||
|
|
||||||
|
/// go to end of file
|
||||||
|
file.seekToEndOfFile()
|
||||||
|
|
||||||
|
/// write string to end
|
||||||
|
file.write(data)
|
||||||
|
|
||||||
|
///close file
|
||||||
|
file.closeFile()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/// Clean up older logs
|
||||||
|
deleteLogs()
|
||||||
|
|
||||||
|
/// create new log file
|
||||||
|
try? data.write(to: logFileURL, options: .atomicWrite)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLogString() -> String {
|
||||||
|
|
||||||
|
if let logFileURL = logFileURL {
|
||||||
|
let fileURL = URL(fileURLWithPath: logFileURL.path)
|
||||||
|
do {
|
||||||
|
let content = try String(contentsOf: fileURL, encoding: .utf8)
|
||||||
|
return String(content)
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
log("[LUI] Error reading file: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Deletes all log files.
|
||||||
|
func deleteLogs() {
|
||||||
|
|
||||||
|
log("[LUI] Deleting all logs...")
|
||||||
|
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
|
||||||
|
let documentsDirectory = getDocumentsDirectory()
|
||||||
|
|
||||||
|
guard let allFiles = try? fileManager.contentsOfDirectory(at: documentsDirectory, includingPropertiesForKeys: nil) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let logFiles = allFiles.filter { $0.pathExtension.elementsEqual("log") }
|
||||||
|
|
||||||
|
for file in logFiles {
|
||||||
|
|
||||||
|
do {
|
||||||
|
log("[LUI] Removing \(file.description)")
|
||||||
|
try fileManager.removeItem(at: file)
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
print(error.localizedDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Logs a specified string.
|
||||||
|
public func log(_ text: String) {
|
||||||
|
|
||||||
|
let logger = LogManager.sharedInstance
|
||||||
|
|
||||||
|
if logger.loggingEnabled {
|
||||||
|
loggerQueue.async {
|
||||||
|
print(text)
|
||||||
|
|
||||||
|
// Weird bug?
|
||||||
|
#if !os(tvOS)
|
||||||
|
logger.writeToFile(string: text)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Returns the URL of the documents directory.
|
||||||
|
func getDocumentsDirectory() -> URL {
|
||||||
|
return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"pins" : [
|
|
||||||
{
|
|
||||||
"identity" : "asn1",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/leif-ibsen/ASN1",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "555922e06f1835863d4c0143eb00d0097bcfc707",
|
|
||||||
"version" : "2.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identity" : "bigint",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/leif-ibsen/BigInt",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "47903c6b2dd2cb3b4484d4524676a2ca8723a871",
|
|
||||||
"version" : "1.9.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identity" : "swift-protobuf",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/apple/swift-protobuf.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "0af9125c4eae12a4973fb66574c53a54962a9e1e",
|
|
||||||
"version" : "1.21.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identity" : "swiftecc",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/leif-ibsen/SwiftECC",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "55493f0609f07b24bf6cd52b90898ed1cefb268e",
|
|
||||||
"version" : "3.5.3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version" : 2
|
|
||||||
}
|
|
||||||