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

♻️ Added logger class

This commit is contained in:
2021-12-21 17:06:03 +01:00
parent ceb168c6cf
commit e76c6e14e4
23 changed files with 135 additions and 64 deletions

View File

@ -15,17 +15,25 @@ import Foundation
// Information about the PHP versions
// etc.: needs to be stored in a separate object we can instantiate here and in PHP Monitor.
print(CommandLine.arguments)
var logger = Log.shared
logger.verbosity = .warning
if CommandLine.arguments.count != 3 {
print("You must enter two arguments.")
if CommandLine.arguments.count < 3 {
Log.err("You must enter at least two additional arguments.")
exit(1)
}
if CommandLine.arguments.contains("-v") || CommandLine.arguments.contains("--verbose") {
logger.verbosity = .info
}
if CommandLine.arguments.contains("-p") || CommandLine.arguments.contains("--performance") {
logger.verbosity = .performance
}
let argument = CommandLine.arguments[1]
if !AllowedArguments.has(argument) {
print("The supported arguments are: \(AllowedArguments.rawValues)")
Log.err("The supported arguments are: \(AllowedArguments.rawValues)")
exit(1)
}
@ -37,9 +45,9 @@ PhpSwitcher.detectPhpVersions()
switch action {
case .use:
let version = CommandLine.arguments[2]
print("Switching to PHP \(version)...")
Log.info("Switching to PHP \(version)...")
break
case .none:
print("Action not recognized!")
Log.err("Action not recognized!")
exit(1)
}