prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Make roundcube log to the console
  Roundcube is currently hard to debug because it logs into a special folder (/var/www/html/logs). It should log to stdout/stderr instead.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `webmails/roundcube/start.py`
  Content:
  ```
  1 #!/usr/bin/python3
  2 
  3 import os
  4 import logging as log
  5 import sys
  6 from socrate import conf
  7 
  8 log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
  9 
  10 os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576))
  11 
  12 conf.jinja("/php.ini", os.environ, "/usr/local/etc/php/conf.d/roundcube.ini")
  13 
  14 # Fix some permissions
  15 os.system("mkdir -p /data/gpg")
  16 os.system("chown -R www-data:www-data /data")
  17 
  18 # Run apache
  19 os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
  20
  ```
  --- 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/webmails/roundcube/start.py b/webmails/roundcube/start.py
  --- a/webmails/roundcube/start.py
  +++ b/webmails/roundcube/start.py
  @@ -4,16 +4,61 @@
   import logging as log
   import sys
   from socrate import conf
  +import subprocess
   
   log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
   
   os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576))
   
  +db_flavor=os.environ.get("ROUNDCUBE_DB_FLAVOR",os.environ.get("DB_FLAVOR","sqlite"))
  +if db_flavor=="sqlite":
  +    os.environ["DB_DSNW"]="sqlite:////data/roundcube.db"
  +elif db_flavor=="mysql":
  +    os.environ["DB_DSNW"]="mysql://%s:%s@%s/%s" % (
  +        os.environ.get("ROUNDCUBE_DB_USER","roundcube"),
  +        os.environ.get("ROUNDCUBE_DB_PW"),
  +        os.environ.get("ROUNDCUBE_DB_HOST",os.environ.get("DB_HOST","database")),
  +        os.environ.get("ROUNDCUBE_DB_NAME","roundcube")
  +        )
  +elif db_flavor=="postgresql":
  +    os.environ["DB_DSNW"]="pgsql://%s:%s@%s/%s" % (
  +        os.environ.get("ROUNDCUBE_DB_USER","roundcube"),
  +        os.environ.get("ROUNDCUBE_DB_PW"),
  +        os.environ.get("ROUNDCUBE_DB_HOST",os.environ.get("DB_HOST","database")),
  +        os.environ.get("ROUNDCUBE_DB_NAME","roundcube")
  +        )
  +else:
  +    print("Unknown ROUNDCUBE_DB_FLAVOR: %s",db_flavor)
  +    exit(1)
  +
  +
  +
   conf.jinja("/php.ini", os.environ, "/usr/local/etc/php/conf.d/roundcube.ini")
   
   # Fix some permissions
  -os.system("mkdir -p /data/gpg")
  -os.system("chown -R www-data:www-data /data")
  +os.system("mkdir -p /data/gpg /var/www/html/logs")
  +os.system("touch /var/www/html/logs/errors")
  +os.system("chown -R www-data:www-data /data /var/www/html/logs")
  +
  +try:
  +    print("Initializing database")
  +    result=subprocess.check_output(["/var/www/html/bin/initdb.sh","--dir","/var/www/html/SQL"],stderr=subprocess.STDOUT)
  +    print(result.decode())
  +except subprocess.CalledProcessError as e:
  +    if "already exists" in e.stdout.decode():
  +        print("Already initialzed")
  +    else:
  +        print(e.stdout.decode())
  +        quit(1)
  +
  +try:
  +    print("Upgrading database")
  +    subprocess.check_call(["/var/www/html/bin/update.sh","--version=?","-y"],stderr=subprocess.STDOUT)
  +except subprocess.CalledProcessError as e:
  +    quit(1)
  +
  +# Tail roundcube logs
  +subprocess.Popen(["tail","-f","-n","0","/var/www/html/logs/errors"])
   
   # Run apache
   os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
  
