We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
logging_functions should write logs from dev & test VMs to dev/
Currently `logging_functions.py` will write new log files to the `dev/` directory if the script being executed is not being executed from the admin account.  This should be extended to write to `dev/` when the script is run from personal accounts from the dev or test VMs. 

In other words, all logs should be written to `dev/` unless they are being run from the admin account on one of the production VMs. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `jwql/utils/logging_functions.py`
Content:
```
1 
2 """ Logging functions for the ``jwql`` automation platform.
3 
4 This module provides decorators to log the execution of modules.  Log
5 files are written to the ``logs/`` directory in the ``jwql`` central
6 storage area, named by module name and timestamp, e.g.
7 ``monitor_filesystem/monitor_filesystem_2018-06-20-15:22:51.log``
8 
9 
10 Authors
11 -------
12 
13     - Catherine Martlin 2018
14     - Alex Viana, 2013 (WFC3 QL Version)
15 
16 Use
17 ---
18 
19     To log the execution of a module, use:
20     ::
21 
22         import os
23         import logging
24 
25         from jwql.logging.logging_functions import configure_logging
26         from jwql.logging.logging_functions import log_info
27         from jwql.logging.logging_functions import log_fail
28 
29         @log_info
30         @log_fail
31         def my_main_function():
32             pass
33 
34         if __name__ == '__main__':
35 
36             module = os.path.basename(__file__).replace('.py', '')
37             configure_logging(module)
38 
39             my_main_function()
40 
41 Dependencies
42 ------------
43 
44     The user must have a configuration file named ``config.json``
45     placed in the ``utils`` directory.
46 
47 
48 References
49 ----------
50     This code is adopted and updated from python routine
51     ``logging_functions.py`` written by Alex Viana, 2013 for the WFC3
52     Quicklook automation platform.
53 """
54 
55 import datetime
56 import getpass
57 import importlib
58 import logging
59 import os
60 import pwd
61 import socket
62 import sys
63 import time
64 import traceback
65 
66 from functools import wraps
67 
68 from jwql.utils.permissions import set_permissions
69 from jwql.utils.utils import get_config, ensure_dir_exists
70 
71 LOG_FILE_LOC = ''
72 PRODUCTION_BOOL = ''
73 
74 
75 def configure_logging(module, production_mode=True, path='./'):
76     """Configure the log file with a standard logging format.
77 
78     Parameters
79     ----------
80     module : str
81         The name of the module being logged.
82     production_mode : bool
83         Whether or not the output should be written to the production
84         environement.
85     path : str
86         Where to write the log if user-supplied path; default to working dir.
87     """
88 
89     # Determine log file location
90     if production_mode:
91         log_file = make_log_file(module)
92     else:
93         log_file = make_log_file(module, production_mode=False, path=path)
94     global LOG_FILE_LOC
95     global PRODUCTION_BOOL
96     LOG_FILE_LOC = log_file
97     PRODUCTION_BOOL = production_mode
98 
99     # Create the log file and set the permissions
100     logging.basicConfig(filename=log_file,
101                         format='%(asctime)s %(levelname)s: %(message)s',
102                         datefmt='%m/%d/%Y %H:%M:%S %p',
103                         level=logging.INFO)
104     set_permissions(log_file)
105 
106 
107 def make_log_file(module, production_mode=True, path='./'):
108     """Create the log file name based on the module name.
109 
110     The name of the ``log_file`` is a combination of the name of the
111     module being logged and the current datetime.
112 
113     Parameters
114     ----------
115     module : str
116         The name of the module being logged.
117     production_mode : bool
118         Whether or not the output should be written to the production
119         environment.
120     path : str
121         Where to write the log if user-supplied path; default to
122         working dir.
123 
124     Returns
125     -------
126     log_file : str
127         The full path to where the log file will be written to.
128     """
129 
130     timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M')
131     filename = '{0}_{1}.log'.format(module, timestamp)
132     user = pwd.getpwuid(os.getuid()).pw_name
133 
134     settings = get_config()
135     admin_account = settings['admin_account']
136     log_path = settings['log_dir']
137 
138     exempt_modules = []
139     if user != admin_account and module not in exempt_modules and production_mode:
140         module = os.path.join('dev', module)
141 
142     if production_mode:
143         log_file = os.path.join(log_path, module, filename)
144     else:
145         log_file = os.path.join(path, filename)
146 
147     ensure_dir_exists(os.path.dirname(log_file))
148 
149     return log_file
150 
151 
152 def log_info(func):
153     """Decorator to log useful system information.
154 
155     This function can be used as a decorator to log user environment
156     and system information. Future packages we want to track can be
157     added or removed as necessary.
158 
159     Parameters
160     ----------
161     func : func
162         The function to decorate.
163 
164     Returns
165     -------
166     wrapped : func
167         The wrapped function.
168     """
169 
170     @wraps(func)
171     def wrapped(*a, **kw):
172 
173         # Log environment information
174         logging.info('User: ' + getpass.getuser())
175         logging.info('System: ' + socket.gethostname())
176         logging.info('Python Version: ' + sys.version.replace('\n', ''))
177         logging.info('Python Executable Path: ' + sys.executable)
178 
179         # Read in setup.py file to build list of required modules
180         settings = get_config()
181         setup_file_name = settings['setup_file']
182         with open(setup_file_name) as setup:
183             for line in setup:
184                 if line[0:8] == "REQUIRES":
185                     module_required = line[12:-2]
186                     module_list = module_required.split(',')
187 
188         # Clean up the module list
189         module_list = [module.replace('"', '').replace("'", '').replace(' ', '') for module in module_list]
190         module_list = [module.split('=')[0] for module in module_list]
191 
192         # Log common module version information
193         for module in module_list:
194             try:
195                 mod = importlib.import_module(module)
196                 logging.info(module + ' Version: ' + mod.__version__)
197                 logging.info(module + ' Path: ' + mod.__path__[0])
198             except ImportError as err:
199                 logging.warning(err)
200 
201         # Call the function and time it
202         t1_cpu = time.clock()
203         t1_time = time.time()
204         func(*a, **kw)
205         t2_cpu = time.clock()
206         t2_time = time.time()
207 
208         # Log execution time
209         hours_cpu, remainder_cpu = divmod(t2_cpu - t1_cpu, 60 * 60)
210         minutes_cpu, seconds_cpu = divmod(remainder_cpu, 60)
211         hours_time, remainder_time = divmod(t2_time - t1_time, 60 * 60)
212         minutes_time, seconds_time = divmod(remainder_time, 60)
213         logging.info('Elapsed Real Time: {0:.0f}:{1:.0f}:{2:f}'.format(hours_time, minutes_time, seconds_time))
214         logging.info('Elapsed CPU Time: {0:.0f}:{1:.0f}:{2:f}'.format(hours_cpu, minutes_cpu, seconds_cpu))
215 
216     return wrapped
217 
218 
219 def log_fail(func):
220     """Decorator to log crashes in the decorated code.
221 
222     Parameters
223     ----------
224     func : func
225         The function to decorate.
226 
227     Returns
228     -------
229     wrapped : func
230         The wrapped function.
231     """
232 
233     @wraps(func)
234     def wrapped(*a, **kw):
235 
236         try:
237 
238             # Run the function
239             func(*a, **kw)
240             logging.info('Completed Successfully')
241 
242         except Exception:
243             logging.critical(traceback.format_exc())
244             logging.critical('CRASHED')
245 
246     return wrapped
247
```
--- 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/jwql/utils/logging_functions.py b/jwql/utils/logging_functions.py
--- a/jwql/utils/logging_functions.py
+++ b/jwql/utils/logging_functions.py
@@ -135,8 +135,7 @@
     admin_account = settings['admin_account']
     log_path = settings['log_dir']
 
