We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Docker] DEFAULT_ROOT_PATH should be created if it does not exist
I have tried to run opsdroid in a Docker container, in the following environment:

```
OS: Ubuntu 16.04.3 LTS
Docker version: 17.06.2-ce
Docker API version: 1.30
```

The process I followed is the following:

1. `docker pull opsdroid/opsdroid:latest`
2. Created an initial configuration in the host: `/var/tmp/configuration.yaml`
3. Ran the following command: ` docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest`

The configuration file contents are:
```
connectors:
  - name: shell

skills:
  - name: hello
```

But I got the following error:

```
ubuntu@ubuntu:~$ docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/opsdroid/__main__.py", line 112, in <module>
    main()
  File "/usr/src/app/opsdroid/__main__.py", line 105, in main
    configure_logging(opsdroid.config)
  File "/usr/src/app/opsdroid/__main__.py", line 51, in configure_logging
    file_handler = logging.FileHandler(logfile_path)
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1014, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1043, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'
ubuntu@ubuntu:~$
```

When running the container in interactive mode to debug the issue, by issuing `docker run -it -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest /bin/sh` and executing the default command (`python -m opsdroid`), I reproduced the issue:

```
/usr/src/app # python -m opsdroid
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/opsdroid/__main__.py", line 112, in <module>
    main()
  File "/usr/src/app/opsdroid/__main__.py", line 105, in main
    configure_logging(opsdroid.config)
  File "/usr/src/app/opsdroid/__main__.py", line 51, in configure_logging
    file_handler = logging.FileHandler(logfile_path)
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1014, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1043, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'
/usr/src/app #
```

When checking if the `/root/.opsdroid/` directory existed, I got the following:
```
/usr/src/app # ls /root/.opsdroid
ls: /root/.opsdroid: No such file or directory
```

Concluding, opsdroid should check if that directory exists and create it if not. 
[Docker] DEFAULT_ROOT_PATH should be created if it does not exist
I have tried to run opsdroid in a Docker container, in the following environment:

```
OS: Ubuntu 16.04.3 LTS
Docker version: 17.06.2-ce
Docker API version: 1.30
```

The process I followed is the following:

1. `docker pull opsdroid/opsdroid:latest`
2. Created an initial configuration in the host: `/var/tmp/configuration.yaml`
3. Ran the following command: ` docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest`

The configuration file contents are:
```
connectors:
  - name: shell

skills:
  - name: hello
```

But I got the following error:

```
ubuntu@ubuntu:~$ docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/opsdroid/__main__.py", line 112, in <module>
    main()
  File "/usr/src/app/opsdroid/__main__.py", line 105, in main
    configure_logging(opsdroid.config)
  File "/usr/src/app/opsdroid/__main__.py", line 51, in configure_logging
    file_handler = logging.FileHandler(logfile_path)
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1014, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1043, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'
ubuntu@ubuntu:~$
```

When running the container in interactive mode to debug the issue, by issuing `docker run -it -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest /bin/sh` and executing the default command (`python -m opsdroid`), I reproduced the issue:

```
/usr/src/app # python -m opsdroid
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/opsdroid/__main__.py", line 112, in <module>
    main()
  File "/usr/src/app/opsdroid/__main__.py", line 105, in main
    configure_logging(opsdroid.config)
  File "/usr/src/app/opsdroid/__main__.py", line 51, in configure_logging
    file_handler = logging.FileHandler(logfile_path)
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1014, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1043, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'
/usr/src/app #
```

When checking if the `/root/.opsdroid/` directory existed, I got the following:
```
/usr/src/app # ls /root/.opsdroid
ls: /root/.opsdroid: No such file or directory
```

