@@ -89,6 +89,18 @@ def build_parser() -> argparse.ArgumentParser:
8989 help = "Check whether file(s) is/are already published." ,
9090 )
9191
92+ # Verbosity options (mutually exclusive)
93+ verbosity_group = parser .add_mutually_exclusive_group ()
94+ verbosity_group .add_argument (
95+ "-v" , "--verbose" , action = "store_true" , help = "Enable verbose output (DEBUG level)"
96+ )
97+ verbosity_group .add_argument (
98+ "-q" ,
99+ "--quiet" ,
100+ action = "store_true" ,
101+ help = "Quiet mode (show only warnings and errors)" ,
102+ )
103+
92104 # Provide -help to mirror legacy behavior (in addition to -h and --help)
93105 parser .add_argument (
94106 "-h" ,
@@ -315,20 +327,23 @@ def print_can_file_be_downloaded(file_can_be_downloaded: bool):
315327 logger .info ("%sFile is not (yet) available for download." , INDENT )
316328
317329
318- def configure_logging () -> None :
330+ def configure_logging (log_level : int = logging . INFO ) -> None :
319331 """Configure logging to send INFO/WARNING to stdout and ERROR/CRITICAL to stderr.
320332
321333 Sets up two handlers:
322- - INFO handler: Sends INFO and WARNING level messages to stdout
334+ - INFO handler: Sends INFO, WARNING, and DEBUG level messages to stdout
323335 - ERROR handler: Sends ERROR and CRITICAL level messages to stderr
324336
325337 Both handlers use simple message-only formatting without timestamps or level names.
338+
339+ Args:
340+ log_level: Minimum logging level (DEBUG, INFO, or WARNING). Default is INFO.
326341 """
327- logger .setLevel (logging . INFO )
342+ logger .setLevel (log_level )
328343
329- # Handler for INFO and WARNING level messages -> stdout
344+ # Handler for INFO, WARNING, and DEBUG level messages -> stdout
330345 info_handler = logging .StreamHandler (sys .stdout )
331- info_handler .setLevel (logging .INFO )
346+ info_handler .setLevel (logging .DEBUG ) # Accept all levels, filter will handle it
332347 info_handler .addFilter (lambda record : record .levelno < logging .ERROR )
333348 info_handler .setFormatter (logging .Formatter ("%(message)s" ))
334349
@@ -365,11 +380,13 @@ def main(argv: List[str] | None = None) -> int:
365380 1: One or more files failed to stage (errors printed to stderr).
366381 2: Fatal error (missing inputdata directory, missing file list, etc.).
367382 """
368- configure_logging ()
369-
370383 parser = build_parser ()
371384 args = parser .parse_args (argv )
372385
386+ # Configure logging based on verbosity flags
387+ log_level = shared .get_log_level (quiet = args .quiet , verbose = args .verbose )
388+ configure_logging (log_level )
389+
373390 # Ensure we are running as the STAGE_OWNER account before touching the tree
374391 # Set env var RIMPORT_SKIP_USER_CHECK=1 if you prefer to run `sudox -u STAGE_OWNER rimport …`
375392 # explicitly (or for testing).
0 commit comments