Class: Mbeditor::LogsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mbeditor/logs_controller.rb

Instance Method Summary collapse

Instance Method Details

#tailObject

GET /logs/tail Reads the active environment's log file incrementally. Used for the initial load (no offset) and as the HTTP polling fallback (with offset).



8
9
10
11
12
13
14
# File 'app/controllers/mbeditor/logs_controller.rb', line 8

def tail
  # Clamped: a negative offset reaches IO#seek and raises Errno::EINVAL,
  # which surfaced as a 500 on a param the client fully controls.
  offset = params[:offset].present? ? [params[:offset].to_i, 0].max : nil
  result = LogTailService.new(log_path).read_since(offset)
  render json: result
end