Concluding, opsdroid should check if that directory exists and create it if not. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `opsdroid/__main__.py`
Content:
```
1 """Starts opsdroid."""
2 
3 import os
4 import sys
5 import logging
6 import argparse
7 
8 from opsdroid.core import OpsDroid
9 from opsdroid.const import DEFAULT_LOG_FILENAME, EXAMPLE_CONFIG_FILE
10 from opsdroid.web import Web
11 
12 
13 _LOGGER = logging.getLogger("opsdroid")
14 
15 
16 def configure_logging(config):
17     """Configure the root logger based on user config."""
18     rootlogger = logging.getLogger()
19     while rootlogger.handlers:
20         rootlogger.handlers.pop()
21 
22     try:
23         if config["logging"]["path"]:
24             logfile_path = os.path.expanduser(config["logging"]["path"])
25         else:
26             logfile_path = config["logging"]["path"]
27     except KeyError:
28         logfile_path = DEFAULT_LOG_FILENAME
29 
30     try:
31         log_level = get_logging_level(
32             config["logging"]["level"])
33     except KeyError:
34         log_level = logging.INFO
35 
36     rootlogger.setLevel(log_level)
37     formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s')
38 
39     console_handler = logging.StreamHandler()
40     console_handler.setLevel(log_level)
41     console_handler.setFormatter(formatter)
42     rootlogger.addHandler(console_handler)
43 
44     try:
45         if not config["logging"]["console"]:
46             console_handler.setLevel(logging.CRITICAL)
47     except KeyError:
48         pass
49 
50     if logfile_path:
51         file_handler = logging.FileHandler(logfile_path)
52         file_handler.setLevel(log_level)
53         file_handler.setFormatter(formatter)
54         rootlogger.addHandler(file_handler)
55 
56     _LOGGER.info("="*40)
57     _LOGGER.info("Stated application")
58 
59 
60 def get_logging_level(logging_level):
61     """Get the logger level based on the user configuration."""
62     if logging_level == 'critical':
63         return logging.CRITICAL
64     elif logging_level == 'error':
65         return logging.ERROR
66     elif logging_level == 'warning':
67         return logging.WARNING
68     elif logging_level == 'debug':
69         return logging.DEBUG
70 
71     return logging.INFO
72 
73 
74 def parse_args(args):
75     """Parse command line arguments."""
76     parser = argparse.ArgumentParser(description='Run opsdroid.')
77     parser.add_argument('--gen-config', action="store_true",
78                         help='prints out an example configuration file')
79     return parser.parse_args(args)
80 
81 
82 def check_dependencies():
83     """Check for system dependencies required by opsdroid."""
84     if sys.version_info[0] < 3 or sys.version_info[1] < 5:
85         logging.critical("Whoops! opsdroid requires python 3.5 or above.")
86         sys.exit(1)
87 
88 
89 def main():
90     """Enter the application here."""
91     args = parse_args(sys.argv[1:])
92 
93     if args.gen_config:
94         with open(EXAMPLE_CONFIG_FILE, 'r') as conf:
95             print(conf.read())
96         sys.exit(0)
97 
98     check_dependencies()
99 
100     restart = True
101 
102     while restart:
103         with OpsDroid() as opsdroid:
104             opsdroid.load()
105             configure_logging(opsdroid.config)
106             opsdroid.web_server = Web(opsdroid)
107             opsdroid.start_loop()
108             restart = opsdroid.should_restart
109 
110 
111 if __name__ == "__main__":
112     main()
113
```
--- 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()

