@@ -170,22 +170,23 @@ def get_deployment_log(args):
170
170
exit (1 )
171
171
172
172
to_timestamp = datetime .now ()
173
- from_timestamp = ( to_timestamp - timedelta (seconds = args .duration ) )
173
+ from_timestamp = to_timestamp - timedelta (seconds = args .duration )
174
174
last_log_timestamp = from_timestamp
175
- log_ids = set () # to avoid duplicate logs
175
+ log_ids = set () # to avoid duplicate logs
176
176
max_entries = args .tail
177
177
while True :
178
178
status_code , msg = deploymentapi .get_deployment_log (
179
- api_key , args .deployment_name , from_timestamp , to_timestamp , max_entries )
179
+ api_key , args .deployment_name , from_timestamp , to_timestamp , max_entries
180
+ )
180
181
if status_code != 200 :
181
182
print (f"{ status_code } : { msg } " )
182
183
exit (status_code )
183
184
184
- for log in msg [::- 1 ]: # logs are sorted by reversed timestamp
185
+ for log in msg [::- 1 ]: # logs are sorted by reversed timestamp
185
186
log_timestamp = datetime .fromisoformat (log ["timestamp" ]).replace (tzinfo = None )
186
- if (log [' insert_id' ] in log_ids ) or (log_timestamp < last_log_timestamp ):
187
+ if (log [" insert_id" ] in log_ids ) or (log_timestamp < last_log_timestamp ):
187
188
continue
188
- log_ids .add (log [' insert_id' ])
189
+ log_ids .add (log [" insert_id" ])
189
190
last_log_timestamp = log_timestamp
190
191
print (f'[{ log_timestamp .strftime ("%Y-%m-%d %H:%M:%S.%f" )} ] { log ["payload" ]} ' )
191
192
@@ -195,5 +196,4 @@ def get_deployment_log(args):
195
196
time .sleep (10 )
196
197
from_timestamp = last_log_timestamp
197
198
to_timestamp = datetime .now ()
198
- max_entries = 300 # only set max_entries for the first request
199
-
199
+ max_entries = 300 # only set max_entries for the first request
0 commit comments