13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/rails_dev_mcp/tools/dev_server_logs.rb', line 13
def call(lines: nil, notable_only: nil)
lines ||= 50
notable_only ||= false
unless RailsDevMCP.server_process
process = ProcessManager.new(rails_root: RailsDevMCP.rails_root)
result = process.logs(lines: lines)
else
result = RailsDevMCP.server_process.logs(lines: lines)
end
if result[:success]
log(:debug, "Retrieved #{lines} log lines")
if notable_only && result[:notable_events].to_s.strip.length > 0
<<~LOGS
📋 Notable events from Rails server logs:
#{result[:notable_events]}
Log file: #{result[:log_file]}
LOGS
elsif result[:full_logs].to_s.strip.length > 0
<<~LOGS
📋 Rails server logs (last #{lines} lines):
#{result[:full_logs]}
Log file: #{result[:log_file]}
LOGS
else
"📋 No logs available yet. The server may have just started."
end
else
log(:error, "Failed to retrieve logs: #{result[:error]}")
"❌ Failed to retrieve logs: #{result[:error]}"
end
end
|