@@ -231,17 +231,18 @@ def run(scenario_file: str, additional_args: tuple[str]):
231
231
232
232
233
233
@click .command ()
234
- @click .argument ("pod_name" , type = str , default = "" )
235
- @click .option ("--follow" , "-f" , is_flag = True , default = False , help = "Follow logs" )
236
- def logs (pod_name : str , follow : bool ):
237
- """Show the logs of a pod"""
234
+ @click .argument ("pod_name" , type = str , required = False )
235
+ @click .option ("--follow" , "-f" , is_flag = True , default = False , help = "Follow logs in real-time" )
236
+ @click .option ("--grep" , "-g" , type = str , required = False , help = "Pattern to grep for in logs" )
237
+ def logs (pod_name : str = "" , follow : bool = False , grep : str = "" ):
238
+ """Show the logs of a Kubernetes pod, optionally filtering by a grep pattern."""
238
239
follow_flag = "--follow" if follow else ""
239
240
namespace = get_default_namespace ()
240
241
241
242
if pod_name :
242
243
try :
243
244
command = f"kubectl logs pod/{ pod_name } -n { namespace } { follow_flag } "
244
- stream_command (command )
245
+ stream_command (command , grep )
245
246
return
246
247
except Exception as e :
247
248
print (f"Could not find the pod { pod_name } : { e } " )
@@ -270,7 +271,7 @@ def logs(pod_name: str, follow: bool):
270
271
pod_name = selected ["pod" ]
271
272
try :
272
273
command = f"kubectl logs pod/{ pod_name } -n { namespace } { follow_flag } "
273
- stream_command (command )
274
+ stream_command (command , grep )
274
275
except Exception as e :
275
276
print (f"Please consider waiting for the pod to become available. Encountered: { e } " )
276
277
else :
0 commit comments