Loss Log now uses binary file, 2/3 size reduction

This commit is contained in:
2017-06-19 16:47:19 +02:00
parent 1e56a6247b
commit 16ea155d0d
9 changed files with 89 additions and 10 deletions
+14 -4
View File
@@ -21,11 +21,11 @@ class ConnectionLossOperation: Operation {
let time : Date = Date()
let start: Array<String> = (NSApp.delegate as! AppDelegate).justDate.string(from: time).components(separatedBy: ".")
// Line to write
let entry: String = String(format: "%@\n", (NSApp.delegate as! AppDelegate).justTime.string(from: time))
let entry: String = String(format: "%@", (NSApp.delegate as! AppDelegate).justTime.string(from: time))
// File manager
let fileManager: FileManager = FileManager.default
// Path to file
let file: String = NSString(format: "~/KDLog/%@.docsisplist2/%@/%@/KDLog.txt", start[2], start[1], start[0]).expandingTildeInPath
let file: String = NSString(format: "~/KDLog/%@.docsisplist2/%@/%@/KDLog.hex", start[2], start[1], start[0]).expandingTildeInPath
// Make all relevant directories if not present
pthread_mutex_lock(&((NSApp.delegate as! AppDelegate).lock))
let dir: NSString = NSString(format: "~/KDLog/%@.docsisplist2/%@/%@", start[2], start[1], start[0])
@@ -44,6 +44,7 @@ class ConnectionLossOperation: Operation {
data, response, error in
if error != nil && data == nil && self.result2 {
/*
let fileH: FileHandle? = FileHandle(forUpdatingAtPath: file)
if fileH == nil {
do{
@@ -58,7 +59,11 @@ class ConnectionLossOperation: Operation {
fileH?.write(data!)
fileH?.closeFile()
}
let sep = entry.components(separatedBy: ":")
FileOperations.logHours(UInt8(sep[0])!, minutes: UInt8(sep[1])!, seconds: UInt8(sep[2])!, toLog: file)
*/
FileOperations.log(data: entry, toLog: file)
self.result2 = false;
NSLog("Internet loss logged!")
}
@@ -70,6 +75,7 @@ class ConnectionLossOperation: Operation {
data, response, error in
if error != nil && data == nil && self.result1 {
/*
let fileH: FileHandle? = FileHandle(forUpdatingAtPath: file)
if fileH == nil {
do{
@@ -84,7 +90,11 @@ class ConnectionLossOperation: Operation {
fileH?.write(data!)
fileH?.closeFile()
}
self.result1 = false;
let sep = entry.components(separatedBy: ":")
FileOperations.logHours(UInt8(sep[0])!, minutes: UInt8(sep[1])!, seconds: UInt8(sep[2])!, toLog: file)
*/
FileOperations.log(data: entry, toLog: file)
self.result2 = false;
NSLog("Internet loss logged!")
}
else if error != nil && response == nil && data == nil {
+1 -1
View File
@@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>4.0</string>
<key>CFBundleVersion</key>
<string>27</string>
<string>39</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
+1
View File
@@ -4,3 +4,4 @@
//
#import "XMLDictionary.h"
//#import "FileOperations.h"
+1 -1
View File
@@ -1,2 +1,2 @@
version 4.0
build 27
build 39