-    exempt_modules = []
-    if user != admin_account and module not in exempt_modules and production_mode:
+    if user != admin_account or not production_mode:
         module = os.path.join('dev', module)
 
     if production_mode:

{"golden_diff": "diff --git a/jwql/utils/logging_functions.py b/jwql/utils/logging_functions.py\n--- a/jwql/utils/logging_functions.py\n+++ b/jwql/utils/logging_functions.py\n@@ -135,8 +135,7 @@\n     admin_account = settings['admin_account']\n     log_path = settings['log_dir']\n \n-    exempt_modules = []\n-    if user != admin_account and module not in exempt_modules and production_mode:\n+    if user != admin_account or not production_mode:\n         module = os.path.join('dev', module)\n \n     if production_mode:\n", "issue": "logging_functions should write logs from dev & test VMs to dev/\nCurrently `logging_functions.py` will write new log files to the `dev/` directory if the script being executed is not being executed from the admin account.  This should be extended to write to `dev/` when the script is run from personal accounts from the dev or test VMs. \r\n\r\nIn other words, all logs should be written to `dev/` unless they are being run from the admin account on one of the production VMs. \n", "before_files": [{"content": "\n\"\"\" Logging functions for the ``jwql`` automation platform.\n\nThis module provides decorators to log the execution of modules.  Log\nfiles are written to the ``logs/`` directory in the ``jwql`` central\nstorage area, named by module name and timestamp, e.g.\n``monitor_filesystem/monitor_filesystem_2018-06-20-15:22:51.log``\n\n\nAuthors\n-------\n\n    - Catherine Martlin 2018\n    - Alex Viana, 2013 (WFC3 QL Version)\n\nUse\n---\n\n    To log the execution of a module, use:\n    ::\n\n        import os\n        import logging\n\n        from jwql.logging.logging_functions import configure_logging\n        from jwql.logging.logging_functions import log_info\n        from jwql.logging.logging_functions import log_fail\n\n        @log_info\n        @log_fail\n        def my_main_function():\n            pass\n\n        if __name__ == '__main__':\n\n            module = os.path.basename(__file__).replace('.py', '')\n            configure_logging(module)\n\n            my_main_function()\n\nDependencies\n------------\n\n    The user must have a configuration file named ``config.json``\n    placed in the ``utils`` directory.\n\n\nReferences\n----------\n    This code is adopted and updated from python routine\n    ``logging_functions.py`` written by Alex Viana, 2013 for the WFC3\n    Quicklook automation platform.\n\"\"\"\n\nimport datetime\nimport getpass\nimport importlib\nimport logging\nimport os\nimport pwd\nimport socket\nimport sys\nimport time\nimport traceback\n\nfrom functools import wraps\n\nfrom jwql.utils.permissions import set_permissions\nfrom jwql.utils.utils import get_config, ensure_dir_exists\n\nLOG_FILE_LOC = ''\nPRODUCTION_BOOL = ''\n\n\ndef configure_logging(module, production_mode=True, path='./'):\n    \"\"\"Configure the log file with a standard logging format.\n\n    Parameters\n    ----------\n    module : str\n        The name of the module being logged.\n    production_mode : bool\n        Whether or not the output should be written to the production\n        environement.\n    path : str\n        Where to write the log if user-supplied path; default to working dir.\n    \"\"\"\n\n    # Determine log file location\n    if production_mode:\n        log_file = make_log_file(module)\n    else:\n        log_file = make_log_file(module, production_mode=False, path=path)\n    global LOG_FILE_LOC\n    global PRODUCTION_BOOL\n    LOG_FILE_LOC = log_file\n    PRODUCTION_BOOL = production_mode\n\n    # Create the log file and set the permissions\n    logging.basicConfig(filename=log_file,\n                        format='%(asctime)s %(levelname)s: %(message)s',\n                        datefmt='%m/%d/%Y %H:%M:%S %p',\n                        level=logging.INFO)\n    set_permissions(log_file)\n\n\ndef make_log_file(module, production_mode=True, path='./'):\n    \"\"\"Create the log file name based on the module name.\n\n    The name of the ``log_file`` is a combination of the name of the\n    module being logged and the current datetime.\n\n    Parameters\n    ----------\n    module : str\n        The name of the module being logged.\n    production_mode : bool\n        Whether or not the output should be written to the production\n        environment.\n    path : str\n        Where to write the log if user-supplied path; default to\n        working dir.\n\n    Returns\n    -------\n    log_file : str\n        The full path to where the log file will be written to.\n    \"\"\"\n\n    timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M')\n    filename = '{0}_{1}.log'.format(module, timestamp)\n    user = pwd.getpwuid(os.getuid()).pw_name\n\n    settings = get_config()\n    admin_account = settings['admin_account']\n    log_path = settings['log_dir']\n\n    exempt_modules = []\n    if user != admin_account and module not in exempt_modules and production_mode:\n        module = os.path.join('dev', module)\n\n    if production_mode:\n        log_file = os.path.join(log_path, module, filename)\n    else:\n        log_file = os.path.join(path, filename)\n\n    ensure_dir_exists(os.path.dirname(log_file))\n\n    return log_file\n\n\ndef log_info(func):\n    \"\"\"Decorator to log useful system information.\n\n    This function can be used as a decorator to log user environment\n    and system information. Future packages we want to track can be\n    added or removed as necessary.\n\n    Parameters\n    ----------\n    func : func\n        The function to decorate.\n\n    Returns\n    -------\n    wrapped : func\n        The wrapped function.\n    \"\"\"\n\n    @wraps(func)\n    def wrapped(*a, **kw):\n\n        # Log environment information\n        logging.info('User: ' + getpass.getuser())\n        logging.info('System: ' + socket.gethostname())\n        logging.info('Python Version: ' + sys.version.replace('\\n', ''))\n        logging.info('Python Executable Path: ' + sys.executable)\n\n        # Read in setup.py file to build list of required modules\n        settings = get_config()\n        setup_file_name = settings['setup_file']\n        with open(setup_file_name) as setup:\n            for line in setup:\n                if line[0:8] == \"REQUIRES\":\n                    module_required = line[12:-2]\n                    module_list = module_required.split(',')\n\n        # Clean up the module list\n        module_list = [module.replace('\"', '').replace(\"'\", '').replace(' ', '') for module in module_list]\n        module_list = [module.split('=')[0] for module in module_list]\n\n        # Log common module version information\n        for module in module_list:\n            try:\n                mod = importlib.import_module(module)\n                logging.info(module + ' Version: ' + mod.__version__)\n                logging.info(module + ' Path: ' + mod.__path__[0])\n            except ImportError as err:\n                logging.warning(err)\n\n        # Call the function and time it\n        t1_cpu = time.clock()\n        t1_time = time.time()\n        func(*a, **kw)\n        t2_cpu = time.clock()\n        t2_time = time.time()\n\n        # Log execution time\n        hours_cpu, remainder_cpu = divmod(t2_cpu - t1_cpu, 60 * 60)\n        minutes_cpu, seconds_cpu = divmod(remainder_cpu, 60)\n        hours_time, remainder_time = divmod(t2_time - t1_time, 60 * 60)\n        minutes_time, seconds_time = divmod(remainder_time, 60)\n        logging.info('Elapsed Real Time: {0:.0f}:{1:.0f}:{2:f}'.format(hours_time, minutes_time, seconds_time))\n        logging.info('Elapsed CPU Time: {0:.0f}:{1:.0f}:{2:f}'.format(hours_cpu, minutes_cpu, seconds_cpu))\n\n    return wrapped\n\n\ndef log_fail(func):\n    \"\"\"Decorator to log crashes in the decorated code.\n\n    Parameters\n    ----------\n    func : func\n        The function to decorate.\n\n    Returns\n    -------\n    wrapped : func\n        The wrapped function.\n    \"\"\"\n\n    @wraps(func)\n    def wrapped(*a, **kw):\n\n        try:\n\n            # Run the function\n            func(*a, **kw)\n            logging.info('Completed Successfully')\n\n        except Exception:\n            logging.critical(traceback.format_exc())\n            logging.critical('CRASHED')\n\n    return wrapped\n", "path": "jwql/utils/logging_functions.py"}], "after_files": [{"content": "\n\"\"\" Logging functions for the ``jwql`` automation platform.\n\nThis module provides decorators to log the execution of modules.  Log\nfiles are written to the ``logs/`` directory in the ``jwql`` central\nstorage area, named by module name and timestamp, e.g.\n``monitor_filesystem/monitor_filesystem_2018-06-20-15:22:51.log``\n\n\nAuthors\n-------\n\n    - Catherine Martlin 2018\n    - Alex Viana, 2013 (WFC3 QL Version)\n\nUse\n---\n\n    To log the execution of a module, use:\n    ::\n\n        import os\n        import logging\n\n        from jwql.logging.logging_functions import configure_logging\n        from jwql.logging.logging_functions import log_info\n        from jwql.logging.logging_functions import log_fail\n\n        @log_info\n        @log_fail\n        def my_main_function():\n            pass\n\n        if __name__ == '__main__':\n\n            module = os.path.basename(__file__).replace('.py', '')\n            configure_logging(module)\n\n            my_main_function()\n\nDependencies\n------------\n\n    The user must have a configuration file named ``config.json``\n    placed in the ``utils`` directory.\n\n\nReferences\n----------\n    This code is adopted and updated from python routine\n    ``logging_functions.py`` written by Alex Viana, 2013 for the WFC3\n    Quicklook automation platform.\n\"\"\"\n\nimport datetime\nimport getpass\nimport importlib\nimport logging\nimport os\nimport pwd\nimport socket\nimport sys\nimport time\nimport traceback\n\nfrom functools import wraps\n\nfrom jwql.utils.permissions import set_permissions\nfrom jwql.utils.utils import get_config, ensure_dir_exists\n\nLOG_FILE_LOC = ''\nPRODUCTION_BOOL = ''\n\n\ndef configure_logging(module, production_mode=True, path='./'):\n    \"\"\"Configure the log file with a standard logging format.\n\n    Parameters\n    ----------\n    module : str\n        The name of the module being logged.\n    production_mode : bool\n        Whether or not the output should be written to the production\n        environement.\n    path : str\n        Where to write the log if user-supplied path; default to working dir.\n    \"\"\"\n\n    # Determine log file location\n    if production_mode:\n        log_file = make_log_file(module)\n    else:\n        log_file = make_log_file(module, production_mode=False, path=path)\n    global LOG_FILE_LOC\n    global PRODUCTION_BOOL\n    LOG_FILE_LOC = log_file\n    PRODUCTION_BOOL = production_mode\n\n    # Create the log file and set the permissions\n    logging.basicConfig(filename=log_file,\n                        format='%(asctime)s %(levelname)s: %(message)s',\n                        datefmt='%m/%d/%Y %H:%M:%S %p',\n                        level=logging.INFO)\n    set_permissions(log_file)\n\n\ndef make_log_file(module, production_mode=True, path='./'):\n    \"\"\"Create the log file name based on the module name.\n\n    The name of the ``log_file`` is a combination of the name of the\n    module being logged and the current datetime.\n\n    Parameters\n    ----------\n    module : str\n        The name of the module being logged.\n    production_mode : bool\n        Whether or not the output should be written to the production\n        environment.\n    path : str\n        Where to write the log if user-supplied path; default to\n        working dir.\n\n    Returns\n    -------\n    log_file : str\n        The full path to where the log file will be written to.\n    \"\"\"\n\n    timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M')\n    filename = '{0}_{1}.log'.format(module, timestamp)\n    user = pwd.getpwuid(os.getuid()).pw_name\n\n    settings = get_config()\n    admin_account = settings['admin_account']\n    log_path = settings['log_dir']\n\n    if user != admin_account or not production_mode:\n        module = os.path.join('dev', module)\n\n    if production_mode:\n        log_file = os.path.join(log_path, module, filename)\n    else:\n        log_file = os.path.join(path, filename)\n\n    ensure_dir_exists(os.path.dirname(log_file))\n\n    return log_file\n\n\ndef log_info(func):\n    \"\"\"Decorator to log useful system information.\n\n    This function can be used as a decorator to log user environment\n    and system information. Future packages we want to track can be\n    added or removed as necessary.\n\n    Parameters\n    ----------\n    func : func\n        The function to decorate.\n\n    Returns\n    -------\n    wrapped : func\n        The wrapped function.\n    \"\"\"\n\n    @wraps(func)\n    def wrapped(*a, **kw):\n\n        # Log environment information\n        logging.info('User: ' + getpass.getuser())\n        logging.info('System: ' + socket.gethostname())\n        logging.info('Python Version: ' + sys.version.replace('\\n', ''))\n        logging.info('Python Executable Path: ' + sys.executable)\n\n        # Read in setup.py file to build list of required modules\n        settings = get_config()\n        setup_file_name = settings['setup_file']\n        with open(setup_file_name) as setup:\n            for line in setup:\n                if line[0:8] == \"REQUIRES\":\n                    module_required = line[12:-2]\n                    module_list = module_required.split(',')\n\n        # Clean up the module list\n        module_list = [module.replace('\"', '').replace(\"'\", '').replace(' ', '') for module in module_list]\n        module_list = [module.split('=')[0] for module in module_list]\n\n        # Log common module version information\n        for module in module_list:\n            try:\n                mod = importlib.import_module(module)\n                logging.info(module + ' Version: ' + mod.__version__)\n                logging.info(module + ' Path: ' + mod.__path__[0])\n            except ImportError as err:\n                logging.warning(err)\n\n        # Call the function and time it\n        t1_cpu = time.clock()\n        t1_time = time.time()\n        func(*a, **kw)\n        t2_cpu = time.clock()\n        t2_time = time.time()\n\n        # Log execution time\n        hours_cpu, remainder_cpu = divmod(t2_cpu - t1_cpu, 60 * 60)\n        minutes_cpu, seconds_cpu = divmod(remainder_cpu, 60)\n        hours_time, remainder_time = divmod(t2_time - t1_time, 60 * 60)\n        minutes_time, seconds_time = divmod(remainder_time, 60)\n        logging.info('Elapsed Real Time: {0:.0f}:{1:.0f}:{2:f}'.format(hours_time, minutes_time, seconds_time))\n        logging.info('Elapsed CPU Time: {0:.0f}:{1:.0f}:{2:f}'.format(hours_cpu, minutes_cpu, seconds_cpu))\n\n    return wrapped\n\n\ndef log_fail(func):\n    \"\"\"Decorator to log crashes in the decorated code.\n\n    Parameters\n    ----------\n    func : func\n        The function to decorate.\n\n    Returns\n    -------\n    wrapped : func\n        The wrapped function.\n    \"\"\"\n\n    @wraps(func)\n    def wrapped(*a, **kw):\n\n        try:\n\n            # Run the function\n            func(*a, **kw)\n            logging.info('Completed Successfully')\n\n        except Exception:\n            logging.critical(traceback.format_exc())\n            logging.critical('CRASHED')\n\n    return wrapped\n", "path": "jwql/utils/logging_functions.py"}]}