Fix logs endpoint
This commit is contained in:
@@ -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) {
|
func (l *Logger) GetLogsFromFile() (string, error) {
|
||||||
file, err := os.Open(l.logPath)
|
file, err := os.Open(l.logPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
var buffer bytes.Buffer
|
|
||||||
_, err = io.Copy(&buffer, file)
|
data, err := io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
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) {
|
func (l *Logger) UploadLogFile() (string, error) {
|
||||||
file, err := os.Open(l.logPath)
|
file, err := os.Open(l.logPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user