1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

👌 Improve initial logging during startup

This commit is contained in:
2022-02-11 23:51:58 +01:00
parent f702d14749
commit 537536d443

View File

@ -20,24 +20,24 @@ class Startup {
func checkEnvironment(success: @escaping () -> Void, failure: @escaping () -> Void)
{
// Do the important system setup checks
Log.info("The user is running PHP Monitor with the architecture: \(App.architecture)")
Log.info("[ARCH] The user is running PHP Monitor with the architecture: \(App.architecture)")
for check in self.checks {
if check.succeeds() {
Log.info(" \(check.name): PASSED")
Log.info("[OK] \(check.name)")
continue
}
Log.info("\(check.name): FAILED")
// If we get here, something's gone wrong and the check has failed
Log.info("[FAIL] \(check.name)")
showAlert(for: check)
failure()
return
}
// If we get here, nothing has gone wrong. That's what we want!
initializeSwitcher()
Log.info("==================================")
Log.info("PHP Monitor has determined the application has successfully passed all checks.")
success()
}
@ -76,7 +76,7 @@ class Startup {
public var checks: [EnvironmentCheck] = [
EnvironmentCheck(
command: { return !FileManager.default.fileExists(atPath: Paths.brew) },
name: "Homebrew Location Check",
name: "`\(Paths.brew)` exists",
titleText: "alert.homebrew_missing.title".localized,
descriptionText: "alert.homebrew_missing.info".localized(
App.architecture
@ -89,7 +89,7 @@ class Startup {
),
EnvironmentCheck(
command: { return !Shell.fileExists(Paths.php) },
name: "PHP Binary Check",
name: "`\(Paths.php)` exists",
titleText: "startup.errors.php_binary.title".localized,
descriptionText: "startup.errors.php_binary.desc".localized(
Paths.php
@ -97,7 +97,7 @@ class Startup {
),
EnvironmentCheck(
command: { return !Shell.pipe("ls \(Paths.optPath) | grep php").contains("php") },
name: "PHP Versions Check",
name: "`ls \(Paths.optPath) | grep php` returned php result",
titleText: "startup.errors.php_opt.title".localized,
descriptionText: "startup.errors.php_opt.desc".localized(
Paths.optPath
@ -108,7 +108,7 @@ class Startup {
return !(Shell.fileExists(Paths.valet)
|| Shell.fileExists("~/.composer/vendor/bin/valet"))
},
name: "Valet Check",
name: "`valet` binary exists",
titleText: "startup.errors.valet_executable.title".localized,
descriptionText: "startup.errors.valet_executable.desc".localized(
Paths.valet
@ -116,19 +116,19 @@ class Startup {
),
EnvironmentCheck(
command: { return HomebrewDiagnostics.cannotLoadService() },
name: "Homebrew Services Check",
name: "`sudo \(Paths.brew) services info` JSON loaded",
titleText: "startup.errors.services_json_error.title".localized,
descriptionText: "startup.errors.services_json_error.desc".localized
),
EnvironmentCheck(
command: { return !Shell.pipe("cat /private/etc/sudoers.d/brew").contains(Paths.brew) },
name: "Sudo Check (Homebrew)",
name: "`/private/etc/sudoers.d/brew` contains brew",
titleText: "startup.errors.sudoers_brew.title".localized,
descriptionText: "startup.errors.sudoers_brew.desc".localized
),
EnvironmentCheck(
command: { return !Shell.pipe("cat /private/etc/sudoers.d/valet").contains(Paths.valet) },
name: "Sudo Check (Valet)",
name: "`/private/etc/sudoers.d/valet` contains valet",
titleText: "startup.errors.sudoers_valet.title".localized,
descriptionText: "startup.errors.sudoers_valet.desc".localized
),
@ -139,7 +139,7 @@ class Startup {
Valet.shared.version = VersionExtractor.from(valet("--version", sudo: false))
return Valet.shared.version == nil
},
name: "Valet Version Check",
name: "`valet --version` was loaded",
titleText: "startup.errors.valet_version_unknown.title".localized,
descriptionText: "startup.errors.valet_version_unknown.desc".localized
)