diff --git a/onionshare/__init__.py b/onionshare/__init__.py
index 1043334e..f2180cee 100644
--- a/onionshare/__init__.py
+++ b/onionshare/__init__.py
@@ -56,6 +56,11 @@ def main(cwd=None):
     stay_open = bool(args.stay_open)
     stealth = bool(args.stealth)
 
+    # Debug mode?
+    if debug:
+        common.set_debug(debug)
+        web.debug_mode()
+
     # Validation
     valid = True
     for filename in filenames:
@@ -66,7 +71,7 @@ def main(cwd=None):
         sys.exit()
 
     # Start the Onion object
-    onion = Onion(debug)
+    onion = Onion()
     try:
         onion.connect()
     except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported, BundledTorTimeout) as e:
@@ -84,10 +89,6 @@ def main(cwd=None):
         print("")
         sys.exit()
 
-    # Debug mode?
-    if debug:
-        web.debug_mode()
-
     # Prepare files to share
     print(strings._("preparing_files"))
     web.set_file_info(filenames)
diff --git a/onionshare/common.py b/onionshare/common.py
index 5f3d119a..8d5ad79a 100644
--- a/onionshare/common.py
+++ b/onionshare/common.py
@@ -20,6 +20,19 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import sys, os, inspect, hashlib, base64, platform, zipfile, tempfile, math, time, socket, random
 from random import SystemRandom
 
+debug = False
+def log(module, func, msg):
+    """
+    If debug mode is on, log error messages to stdout
+    """
+    global debug
+    if debug:
+        print("[{}.{}] {}".format(module, func, msg))
+
+def set_debug(new_debug):
+    global debug
+    debug = new_debug
+
 
 def get_platform():
     """
diff --git a/onionshare/onion.py b/onionshare/onion.py
index 8b673773..ef806a46 100644
--- a/onionshare/onion.py
+++ b/onionshare/onion.py
@@ -119,9 +119,7 @@ class Onion(object):
     call this function and pass in a status string while connecting to tor. This
     is necessary for status updates to reach the GUI.
     """
-    def __init__(self, debug):
-        self.debug = debug
-
+    def __init__(self):
         self.stealth = False
         self.service_id = None
 
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index 43c19694..71b8b9d4 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -27,7 +27,7 @@ class OnionShare(object):
     OnionShare is the main application class. Pass in options and run
     start_onion_service and it will do the magic.
     """
-    def __init__(self, onion, debug=False, local_only=False, stay_open=False):
+    def __init__(self, onion, local_only=False, stay_open=False):
         # The Onion object
         self.onion = onion
 
diff --git a/onionshare_gui/__init__.py b/onionshare_gui/__init__.py
index 8b7bdf3b..3cc4c073 100644
--- a/onionshare_gui/__init__.py
+++ b/onionshare_gui/__init__.py
@@ -76,6 +76,11 @@ def main():
     stay_open = bool(args.stay_open)
     debug = bool(args.debug)
 
+    # Debug mode?
+    if debug:
+        common.set_debug(debug)
+        web.debug_mode()
+
     # Validation
     if filenames:
         valid = True
@@ -87,14 +92,14 @@ def main():
             sys.exit()
 
     # Start the Onion
-    onion = Onion(debug)
+    onion = Onion()
 
     # Start the OnionShare app
     web.set_stay_open(stay_open)
-    app = OnionShare(onion, debug, local_only, stay_open)
+    app = OnionShare(onion, local_only, stay_open)
 
     # Launch the gui
-    gui = OnionShareGui(onion, debug, qtapp, app, filenames)
+    gui = OnionShareGui(onion, qtapp, app, filenames)
 
     # Clean up when app quits
     def shutdown():
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index db1c7838..84f3ab3e 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -44,10 +44,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
     starting_server_step3 = QtCore.pyqtSignal()
     starting_server_error = QtCore.pyqtSignal(str)
 
-    def __init__(self, onion, debug, qtapp, app, filenames):
+    def __init__(self, onion, qtapp, app, filenames):
         super(OnionShareGui, self).__init__()
         self.onion = onion
-        self.debug = debug
         self.qtapp = qtapp
         self.app = app