@@ -582,18 +582,19 @@ def parse_args():
582
582
return args
583
583
584
584
585
- def setup_logging (log_directory : Path ):
585
+ def setup_logging (log_directory : Path , select_output : str | None ):
586
586
"""Setup logging to stderr if run by a human, or to a file if run from a cron."""
587
+ log_format = "%(asctime)s %(levelname)s: %(message)s"
587
588
if sys .stderr .isatty ():
588
- logging .basicConfig (
589
- format = "%(asctime)s %(levelname)s: %(message)s" , stream = sys .stderr
590
- )
589
+ logging .basicConfig (format = log_format , stream = sys .stderr )
591
590
else :
592
591
log_directory .mkdir (parents = True , exist_ok = True )
593
- handler = logging .handlers .WatchedFileHandler (log_directory / "docsbuild.log" )
594
- handler .setFormatter (
595
- logging .Formatter ("%(asctime)s %(levelname)s: %(message)s" )
596
- )
592
+ if select_output is None :
593
+ filename = log_directory / "docsbuild.log"
594
+ else :
595
+ filename = log_directory / f"docsbuild-{ select_output } .log"
596
+ handler = logging .handlers .WatchedFileHandler (filename )
597
+ handler .setFormatter (logging .Formatter (log_format ))
597
598
logging .getLogger ().addHandler (handler )
598
599
logging .getLogger ().setLevel (logging .DEBUG )
599
600
@@ -1221,7 +1222,7 @@ def _checkout_name(select_output: str | None) -> str:
1221
1222
def main ():
1222
1223
"""Script entry point."""
1223
1224
args = parse_args ()
1224
- setup_logging (args .log_directory )
1225
+ setup_logging (args .log_directory , args . select_output )
1225
1226
1226
1227
if args .select_output is None :
1227
1228
build_docs_with_lock (args , "build_docs.lock" )
0 commit comments