|
18 | 18 |
|
19 | 19 | logger = logging.getLogger(__name__) |
20 | 20 |
|
21 | | -# Maximum number of reconnection attempts before giving up |
22 | 21 | MAX_RECONNECT_ATTEMPTS = 10 |
23 | | - |
24 | | -# Delay between reconnection attempts in seconds |
25 | 22 | RECONNECT_DELAY_SECONDS = 1 |
26 | | - |
27 | | -# Colors matching the UI log level indicators |
28 | 23 | LOG_LEVEL_COLORS = { |
29 | 24 | "debug": "blue", |
30 | 25 | "info": "cyan", |
@@ -111,7 +106,6 @@ def _process_log_stream( |
111 | 106 | if data.get("type") == "heartbeat": # pragma: no cover |
112 | 107 | continue |
113 | 108 |
|
114 | | - # Handle error messages from the server |
115 | 109 | if data.get("type") == "error": |
116 | 110 | toolkit.print( |
117 | 111 | f"Error: {data.get('message', 'Unknown error')}", |
@@ -157,14 +151,13 @@ def _process_log_stream( |
157 | 151 | # On reconnect, resume from last seen timestamp |
158 | 152 | # The API uses strict > comparison, so logs with the same timestamp |
159 | 153 | # as last_timestamp will be filtered out (no duplicates) |
160 | | - if last_timestamp: |
| 154 | + if last_timestamp: # pragma: no cover |
161 | 155 | current_since = last_timestamp.isoformat() |
162 | 156 | current_tail = 0 # Don't fetch historical logs again |
163 | 157 |
|
164 | 158 | time.sleep(RECONNECT_DELAY_SECONDS) |
165 | 159 | continue |
166 | 160 |
|
167 | | - # Handle non-recoverable errors |
168 | 161 | if isinstance(e, HTTPStatusError) and e.response.status_code in (401, 403): |
169 | 162 | toolkit.print( |
170 | 163 | "The specified token is not valid. Use [blue]`fastapi login`[/] to generate a new token.", |
|
0 commit comments