mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-07 05:10:06 +01:00
🔀 Merge branch 'dev/5.7' into dev/6.0
This merge brings all of the changes from 5.7 into the 6.0 branch, while avoiding the need for cherry picking now that the conflicts have been resolved.
This commit is contained in:
@@ -30,9 +30,9 @@ class Log {
|
||||
|
||||
public func prepareLogFile() {
|
||||
if !isRunningTests && Verbosity.cli.isApplicable() {
|
||||
_ = system("mkdir -p ~/.config/phpmon 2> /dev/null")
|
||||
_ = system("rm ~/.config/phpmon/last_session.log 2> /dev/null")
|
||||
_ = system("touch ~/.config/phpmon/last_session.log 2> /dev/null")
|
||||
system_quiet("mkdir -p ~/.config/phpmon 2> /dev/null")
|
||||
system_quiet("rm ~/.config/phpmon/last_session.log 2> /dev/null")
|
||||
system_quiet("touch ~/.config/phpmon/last_session.log 2> /dev/null")
|
||||
self.logExists = FileSystem.fileExists(self.logFilePath)
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,12 @@ class Log {
|
||||
}
|
||||
}
|
||||
|
||||
static func line(as verbosity: Verbosity = .info) {
|
||||
if verbosity.isApplicable() {
|
||||
Log.shared.log("----------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
private func log(_ text: String) {
|
||||
print(text)
|
||||
|
||||
@@ -85,4 +91,4 @@ class Log {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,3 +26,21 @@ public func system(_ command: String) -> String {
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
/**
|
||||
Run a simple blocking Shell command on the user's own system.
|
||||
This variation does not return the output.
|
||||
Avoid using this method in favor of the fakeable Shell class unless needed for express system operations.
|
||||
*/
|
||||
public func system_quiet(_ command: String) {
|
||||
let task = Process()
|
||||
task.launchPath = "/bin/sh"
|
||||
task.arguments = ["-c", command]
|
||||
|
||||
let pipe = Pipe()
|
||||
task.standardOutput = pipe
|
||||
task.launch()
|
||||
|
||||
_ = pipe.fileHandleForReading.readDataToEndOfFile()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user