diff --git a/Sparkle/updates/appcast.xml b/Sparkle/updates/appcast.xml index 0b69b70..ef7cdab 100644 --- a/Sparkle/updates/appcast.xml +++ b/Sparkle/updates/appcast.xml @@ -27,5 +27,16 @@ + + 2.0.3 + Sun, 29 Mar 2020 19:27:26 +0200 + 10.12 + + + + + + + diff --git a/Sparkle/updates/iGlance2.0.3-2.0.1.delta b/Sparkle/updates/iGlance2.0.3-2.0.1.delta new file mode 100644 index 0000000..24e4ea1 Binary files /dev/null and b/Sparkle/updates/iGlance2.0.3-2.0.1.delta differ diff --git a/Sparkle/updates/iGlance2.0.3-2.0.2.delta b/Sparkle/updates/iGlance2.0.3-2.0.2.delta new file mode 100644 index 0000000..a1a5af4 Binary files /dev/null and b/Sparkle/updates/iGlance2.0.3-2.0.2.delta differ diff --git a/Sparkle/updates/iGlance2.0.3-2.0.delta b/Sparkle/updates/iGlance2.0.3-2.0.delta new file mode 100644 index 0000000..9503f08 Binary files /dev/null and b/Sparkle/updates/iGlance2.0.3-2.0.delta differ diff --git a/iGlance/iGlance/iGlance.xcodeproj/project.pbxproj b/iGlance/iGlance/iGlance.xcodeproj/project.pbxproj index da2de33..b22ee5f 100644 --- a/iGlance/iGlance/iGlance.xcodeproj/project.pbxproj +++ b/iGlance/iGlance/iGlance.xcodeproj/project.pbxproj @@ -41,6 +41,7 @@ B46F25D623B22E4500E0A3F4 /* GpuInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B46F25D523B22E4500E0A3F4 /* GpuInfo.swift */; }; B47094EA23C79F9A009D85AD /* ThemedLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B47094E923C79F9A009D85AD /* ThemedLabel.swift */; }; B47094EC23C7A30A009D85AD /* ThemedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B47094EB23C7A30A009D85AD /* ThemedButton.swift */; }; + B472EC20243101DB002F7504 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = B472EC1F243101DB002F7504 /* Logger.swift */; }; B47D3C8D23ABEDF100DE911F /* CustomDashboardBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = B47D3C8C23ABEDF100DE911F /* CustomDashboardBox.swift */; }; B48BD19123E73F8E00152931 /* CpuUsageMenuBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B48BD19023E73F8E00152931 /* CpuUsageMenuBarItem.swift */; }; B49CD58F23EB17D9009711E6 /* CodableColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49CD58E23EB17D9009711E6 /* CodableColor.swift */; }; @@ -157,6 +158,7 @@ B46F25D523B22E4500E0A3F4 /* GpuInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GpuInfo.swift; sourceTree = ""; }; B47094E923C79F9A009D85AD /* ThemedLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemedLabel.swift; sourceTree = ""; }; B47094EB23C7A30A009D85AD /* ThemedButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemedButton.swift; sourceTree = ""; }; + B472EC1F243101DB002F7504 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = ""; }; B47D3C8C23ABEDF100DE911F /* CustomDashboardBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDashboardBox.swift; sourceTree = ""; }; B48BD19023E73F8E00152931 /* CpuUsageMenuBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CpuUsageMenuBarItem.swift; sourceTree = ""; }; B49CD58E23EB17D9009711E6 /* CodableColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodableColor.swift; sourceTree = ""; }; @@ -390,6 +392,7 @@ B4C37E6E23A91F2F008C7FC0 /* Theme */, B4FE0DAD23EF1BCB00AE94E6 /* Utils */, B46789B523A69ECA00CE572D /* AppDelegate.swift */, + B472EC1F243101DB002F7504 /* Logger.swift */, B4DE725E23C257610001CF46 /* Extensions.swift */, B49F5D5623C5BCAF009E9BE6 /* UserSettings.swift */, B46789BB23A69ECB00CE572D /* Main.storyboard */, @@ -721,6 +724,7 @@ B4FE0DB123EF1E0100AE94E6 /* LineGraph.swift in Sources */, B4FE0DB323EF210500AE94E6 /* Graph.swift in Sources */, B43ABF2A23AA32FA007F93BA /* SidebarViewController.swift in Sources */, + B472EC20243101DB002F7504 /* Logger.swift in Sources */, B415FF2723F459EF00ED6567 /* MemoryViewController.swift in Sources */, B4C37E6323A7946B008C7FC0 /* SidebarView.swift in Sources */, B45AC91D24212B2A00D331AC /* NetworkInfo.swift in Sources */, @@ -904,7 +908,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2.0.2; + CURRENT_PROJECT_VERSION = 2.0.3; DEVELOPMENT_TEAM = J6GXEPK4NG; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = iGlance/Info.plist; @@ -913,7 +917,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.3; PRODUCT_BUNDLE_IDENTIFIER = io.github.iglance.iGlance; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -931,7 +935,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2.0.2; + CURRENT_PROJECT_VERSION = 2.0.3; DEVELOPMENT_TEAM = J6GXEPK4NG; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = iGlance/Info.plist; @@ -940,7 +944,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.3; PRODUCT_BUNDLE_IDENTIFIER = io.github.iglance.iGlance; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/iGlance/iGlance/iGlance/AppDelegate.swift b/iGlance/iGlance/iGlance/AppDelegate.swift index fc59bcc..337972b 100644 --- a/iGlance/iGlance/iGlance/AppDelegate.swift +++ b/iGlance/iGlance/iGlance/AppDelegate.swift @@ -31,6 +31,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { // MARK: - // MARK: Instance Variables + let logger = Logger() + var mainWindow: MainWindowController = NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "MainWindowController") as! MainWindowController var currentUpdateLoopTimer: Timer! @@ -39,29 +41,6 @@ class AppDelegate: NSObject, NSApplicationDelegate { // MARK: Lifecycle Functions func applicationWillFinishLaunching(_ notification: Notification) { - // set the custom log formatter - DDOSLogger.sharedInstance.logFormatter = CustomLogFormatter() - // add the loggers to the loggin framework - DDLog.add(DDOSLogger.sharedInstance) - - // register the logger - // logs are saved under /Library/Logs/iGlance/ - let fileLogger = DDFileLogger() - fileLogger.logFormatter = CustomLogFormatter() - fileLogger.rollingFrequency = 60 * 60 * 24 // 24 hours - fileLogger.logFileManager.maximumNumberOfLogFiles = 7 - DDLog.add(fileLogger) - - // set the default log level to error - dynamicLogLevel = .error - - if DEBUG { - // log all messages - dynamicLogLevel = .all - // open the window on startup in debug mode - showMainWindow() - } - // call the update loop once on startup to render the menu bar items self.updateLoop() } diff --git a/iGlance/iGlance/iGlance/Logger.swift b/iGlance/iGlance/iGlance/Logger.swift new file mode 100644 index 0000000..83b08b7 --- /dev/null +++ b/iGlance/iGlance/iGlance/Logger.swift @@ -0,0 +1,37 @@ +// +// Logger.swift +// iGlance +// +// Created by Dominik on 29.03.20. +// Copyright © 2020 D0miH. All rights reserved. +// + +import Foundation +import CocoaLumberjack + +class Logger { + let fileLogger: DDFileLogger + + init() { + // set the custom log formatter + DDOSLogger.sharedInstance.logFormatter = CustomLogFormatter() + // add the loggers to the loggin framework + DDLog.add(DDOSLogger.sharedInstance) + + // register the logger + // logs are saved under /Library/Logs/iGlance/ + fileLogger = DDFileLogger() + fileLogger.logFormatter = CustomLogFormatter() + fileLogger.rollingFrequency = 60 * 60 * 24 // 24 hours + fileLogger.logFileManager.maximumNumberOfLogFiles = 7 + DDLog.add(fileLogger) + + // set the default log level to error + dynamicLogLevel = .error + + if AppDelegate.userSettings.settings.advancedLogging { + // log all messages + dynamicLogLevel = .all + } + } +} diff --git a/iGlance/iGlance/iGlance/MenuBarItems/Network/NetworkMenuBarItem.swift b/iGlance/iGlance/iGlance/MenuBarItems/Network/NetworkMenuBarItem.swift index 30f97bb..aae61e4 100644 --- a/iGlance/iGlance/iGlance/MenuBarItems/Network/NetworkMenuBarItem.swift +++ b/iGlance/iGlance/iGlance/MenuBarItems/Network/NetworkMenuBarItem.swift @@ -98,8 +98,14 @@ class NetworkMenuBarItem: MenuBarItem { let transmittedBytes = AppDelegate.systemInfo.network.getTotalTransmittedBytesOf(interface: currentInterface) // get the difference of the currently total transmitted bytes and the total transmitted bytes on the last reset - let bytesUploaded = transmittedBytes.up - currentInterfaceLastResetValue.up - let bytesDownloaded = transmittedBytes.down - currentInterfaceLastResetValue.down + var bytesUploaded = transmittedBytes.up + var bytesDownloaded = transmittedBytes.down + if transmittedBytes.up > currentInterfaceLastResetValue.up { + bytesUploaded = transmittedBytes.up - currentInterfaceLastResetValue.up + } + if transmittedBytes.down > currentInterfaceLastResetValue.down { + bytesDownloaded = transmittedBytes.down - currentInterfaceLastResetValue.down + } // update the dictionary self.transmittedBytesPerInterface[currentInterface] = (up: bytesUploaded, down: bytesDownloaded) diff --git a/iGlance/iGlance/iGlance/Modals/PreferenceModal/PreferenceModalViewController.swift b/iGlance/iGlance/iGlance/Modals/PreferenceModal/PreferenceModalViewController.swift index 9eef2d0..71519d9 100644 --- a/iGlance/iGlance/iGlance/Modals/PreferenceModal/PreferenceModalViewController.swift +++ b/iGlance/iGlance/iGlance/Modals/PreferenceModal/PreferenceModalViewController.swift @@ -26,13 +26,13 @@ class PreferenceModalViewController: ModalViewController { @IBOutlet private var autostartOnBootCheckbox: NSButton! { didSet { // load the initial value from the user settings - autostartOnBootCheckbox.state = AppDelegate.userSettings.settings.autostartOnBoot ? NSButton.StateValue.on : NSButton.StateValue.off + autostartOnBootCheckbox.state = AppDelegate.userSettings.settings.autostartOnBoot ? .on : .off } } @IBOutlet private var advancedLoggingCheckbox: ThemedButton! { didSet { - advancedLoggingCheckbox.state = DEBUG ? NSButton.StateValue.on : NSButton.StateValue.off + advancedLoggingCheckbox.state = AppDelegate.userSettings.settings.advancedLogging ? .on : .off } } @@ -123,8 +123,9 @@ class PreferenceModalViewController: ModalViewController { } @IBAction private func advancedLoggingCheckboxChanged(_ sender: NSButton) { + let activated = sender.state == .on // set the dynamic logging level depending on the state of the button - if sender.state == NSButton.StateValue.on { + if activated { dynamicLogLevel = .all DDLogInfo("Set the log level to 'all'") DDLogInfo("Activated 'Advanced Loggin'") @@ -133,6 +134,9 @@ class PreferenceModalViewController: ModalViewController { DDLogInfo("Set the log level to 'error'") DDLogInfo("Deactivated 'Advanced Loggin'") } + + // set the user setting + AppDelegate.userSettings.settings.advancedLogging = activated } @IBAction private func updateIntervalSelectorChanged(_ sender: NSPopUpButton) { diff --git a/iGlance/iGlance/iGlance/SystemInfo/DiskInfo.swift b/iGlance/iGlance/iGlance/SystemInfo/DiskInfo.swift index 4316da2..dbc1106 100644 --- a/iGlance/iGlance/iGlance/SystemInfo/DiskInfo.swift +++ b/iGlance/iGlance/iGlance/SystemInfo/DiskInfo.swift @@ -36,7 +36,7 @@ class DiskInfo { return (0, "") } - DDLogInfo("Output of internal disk size command: \(output)") + DDLogInfo("Output of internal disk size command: \n\(output)") // get all the devices var devices = output.components(separatedBy: "\n\n Capacity:") diff --git a/iGlance/iGlance/iGlance/SystemInfo/GpuInfo.swift b/iGlance/iGlance/iGlance/SystemInfo/GpuInfo.swift index 6fafaee..f2982a1 100644 --- a/iGlance/iGlance/iGlance/SystemInfo/GpuInfo.swift +++ b/iGlance/iGlance/iGlance/SystemInfo/GpuInfo.swift @@ -43,7 +43,7 @@ class GpuInfo { return "" } - DDLogInfo("Output of gpu name command: \(output)") + DDLogInfo("Output of gpu name command: \n\(output)") // seperate the lines let lines = output.split(separator: "\n") diff --git a/iGlance/iGlance/iGlance/SystemInfo/NetworkInfo.swift b/iGlance/iGlance/iGlance/SystemInfo/NetworkInfo.swift index 5f865ce..2444fe8 100644 --- a/iGlance/iGlance/iGlance/SystemInfo/NetworkInfo.swift +++ b/iGlance/iGlance/iGlance/SystemInfo/NetworkInfo.swift @@ -21,7 +21,7 @@ class NetworkInfo { // MARK: Private Variables /// The total uploaded and downloaded bytes that were read during the last update interval of the app. /// This variable is used to calculate the network bandwidth using [getNetworkBandwidth()](x-source-tag://getNetworkBandwidth()) - private var totalTransmittedBytes: (up: UInt64, down: UInt64) = (up: 0, down: 0) + private var lastTotalTransmittedBytes: (up: UInt64, down: UInt64) = (up: 0, down: 0) // MARK: - // MARK: Instance Functions @@ -37,15 +37,22 @@ class NetworkInfo { let transmittedBytes = getTotalTransmittedBytesOf(interface: interface) // get the transmitted byte since the last update - let upBytes = transmittedBytes.up - self.totalTransmittedBytes.up - let downBytes = transmittedBytes.down - self.totalTransmittedBytes.down + var upBytes: UInt64 = 0 + var downBytes: UInt64 = 0 + // if the lastTotalTransmittedBytes is greater than the current transmitted bytes, the currently used interface was changed + if transmittedBytes.up >= self.lastTotalTransmittedBytes.up { + upBytes = transmittedBytes.up - self.lastTotalTransmittedBytes.up + } + if transmittedBytes.down >= self.lastTotalTransmittedBytes.down { + downBytes = transmittedBytes.down - self.lastTotalTransmittedBytes.down + } // divide the bandwidth by the update interval to get the average of one update duration let upBandwidth = upBytes / UInt64(AppDelegate.userSettings.settings.updateInterval) let downBandwidth = downBytes / UInt64(AppDelegate.userSettings.settings.updateInterval) // update the total transmitted bytes - self.totalTransmittedBytes = transmittedBytes + self.lastTotalTransmittedBytes = transmittedBytes return (up: upBandwidth, down: downBandwidth) } @@ -71,7 +78,7 @@ class NetworkInfo { return (up: 0, down: 0) } - DDLogInfo("Output of network bandwidth command: \(commandOutput)") + DDLogInfo("Output of network bandwidth command: \n\(commandOutput)") // split the lines of the output let lowerCaseOutput = commandOutput.lowercased() @@ -121,6 +128,8 @@ class NetworkInfo { // get the command output let commandOutput = pipe.fileHandleForReading.readDataToEndOfFile() + DDLogInfo("Output of the network interface command: \n\(commandOutput)") + // get the currently used interface guard let commandString = String(data: commandOutput, encoding: String.Encoding.utf8) else { DDLogError("Something went wrong while casting the command output to a string") diff --git a/iGlance/iGlance/iGlance/UserSettings.swift b/iGlance/iGlance/iGlance/UserSettings.swift index 190f81b..2ed4aa3 100644 --- a/iGlance/iGlance/iGlance/UserSettings.swift +++ b/iGlance/iGlance/iGlance/UserSettings.swift @@ -74,6 +74,7 @@ struct BatterySettings: Codable { struct IGlanceUserSettings: Codable { // global settings var autostartOnBoot: Bool = false + var advancedLogging: Bool = DEBUG var updateInterval: Double = 2.0 var tempUnit: TemperatureUnit = .celsius