Fix logs endpoint

This commit is contained in:
Ben Sarmiento
2024-02-04 21:25:19 +01:00
parent 00d6100323
commit 306d415acc

View File

@@ -103,21 +103,23 @@ func (l *Logger) Named(name string) *Logger {
}
}
// GetLogsFromFile opens the file at l.logPath, reads its contents, and returns them as a string.
func (l *Logger) GetLogsFromFile() (string, error) {
file, err := os.Open(l.logPath)
if err != nil {
return "", err
}
defer file.Close()
var buffer bytes.Buffer
_, err = io.Copy(&buffer, file)
data, err := io.ReadAll(file)
if err != nil {
return "", err
}
return buffer.String(), nil
return string(data), nil
}
// UploadLogFile opens the file at l.logPath, uploads it to 0x0.st, and returns the URL of the uploaded file.
func (l *Logger) UploadLogFile() (string, error) {
file, err := os.Open(l.logPath)
if err != nil {