verification_info: {"golden_diff": "diff --git a/webmails/roundcube/start.py b/webmails/roundcube/start.py\n--- a/webmails/roundcube/start.py\n+++ b/webmails/roundcube/start.py\n@@ -4,16 +4,61 @@\n import logging as log\n import sys\n from socrate import conf\n+import subprocess\n \n log.basicConfig(stream=sys.stderr, level=os.environ.get(\"LOG_LEVEL\", \"WARNING\"))\n \n os.environ[\"MAX_FILESIZE\"] = str(int(int(os.environ.get(\"MESSAGE_SIZE_LIMIT\"))*0.66/1048576))\n \n+db_flavor=os.environ.get(\"ROUNDCUBE_DB_FLAVOR\",os.environ.get(\"DB_FLAVOR\",\"sqlite\"))\n+if db_flavor==\"sqlite\":\n+    os.environ[\"DB_DSNW\"]=\"sqlite:////data/roundcube.db\"\n+elif db_flavor==\"mysql\":\n+    os.environ[\"DB_DSNW\"]=\"mysql://%s:%s@%s/%s\" % (\n+        os.environ.get(\"ROUNDCUBE_DB_USER\",\"roundcube\"),\n+        os.environ.get(\"ROUNDCUBE_DB_PW\"),\n+        os.environ.get(\"ROUNDCUBE_DB_HOST\",os.environ.get(\"DB_HOST\",\"database\")),\n+        os.environ.get(\"ROUNDCUBE_DB_NAME\",\"roundcube\")\n+        )\n+elif db_flavor==\"postgresql\":\n+    os.environ[\"DB_DSNW\"]=\"pgsql://%s:%s@%s/%s\" % (\n+        os.environ.get(\"ROUNDCUBE_DB_USER\",\"roundcube\"),\n+        os.environ.get(\"ROUNDCUBE_DB_PW\"),\n+        os.environ.get(\"ROUNDCUBE_DB_HOST\",os.environ.get(\"DB_HOST\",\"database\")),\n+        os.environ.get(\"ROUNDCUBE_DB_NAME\",\"roundcube\")\n+        )\n+else:\n+    print(\"Unknown ROUNDCUBE_DB_FLAVOR: %s\",db_flavor)\n+    exit(1)\n+\n+\n+\n conf.jinja(\"/php.ini\", os.environ, \"/usr/local/etc/php/conf.d/roundcube.ini\")\n \n # Fix some permissions\n-os.system(\"mkdir -p /data/gpg\")\n-os.system(\"chown -R www-data:www-data /data\")\n+os.system(\"mkdir -p /data/gpg /var/www/html/logs\")\n+os.system(\"touch /var/www/html/logs/errors\")\n+os.system(\"chown -R www-data:www-data /data /var/www/html/logs\")\n+\n+try:\n+    print(\"Initializing database\")\n+    result=subprocess.check_output([\"/var/www/html/bin/initdb.sh\",\"--dir\",\"/var/www/html/SQL\"],stderr=subprocess.STDOUT)\n+    print(result.decode())\n+except subprocess.CalledProcessError as e:\n+    if \"already exists\" in e.stdout.decode():\n+        print(\"Already initialzed\")\n+    else:\n+        print(e.stdout.decode())\n+        quit(1)\n+\n+try:\n+    print(\"Upgrading database\")\n+    subprocess.check_call([\"/var/www/html/bin/update.sh\",\"--version=?\",\"-y\"],stderr=subprocess.STDOUT)\n+except subprocess.CalledProcessError as e:\n+    quit(1)\n+\n+# Tail roundcube logs\n+subprocess.Popen([\"tail\",\"-f\",\"-n\",\"0\",\"/var/www/html/logs/errors\"])\n \n # Run apache\n os.execv(\"/usr/local/bin/apache2-foreground\", [\"apache2-foreground\"])\n", "issue": "Make roundcube log to the console\nRoundcube is currently hard to debug because it logs into a special folder (/var/www/html/logs). It should log to stdout/stderr instead.\n", "before_files": [{"content": "#!/usr/bin/python3\n\nimport os\nimport logging as log\nimport sys\nfrom socrate import conf\n\nlog.basicConfig(stream=sys.stderr, level=os.environ.get(\"LOG_LEVEL\", \"WARNING\"))\n\nos.environ[\"MAX_FILESIZE\"] = str(int(int(os.environ.get(\"MESSAGE_SIZE_LIMIT\"))*0.66/1048576))\n\nconf.jinja(\"/php.ini\", os.environ, \"/usr/local/etc/php/conf.d/roundcube.ini\")\n\n# Fix some permissions\nos.system(\"mkdir -p /data/gpg\")\nos.system(\"chown -R www-data:www-data /data\")\n\n# Run apache\nos.execv(\"/usr/local/bin/apache2-foreground\", [\"apache2-foreground\"])\n", "path": "webmails/roundcube/start.py"}], "after_files": [{"content": "#!/usr/bin/python3\n\nimport os\nimport logging as log\nimport sys\nfrom socrate import conf\nimport subprocess\n\nlog.basicConfig(stream=sys.stderr, level=os.environ.get(\"LOG_LEVEL\", \"WARNING\"))\n\nos.environ[\"MAX_FILESIZE\"] = str(int(int(os.environ.get(\"MESSAGE_SIZE_LIMIT\"))*0.66/1048576))\n\ndb_flavor=os.environ.get(\"ROUNDCUBE_DB_FLAVOR\",os.environ.get(\"DB_FLAVOR\",\"sqlite\"))\nif db_flavor==\"sqlite\":\n    os.environ[\"DB_DSNW\"]=\"sqlite:////data/roundcube.db\"\nelif db_flavor==\"mysql\":\n    os.environ[\"DB_DSNW\"]=\"mysql://%s:%s@%s/%s\" % (\n        os.environ.get(\"ROUNDCUBE_DB_USER\",\"roundcube\"),\n        os.environ.get(\"ROUNDCUBE_DB_PW\"),\n        os.environ.get(\"ROUNDCUBE_DB_HOST\",os.environ.get(\"DB_HOST\",\"database\")),\n        os.environ.get(\"ROUNDCUBE_DB_NAME\",\"roundcube\")\n        )\nelif db_flavor==\"postgresql\":\n    os.environ[\"DB_DSNW\"]=\"pgsql://%s:%s@%s/%s\" % (\n        os.environ.get(\"ROUNDCUBE_DB_USER\",\"roundcube\"),\n        os.environ.get(\"ROUNDCUBE_DB_PW\"),\n        os.environ.get(\"ROUNDCUBE_DB_HOST\",os.environ.get(\"DB_HOST\",\"database\")),\n        os.environ.get(\"ROUNDCUBE_DB_NAME\",\"roundcube\")\n        )\nelse:\n    print(\"Unknown ROUNDCUBE_DB_FLAVOR: %s\",db_flavor)\n    exit(1)\n\n\n\nconf.jinja(\"/php.ini\", os.environ, \"/usr/local/etc/php/conf.d/roundcube.ini\")\n\n# Fix some permissions\nos.system(\"mkdir -p /data/gpg /var/www/html/logs\")\nos.system(\"touch /var/www/html/logs/errors\")\nos.system(\"chown -R www-data:www-data /data /var/www/html/logs\")\n\ntry:\n    print(\"Initializing database\")\n    result=subprocess.check_output([\"/var/www/html/bin/initdb.sh\",\"--dir\",\"/var/www/html/SQL\"],stderr=subprocess.STDOUT)\n    print(result.decode())\nexcept subprocess.CalledProcessError as e:\n    if \"already exists\" in e.stdout.decode():\n        print(\"Already initialzed\")\n    else:\n        print(e.stdout.decode())\n        quit(1)\n\ntry:\n    print(\"Upgrading database\")\n    subprocess.check_call([\"/var/www/html/bin/update.sh\",\"--version=?\",\"-y\"],stderr=subprocess.STDOUT)\nexcept subprocess.CalledProcessError as e:\n    quit(1)\n\n# Tail roundcube logs\nsubprocess.Popen([\"tail\",\"-f\",\"-n\",\"0\",\"/var/www/html/logs/errors\"])\n\n# Run apache\nos.execv(\"/usr/local/bin/apache2-foreground\", [\"apache2-foreground\"])\n", "path": "webmails/roundcube/start.py"}]}