new - loglevel (#612)

This commit is contained in:
Ho3ein
2023-06-16 18:25:33 +03:30
committed by GitHub
parent 97925eeebe
commit 5188d516e3
10 changed files with 50 additions and 20 deletions

View File

@@ -380,16 +380,17 @@ func (s *ServerService) UpdateXray(version string) error {
}
func (s *ServerService) GetLogs(count string) ([]string, error) {
// Define the journalctl command and its arguments
func (s *ServerService) GetLogs(count string, logLevel string) ([]string, error) {
var cmdArgs []string
if runtime.GOOS == "linux" {
cmdArgs = []string{"journalctl", "-u", "x-ui", "--no-pager", "-n", count}
if logLevel != "" {
cmdArgs = append(cmdArgs, "-p", logLevel)
}
} else {
return []string{"Unsupported operating system"}, nil
}
// Run the command
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
var out bytes.Buffer
cmd.Stdout = &out