Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aec0ed0

Browse files
committed
Move logging setup in own function.
1 parent 0263ea1 commit aec0ed0

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

build_docs.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,17 @@ def parse_args():
516516
return parser.parse_args()
517517

518518

519+
def setup_logging(log_directory):
520+
if sys.stderr.isatty():
521+
logging.basicConfig(format="%(levelname)s:%(message)s", stream=sys.stderr)
522+
else:
523+
logging.basicConfig(
524+
format="%(levelname)s:%(asctime)s:%(message)s",
525+
filename=os.path.join(log_directory, "docsbuild.log"),
526+
)
527+
logging.root.setLevel(logging.DEBUG)
528+
529+
519530
def main():
520531
args = parse_args()
521532
if args.version:
@@ -527,14 +538,7 @@ def main():
527538
args.build_root = os.path.abspath(args.build_root)
528539
if args.www_root:
529540
args.www_root = os.path.abspath(args.www_root)
530-
if sys.stderr.isatty():
531-
logging.basicConfig(format="%(levelname)s:%(message)s", stream=sys.stderr)
532-
else:
533-
logging.basicConfig(
534-
format="%(levelname)s:%(asctime)s:%(message)s",
535-
filename=os.path.join(args.log_directory, "docsbuild.log"),
536-
)
537-
logging.root.setLevel(logging.DEBUG)
541+
setup_logging(args.log_directory)
538542
venv = os.path.join(args.build_root, "venv")
539543
if args.branch:
540544
branches_to_do = [

0 commit comments

Comments
 (0)