Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with detect log file for stream #272

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading