prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Make access logging of admin server dependent on log level
  Currently, admin logs all access logs to the console, regardless of which log level is set.
  This is caused by starting gunicorn with `--access-logfile -`. This should be switched dependent on the log level set, e.g. on for levels >= INFO and off for <=WARNING
   
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `core/admin/start.py`
  Content:
  ```
  1 #!/usr/bin/python3
  2 
  3 import os
  4 
  5 os.system("flask mailu advertise")
  6 os.system("flask db upgrade")
  7 
  8 account = os.environ.get("INITIAL_ADMIN_ACCOUNT")
  9 domain = os.environ.get("INITIAL_ADMIN_DOMAIN")
  10 password = os.environ.get("INITIAL_ADMIN_PW")
  11 
  12 if account is not None and domain is not None and password is not None:
  13     mode = os.environ.get("INITIAL_ADMIN_MODE", default="ifmissing")
  14     os.system("flask mailu admin %s %s '%s' --mode %s" % (account, domain, password, mode))
  15 
  16 os.system("gunicorn -w 4 -b :80 --access-logfile - --error-logfile - --preload 'mailu:create_app()'")
  17
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/core/admin/start.py b/core/admin/start.py
  --- a/core/admin/start.py
  +++ b/core/admin/start.py
  @@ -1,6 +1,10 @@
   #!/usr/bin/python3
   
   import os
  +import logging as log
  +import sys
  +
  +log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "INFO"))
   
   os.system("flask mailu advertise")
   os.system("flask db upgrade")
  @@ -11,6 +15,14 @@
   
   if account is not None and domain is not None and password is not None:
       mode = os.environ.get("INITIAL_ADMIN_MODE", default="ifmissing")
  +    log.info("Creating initial admin accout %s@%s with mode %s",account,domain,mode)
       os.system("flask mailu admin %s %s '%s' --mode %s" % (account, domain, password, mode))
   
  -os.system("gunicorn -w 4 -b :80 --access-logfile - --error-logfile - --preload 'mailu:create_app()'")
  +start_command="".join([
  +    "gunicorn -w 4 -b :80 ",
  +    "--access-logfile - " if (log.root.level<=log.INFO) else "",
  +    "--error-logfile - ",
  +    "--preload ",
  +    "'mailu:create_app()'"])
  +
  +os.system(start_command)
  
verification_info: {"golden_diff": "diff --git a/core/admin/start.py b/core/admin/start.py\n--- a/core/admin/start.py\n+++ b/core/admin/start.py\n@@ -1,6 +1,10 @@\n #!/usr/bin/python3\n \n import os\n+import logging as log\n+import sys\n+\n+log.basicConfig(stream=sys.stderr, level=os.environ.get(\"LOG_LEVEL\", \"INFO\"))\n \n os.system(\"flask mailu advertise\")\n os.system(\"flask db upgrade\")\n@@ -11,6 +15,14 @@\n \n if account is not None and domain is not None and password is not None:\n     mode = os.environ.get(\"INITIAL_ADMIN_MODE\", default=\"ifmissing\")\n+    log.info(\"Creating initial admin accout %s@%s with mode %s\",account,domain,mode)\n     os.system(\"flask mailu admin %s %s '%s' --mode %s\" % (account, domain, password, mode))\n \n-os.system(\"gunicorn -w 4 -b :80 --access-logfile - --error-logfile - --preload 'mailu:create_app()'\")\n+start_command=\"\".join([\n+    \"gunicorn -w 4 -b :80 \",\n+    \"--access-logfile - \" if (log.root.level<=log.INFO) else \"\",\n+    \"--error-logfile - \",\n+    \"--preload \",\n+    \"'mailu:create_app()'\"])\n+\n+os.system(start_command)\n", "issue": "Make access logging of admin server dependent on log level\nCurrently, admin logs all access logs to the console, regardless of which log level is set.\r\nThis is caused by starting gunicorn with `--access-logfile -`. This should be switched dependent on the log level set, e.g. on for levels >= INFO and off for <=WARNING\r\n \n", "before_files": [{"content": "#!/usr/bin/python3\n\nimport os\n\nos.system(\"flask mailu advertise\")\nos.system(\"flask db upgrade\")\n\naccount = os.environ.get(\"INITIAL_ADMIN_ACCOUNT\")\ndomain = os.environ.get(\"INITIAL_ADMIN_DOMAIN\")\npassword = os.environ.get(\"INITIAL_ADMIN_PW\")\n\nif account is not None and domain is not None and password is not None:\n    mode = os.environ.get(\"INITIAL_ADMIN_MODE\", default=\"ifmissing\")\n    os.system(\"flask mailu admin %s %s '%s' --mode %s\" % (account, domain, password, mode))\n\nos.system(\"gunicorn -w 4 -b :80 --access-logfile - --error-logfile - --preload 'mailu:create_app()'\")\n", "path": "core/admin/start.py"}], "after_files": [{"content": "#!/usr/bin/python3\n\nimport os\nimport logging as log\nimport sys\n\nlog.basicConfig(stream=sys.stderr, level=os.environ.get(\"LOG_LEVEL\", \"INFO\"))\n\nos.system(\"flask mailu advertise\")\nos.system(\"flask db upgrade\")\n\naccount = os.environ.get(\"INITIAL_ADMIN_ACCOUNT\")\ndomain = os.environ.get(\"INITIAL_ADMIN_DOMAIN\")\npassword = os.environ.get(\"INITIAL_ADMIN_PW\")\n\nif account is not None and domain is not None and password is not None:\n    mode = os.environ.get(\"INITIAL_ADMIN_MODE\", default=\"ifmissing\")\n    log.info(\"Creating initial admin accout %s@%s with mode %s\",account,domain,mode)\n    os.system(\"flask mailu admin %s %s '%s' --mode %s\" % (account, domain, password, mode))\n\nstart_command=\"\".join([\n    \"gunicorn -w 4 -b :80 \",\n    \"--access-logfile - \" if (log.root.level<=log.INFO) else \"\",\n    \"--error-logfile - \",\n    \"--preload \",\n    \"'mailu:create_app()'\"])\n\nos.system(start_command)\n", "path": "core/admin/start.py"}]}