```

diff --git a/opsdroid/__main__.py b/opsdroid/__main__.py
--- a/opsdroid/__main__.py
+++ b/opsdroid/__main__.py
@@ -48,6 +48,9 @@
         pass
 
     if logfile_path:
+        logdir = os.path.dirname(os.path.realpath(logfile_path))
+        if not os.path.isdir(logdir):
+            os.makedirs(logdir)
         file_handler = logging.FileHandler(logfile_path)
         file_handler.setLevel(log_level)
         file_handler.setFormatter(formatter)

{"golden_diff": "diff --git a/opsdroid/__main__.py b/opsdroid/__main__.py\n--- a/opsdroid/__main__.py\n+++ b/opsdroid/__main__.py\n@@ -48,6 +48,9 @@\n         pass\n \n     if logfile_path:\n+        logdir = os.path.dirname(os.path.realpath(logfile_path))\n+        if not os.path.isdir(logdir):\n+            os.makedirs(logdir)\n         file_handler = logging.FileHandler(logfile_path)\n         file_handler.setLevel(log_level)\n         file_handler.setFormatter(formatter)\n", "issue": "[Docker] DEFAULT_ROOT_PATH should be created if it does not exist\nI have tried to run opsdroid in a Docker container, in the following environment:\r\n\r\n```\r\nOS: Ubuntu 16.04.3 LTS\r\nDocker version: 17.06.2-ce\r\nDocker API version: 1.30\r\n```\r\n\r\nThe process I followed is the following:\r\n\r\n1. `docker pull opsdroid/opsdroid:latest`\r\n2. Created an initial configuration in the host: `/var/tmp/configuration.yaml`\r\n3. Ran the following command: ` docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest`\r\n\r\nThe configuration file contents are:\r\n```\r\nconnectors:\r\n  - name: shell\r\n\r\nskills:\r\n  - name: hello\r\n```\r\n\r\nBut I got the following error:\r\n\r\n```\r\nubuntu@ubuntu:~$ docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 193, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 112, in <module>\r\n    main()\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 105, in main\r\n    configure_logging(opsdroid.config)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 51, in configure_logging\r\n    file_handler = logging.FileHandler(logfile_path)\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1014, in __init__\r\n    StreamHandler.__init__(self, self._open())\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1043, in _open\r\n    return open(self.baseFilename, self.mode, encoding=self.encoding)\r\nFileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'\r\nubuntu@ubuntu:~$\r\n```\r\n\r\nWhen running the container in interactive mode to debug the issue, by issuing `docker run -it -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest /bin/sh` and executing the default command (`python -m opsdroid`), I reproduced the issue:\r\n\r\n```\r\n/usr/src/app # python -m opsdroid\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 193, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 112, in <module>\r\n    main()\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 105, in main\r\n    configure_logging(opsdroid.config)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 51, in configure_logging\r\n    file_handler = logging.FileHandler(logfile_path)\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1014, in __init__\r\n    StreamHandler.__init__(self, self._open())\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1043, in _open\r\n    return open(self.baseFilename, self.mode, encoding=self.encoding)\r\nFileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'\r\n/usr/src/app #\r\n```\r\n\r\nWhen checking if the `/root/.opsdroid/` directory existed, I got the following:\r\n```\r\n/usr/src/app # ls /root/.opsdroid\r\nls: /root/.opsdroid: No such file or directory\r\n```\r\n\r\nConcluding, opsdroid should check if that directory exists and create it if not. \n[Docker] DEFAULT_ROOT_PATH should be created if it does not exist\nI have tried to run opsdroid in a Docker container, in the following environment:\r\n\r\n```\r\nOS: Ubuntu 16.04.3 LTS\r\nDocker version: 17.06.2-ce\r\nDocker API version: 1.30\r\n```\r\n\r\nThe process I followed is the following:\r\n\r\n1. `docker pull opsdroid/opsdroid:latest`\r\n2. Created an initial configuration in the host: `/var/tmp/configuration.yaml`\r\n3. Ran the following command: ` docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest`\r\n\r\nThe configuration file contents are:\r\n```\r\nconnectors:\r\n  - name: shell\r\n\r\nskills:\r\n  - name: hello\r\n```\r\n\r\nBut I got the following error:\r\n\r\n```\r\nubuntu@ubuntu:~$ docker run --rm -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 193, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 112, in <module>\r\n    main()\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 105, in main\r\n    configure_logging(opsdroid.config)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 51, in configure_logging\r\n    file_handler = logging.FileHandler(logfile_path)\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1014, in __init__\r\n    StreamHandler.__init__(self, self._open())\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1043, in _open\r\n    return open(self.baseFilename, self.mode, encoding=self.encoding)\r\nFileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'\r\nubuntu@ubuntu:~$\r\n```\r\n\r\nWhen running the container in interactive mode to debug the issue, by issuing `docker run -it -v /var/tmp/configuration.yaml:/etc/opsdroid/configuration.yaml:ro opsdroid/opsdroid:latest /bin/sh` and executing the default command (`python -m opsdroid`), I reproduced the issue:\r\n\r\n```\r\n/usr/src/app # python -m opsdroid\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 193, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/usr/local/lib/python3.5/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 112, in <module>\r\n    main()\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 105, in main\r\n    configure_logging(opsdroid.config)\r\n  File \"/usr/src/app/opsdroid/__main__.py\", line 51, in configure_logging\r\n    file_handler = logging.FileHandler(logfile_path)\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1014, in __init__\r\n    StreamHandler.__init__(self, self._open())\r\n  File \"/usr/local/lib/python3.5/logging/__init__.py\", line 1043, in _open\r\n    return open(self.baseFilename, self.mode, encoding=self.encoding)\r\nFileNotFoundError: [Errno 2] No such file or directory: '/root/.opsdroid/output.log'\r\n/usr/src/app #\r\n```\r\n\r\nWhen checking if the `/root/.opsdroid/` directory existed, I got the following:\r\n```\r\n/usr/src/app # ls /root/.opsdroid\r\nls: /root/.opsdroid: No such file or directory\r\n```\r\n\r\nConcluding, opsdroid should check if that directory exists and create it if not. \n", "before_files": [{"content": "\"\"\"Starts opsdroid.\"\"\"\n\nimport os\nimport sys\nimport logging\nimport argparse\n\nfrom opsdroid.core import OpsDroid\nfrom opsdroid.const import DEFAULT_LOG_FILENAME, EXAMPLE_CONFIG_FILE\nfrom opsdroid.web import Web\n\n\n_LOGGER = logging.getLogger(\"opsdroid\")\n\n\ndef configure_logging(config):\n    \"\"\"Configure the root logger based on user config.\"\"\"\n    rootlogger = logging.getLogger()\n    while rootlogger.handlers:\n        rootlogger.handlers.pop()\n\n    try:\n        if config[\"logging\"][\"path\"]:\n            logfile_path = os.path.expanduser(config[\"logging\"][\"path\"])\n        else:\n            logfile_path = config[\"logging\"][\"path\"]\n    except KeyError:\n        logfile_path = DEFAULT_LOG_FILENAME\n\n    try:\n        log_level = get_logging_level(\n            config[\"logging\"][\"level\"])\n    except KeyError:\n        log_level = logging.INFO\n\n    rootlogger.setLevel(log_level)\n    formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s')\n\n    console_handler = logging.StreamHandler()\n    console_handler.setLevel(log_level)\n    console_handler.setFormatter(formatter)\n    rootlogger.addHandler(console_handler)\n\n    try:\n        if not config[\"logging\"][\"console\"]:\n            console_handler.setLevel(logging.CRITICAL)\n    except KeyError:\n        pass\n\n    if logfile_path:\n        file_handler = logging.FileHandler(logfile_path)\n        file_handler.setLevel(log_level)\n        file_handler.setFormatter(formatter)\n        rootlogger.addHandler(file_handler)\n\n    _LOGGER.info(\"=\"*40)\n    _LOGGER.info(\"Stated application\")\n\n\ndef get_logging_level(logging_level):\n    \"\"\"Get the logger level based on the user configuration.\"\"\"\n    if logging_level == 'critical':\n        return logging.CRITICAL\n    elif logging_level == 'error':\n        return logging.ERROR\n    elif logging_level == 'warning':\n        return logging.WARNING\n    elif logging_level == 'debug':\n        return logging.DEBUG\n\n    return logging.INFO\n\n\ndef parse_args(args):\n    \"\"\"Parse command line arguments.\"\"\"\n    parser = argparse.ArgumentParser(description='Run opsdroid.')\n    parser.add_argument('--gen-config', action=\"store_true\",\n                        help='prints out an example configuration file')\n    return parser.parse_args(args)\n\n\ndef check_dependencies():\n    \"\"\"Check for system dependencies required by opsdroid.\"\"\"\n    if sys.version_info[0] < 3 or sys.version_info[1] < 5:\n        logging.critical(\"Whoops! opsdroid requires python 3.5 or above.\")\n        sys.exit(1)\n\n\ndef main():\n    \"\"\"Enter the application here.\"\"\"\n    args = parse_args(sys.argv[1:])\n\n    if args.gen_config:\n        with open(EXAMPLE_CONFIG_FILE, 'r') as conf:\n            print(conf.read())\n        sys.exit(0)\n\n    check_dependencies()\n\n    restart = True\n\n    while restart:\n        with OpsDroid() as opsdroid:\n            opsdroid.load()\n            configure_logging(opsdroid.config)\n            opsdroid.web_server = Web(opsdroid)\n            opsdroid.start_loop()\n            restart = opsdroid.should_restart\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "opsdroid/__main__.py"}], "after_files": [{"content": "\"\"\"Starts opsdroid.\"\"\"\n\nimport os\nimport sys\nimport logging\nimport argparse\n\nfrom opsdroid.core import OpsDroid\nfrom opsdroid.const import DEFAULT_LOG_FILENAME, EXAMPLE_CONFIG_FILE\nfrom opsdroid.web import Web\n\n\n_LOGGER = logging.getLogger(\"opsdroid\")\n\n\ndef configure_logging(config):\n    \"\"\"Configure the root logger based on user config.\"\"\"\n    rootlogger = logging.getLogger()\n    while rootlogger.handlers:\n        rootlogger.handlers.pop()\n\n    try:\n        if config[\"logging\"][\"path\"]:\n            logfile_path = os.path.expanduser(config[\"logging\"][\"path\"])\n        else:\n            logfile_path = config[\"logging\"][\"path\"]\n    except KeyError:\n        logfile_path = DEFAULT_LOG_FILENAME\n\n    try:\n        log_level = get_logging_level(\n            config[\"logging\"][\"level\"])\n    except KeyError:\n        log_level = logging.INFO\n\n    rootlogger.setLevel(log_level)\n    formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s')\n\n    console_handler = logging.StreamHandler()\n    console_handler.setLevel(log_level)\n    console_handler.setFormatter(formatter)\n    rootlogger.addHandler(console_handler)\n\n    try:\n        if not config[\"logging\"][\"console\"]:\n            console_handler.setLevel(logging.CRITICAL)\n    except KeyError:\n        pass\n\n    if logfile_path:\n        logdir = os.path.dirname(os.path.realpath(logfile_path))\n        if not os.path.isdir(logdir):\n            os.makedirs(logdir)\n        file_handler = logging.FileHandler(logfile_path)\n        file_handler.setLevel(log_level)\n        file_handler.setFormatter(formatter)\n        rootlogger.addHandler(file_handler)\n\n    _LOGGER.info(\"=\"*40)\n    _LOGGER.info(\"Stated application\")\n\n\ndef get_logging_level(logging_level):\n    \"\"\"Get the logger level based on the user configuration.\"\"\"\n    if logging_level == 'critical':\n        return logging.CRITICAL\n    elif logging_level == 'error':\n        return logging.ERROR\n    elif logging_level == 'warning':\n        return logging.WARNING\n    elif logging_level == 'debug':\n        return logging.DEBUG\n\n    return logging.INFO\n\n\ndef parse_args(args):\n    \"\"\"Parse command line arguments.\"\"\"\n    parser = argparse.ArgumentParser(description='Run opsdroid.')\n    parser.add_argument('--gen-config', action=\"store_true\",\n                        help='prints out an example configuration file')\n    return parser.parse_args(args)\n\n\ndef check_dependencies():\n    \"\"\"Check for system dependencies required by opsdroid.\"\"\"\n    if sys.version_info[0] < 3 or sys.version_info[1] < 5:\n        logging.critical(\"Whoops! opsdroid requires python 3.5 or above.\")\n        sys.exit(1)\n\n\ndef main():\n    \"\"\"Enter the application here.\"\"\"\n    args = parse_args(sys.argv[1:])\n\n    if args.gen_config:\n        with open(EXAMPLE_CONFIG_FILE, 'r') as conf:\n            print(conf.read())\n        sys.exit(0)\n\n    check_dependencies()\n\n    restart = True\n\n    while restart:\n        with OpsDroid() as opsdroid:\n            opsdroid.load()\n            configure_logging(opsdroid.config)\n            opsdroid.web_server = Web(opsdroid)\n            opsdroid.start_loop()\n            restart = opsdroid.should_restart\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "opsdroid/__main__.py"}]}