mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-09 13:10:24 +01:00
👌 Improve initial logging during startup
This commit is contained in:
@@ -20,24 +20,24 @@ class Startup {
|
|||||||
func checkEnvironment(success: @escaping () -> Void, failure: @escaping () -> Void)
|
func checkEnvironment(success: @escaping () -> Void, failure: @escaping () -> Void)
|
||||||
{
|
{
|
||||||
// Do the important system setup checks
|
// 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 {
|
for check in self.checks {
|
||||||
if check.succeeds() {
|
if check.succeeds() {
|
||||||
Log.info("— \(check.name): PASSED")
|
Log.info("[OK] \(check.name)")
|
||||||
continue
|
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)
|
showAlert(for: check)
|
||||||
|
|
||||||
failure()
|
failure()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we get here, nothing has gone wrong. That's what we want!
|
||||||
initializeSwitcher()
|
initializeSwitcher()
|
||||||
|
Log.info("==================================")
|
||||||
Log.info("PHP Monitor has determined the application has successfully passed all checks.")
|
Log.info("PHP Monitor has determined the application has successfully passed all checks.")
|
||||||
success()
|
success()
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ class Startup {
|
|||||||
public var checks: [EnvironmentCheck] = [
|
public var checks: [EnvironmentCheck] = [
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: { return !FileManager.default.fileExists(atPath: Paths.brew) },
|
command: { return !FileManager.default.fileExists(atPath: Paths.brew) },
|
||||||
name: "Homebrew Location Check",
|
name: "`\(Paths.brew)` exists",
|
||||||
titleText: "alert.homebrew_missing.title".localized,
|
titleText: "alert.homebrew_missing.title".localized,
|
||||||
descriptionText: "alert.homebrew_missing.info".localized(
|
descriptionText: "alert.homebrew_missing.info".localized(
|
||||||
App.architecture
|
App.architecture
|
||||||
@@ -89,7 +89,7 @@ class Startup {
|
|||||||
),
|
),
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: { return !Shell.fileExists(Paths.php) },
|
command: { return !Shell.fileExists(Paths.php) },
|
||||||
name: "PHP Binary Check",
|
name: "`\(Paths.php)` exists",
|
||||||
titleText: "startup.errors.php_binary.title".localized,
|
titleText: "startup.errors.php_binary.title".localized,
|
||||||
descriptionText: "startup.errors.php_binary.desc".localized(
|
descriptionText: "startup.errors.php_binary.desc".localized(
|
||||||
Paths.php
|
Paths.php
|
||||||
@@ -97,7 +97,7 @@ class Startup {
|
|||||||
),
|
),
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: { return !Shell.pipe("ls \(Paths.optPath) | grep php").contains("php") },
|
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,
|
titleText: "startup.errors.php_opt.title".localized,
|
||||||
descriptionText: "startup.errors.php_opt.desc".localized(
|
descriptionText: "startup.errors.php_opt.desc".localized(
|
||||||
Paths.optPath
|
Paths.optPath
|
||||||
@@ -108,7 +108,7 @@ class Startup {
|
|||||||
return !(Shell.fileExists(Paths.valet)
|
return !(Shell.fileExists(Paths.valet)
|
||||||
|| Shell.fileExists("~/.composer/vendor/bin/valet"))
|
|| Shell.fileExists("~/.composer/vendor/bin/valet"))
|
||||||
},
|
},
|
||||||
name: "Valet Check",
|
name: "`valet` binary exists",
|
||||||
titleText: "startup.errors.valet_executable.title".localized,
|
titleText: "startup.errors.valet_executable.title".localized,
|
||||||
descriptionText: "startup.errors.valet_executable.desc".localized(
|
descriptionText: "startup.errors.valet_executable.desc".localized(
|
||||||
Paths.valet
|
Paths.valet
|
||||||
@@ -116,19 +116,19 @@ class Startup {
|
|||||||
),
|
),
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: { return HomebrewDiagnostics.cannotLoadService() },
|
command: { return HomebrewDiagnostics.cannotLoadService() },
|
||||||
name: "Homebrew Services Check",
|
name: "`sudo \(Paths.brew) services info` JSON loaded",
|
||||||
titleText: "startup.errors.services_json_error.title".localized,
|
titleText: "startup.errors.services_json_error.title".localized,
|
||||||
descriptionText: "startup.errors.services_json_error.desc".localized
|
descriptionText: "startup.errors.services_json_error.desc".localized
|
||||||
),
|
),
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: { return !Shell.pipe("cat /private/etc/sudoers.d/brew").contains(Paths.brew) },
|
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,
|
titleText: "startup.errors.sudoers_brew.title".localized,
|
||||||
descriptionText: "startup.errors.sudoers_brew.desc".localized
|
descriptionText: "startup.errors.sudoers_brew.desc".localized
|
||||||
),
|
),
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: { return !Shell.pipe("cat /private/etc/sudoers.d/valet").contains(Paths.valet) },
|
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,
|
titleText: "startup.errors.sudoers_valet.title".localized,
|
||||||
descriptionText: "startup.errors.sudoers_valet.desc".localized
|
descriptionText: "startup.errors.sudoers_valet.desc".localized
|
||||||
),
|
),
|
||||||
@@ -139,7 +139,7 @@ class Startup {
|
|||||||
Valet.shared.version = VersionExtractor.from(valet("--version", sudo: false))
|
Valet.shared.version = VersionExtractor.from(valet("--version", sudo: false))
|
||||||
return Valet.shared.version == nil
|
return Valet.shared.version == nil
|
||||||
},
|
},
|
||||||
name: "Valet Version Check",
|
name: "`valet --version` was loaded",
|
||||||
titleText: "startup.errors.valet_version_unknown.title".localized,
|
titleText: "startup.errors.valet_version_unknown.title".localized,
|
||||||
descriptionText: "startup.errors.valet_version_unknown.desc".localized
|
descriptionText: "startup.errors.valet_version_unknown.desc".localized
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user