diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index 5c2b2741e..888a727fc 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -17,6 +17,7 @@ import RSCore let appName = "Evergreen" var currentTheme: VSTheme! +var appDelegate: AppDelegate! @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { @@ -30,7 +31,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { var addFeedController: AddFeedController? var addFolderWindowController: AddFolderWindowController? var keyboardShortcutsWindowController: WebViewWindowController? - + let log = Log() let themeLoader = VSThemeLoader() private let appNewsURLString = "https://ranchero.com/evergreen/feed.json" private let dockBadge = DockBadge() @@ -50,6 +51,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { dockBadge.appDelegate = self NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) + appDelegate = self + } + + func logMessage(_ message: String, type: LogItem.ItemType) { + + let logItem = LogItem(type: type, message: message) + log.add(logItem) + } + + func logDebugMessage(_ message: String) { + + logMessage(message, type: .debug) } // MARK: - NSApplicationDelegate @@ -57,6 +70,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { func applicationDidFinishLaunching(_ note: Notification) { let isFirstRun = AppDefaults.shared.isFirstRun + logDebugMessage(isFirstRun ? "Is first run." : "Is not first run.") let localAccount = AccountManager.shared.localAccount DefaultFeedsImporter.importIfNeeded(isFirstRun, account: localAccount) diff --git a/Frameworks/RSCore/RSCore/Log.swift b/Frameworks/RSCore/RSCore/Log.swift index c171d7c54..f7958c904 100644 --- a/Frameworks/RSCore/RSCore/Log.swift +++ b/Frameworks/RSCore/RSCore/Log.swift @@ -10,7 +10,11 @@ import Foundation public class Log { - var logItems = [LogItem]() + public var logItems = [LogItem]() + + public init() { + // Satisfy compiler + } public func add(_ logItem: LogItem) { diff --git a/Frameworks/RSCore/RSCore/LogItem.swift b/Frameworks/RSCore/RSCore/LogItem.swift index 501964688..96cd67180 100644 --- a/Frameworks/RSCore/RSCore/LogItem.swift +++ b/Frameworks/RSCore/RSCore/LogItem.swift @@ -11,7 +11,7 @@ import Foundation public struct LogItem: Hashable { public enum ItemType { - case notification, warning, error + case debug, notification, warning, error } public let type: ItemType