Cleanup logger usage

This commit is contained in:
Max Goedjen
2021-12-11 23:30:41 -08:00
parent ef691b5170
commit c33557e2a6
3 changed files with 25 additions and 21 deletions

View File

@@ -5,9 +5,11 @@ import OSLog
import SecretKit
struct LaunchAgentController {
private let logger = Logger()
func install() async {
Logger().debug("Installing agent")
logger.debug("Installing agent")
_ = setEnabled(false)
// This is definitely a bit of a "seems to work better" thing but:
// Seems to more reliably hit if these are on separate runloops, otherwise it seems like it sometimes doesn't kill old
@@ -17,15 +19,15 @@ struct LaunchAgentController {
}
func forceLaunch() async throws {
Logger().debug("Agent is not running, attempting to force launch")
logger.debug("Agent is not running, attempting to force launch")
let url = Bundle.main.bundleURL.appendingPathComponent("Contents/Library/LoginItems/SecretAgent.app")
let config = NSWorkspace.OpenConfiguration()
config.activates = false
do {
try await NSWorkspace.shared.openApplication(at: url, configuration: config)
Logger().debug("Agent force launched")
logger.debug("Agent force launched")
} catch {
Logger().error("Error force launching \(error.localizedDescription)")
logger.error("Error force launching \(error.localizedDescription)")
throw error
}
}