diff options
author | Micah Lee <micah@micahflee.com> | 2018-12-11 08:06:14 -0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2018-12-11 08:06:14 -0800 |
commit | b02e1c257fc3b2bd8fb50ddd8e25ba2f4dbb438b (patch) | |
tree | 0bf69e451a0afd0c6911c2dea98536ddb3fc4bd6 | |
parent | 1cf816b24bf61be1067f1ebff338920d76d1352a (diff) | |
parent | 919fdeb096b957e29382113e41270bbaf533b0fb (diff) | |
download | onionshare-b02e1c257fc3b2bd8fb50ddd8e25ba2f4dbb438b.tar.gz onionshare-b02e1c257fc3b2bd8fb50ddd8e25ba2f4dbb438b.zip |
Change filename of flask debug log file, store it in the OnionShare data dir instead of /tmp
-rw-r--r-- | onionshare/web/web.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/onionshare/web/web.py b/onionshare/web/web.py index 5ecbad27..21e9cd8f 100644 --- a/onionshare/web/web.py +++ b/onionshare/web/web.py @@ -184,9 +184,20 @@ class Web(object): """ Turn on debugging mode, which will log flask errors to a debug file. """ - temp_dir = tempfile.gettempdir() - log_handler = logging.FileHandler( - os.path.join(temp_dir, 'onionshare_server.log')) + if self.common.platform == 'Windows': + try: + appdata = os.environ['APPDATA'] + flask_debug_filename = '{}\\OnionShare\\flask_debug.log'.format(appdata) + except: + # If for some reason we don't have the 'APPDATA' environment variable + # (like running tests in Linux while pretending to be in Windows) + flask_debug_filename = os.path.expanduser('~/.config/onionshare/flask_debug.log') + elif self.common.platform == 'Darwin': + flask_debug_filename = os.path.expanduser('~/Library/Application Support/OnionShare/flask_debug.log') + else: + flask_debug_filename = os.path.expanduser('~/.config/onionshare/flask_debug.log') + + log_handler = logging.FileHandler(flask_debug_filename) log_handler.setLevel(logging.WARNING) self.app.logger.addHandler(log_handler) |