Add logging flags to the devel server

This commit is contained in:
John Donaldson 2019-10-30 15:40:36 +00:00
parent 08bba4fa64
commit 107aa5e736
1 changed files with 13 additions and 1 deletions

View File

@ -265,12 +265,24 @@ if __name__ == '__main__':
'--base', default="",
help="Base URL to this server, for reverse proxy setup"
)
parser.add_argument(
"-v", "--verbose",
action="count",
default=1, # Leave at 1, for now, to maintain current default behavior
help="Include more verbose logging. Use multiple flags to increase level",
)
args = parser.parse_args()
parts = args.bind.split(":")
addr = parts[0] or "0.0.0.0"
port = int(parts[1])
if args.verbose >= 2:
log_level = logging.DEBUG
elif args.verbose == 1:
log_level = logging.INFO
else:
log_level = logging.WARNING
logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=log_level)
server = MothServer((addr, port), MothRequestHandler)
server.args["base_url"] = args.base