Skip to content

Commit

Permalink
Fix issue with detect log file for stream (#272)
Browse files Browse the repository at this point in the history
- Fixed an issue where we would not be able to detect the file location for the logs and therefor not stream it
  • Loading branch information
cjlapao authored Jan 13, 2025
1 parent a158857 commit 4eb8fc4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/controllers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,12 @@ func GetSystemLogs() restapi.ControllerHandler {

cfg := config.Get()

// If logging to file is enabled, register the logs endpoints
if cfg.GetBoolKey(constants.LOG_TO_FILE_ENV_VAR) {
// Checking if we have the logs to file enabled so we can read the logs
if !cfg.GetBoolKey(constants.LOG_TO_FILE_ENV_VAR) {
err := errors.New("logs to file is not enabled, we cannot read the logs")
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "Failed to read log file: " + err.Error(),
Code: http.StatusInternalServerError,
Code: http.StatusBadRequest,
})
return
}
Expand All @@ -440,7 +440,7 @@ func GetSystemLogs() restapi.ControllerHandler {
if err != nil {
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "Failed to read log file: " + err.Error(),
Code: http.StatusInternalServerError,
Code: http.StatusBadRequest,
})
return
}
Expand Down Expand Up @@ -500,7 +500,8 @@ func StreamSystemLogs() restapi.ControllerHandler {
// Get log file path
cfg := config.Get()

if cfg.GetBoolKey(constants.LOG_TO_FILE_ENV_VAR) {
// Checking if we have the logs to file enabled so we can read the logs
if !cfg.GetBoolKey(constants.LOG_TO_FILE_ENV_VAR) {
ws.WriteMessage(websocket.TextMessage, []byte("Logs to file is not enabled, we cannot read the logs"))
ws.Close()
return
Expand Down

0 comments on commit 4eb8fc4

Please sign in to comment.