json-friendly debug messages. fix #659
This commit is contained in:
parent
3e1a87397d
commit
696766c370
|
@ -25,7 +25,7 @@ import traceback
|
||||||
import json
|
import json
|
||||||
import Queue
|
import Queue
|
||||||
from network import Network
|
from network import Network
|
||||||
from util import print_msg
|
from util import print_msg, print_stderr
|
||||||
from simple_config import SimpleConfig
|
from simple_config import SimpleConfig
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class NetworkProxy(threading.Thread):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif not daemon_started:
|
elif not daemon_started:
|
||||||
print "Starting daemon [%s]"%self.config.get('server')
|
print_stderr( "Starting daemon [%s]"%self.config.get('server'))
|
||||||
daemon_started = True
|
daemon_started = True
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if (pid == 0): # The first child.
|
if (pid == 0): # The first child.
|
||||||
|
|
|
@ -397,7 +397,7 @@ class Interface(threading.Thread):
|
||||||
print_error("certificate has expired:", cert_path)
|
print_error("certificate has expired:", cert_path)
|
||||||
os.unlink(cert_path)
|
os.unlink(cert_path)
|
||||||
else:
|
else:
|
||||||
print_msg("wrong certificate", self.host)
|
print_error("wrong certificate", self.host)
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
print_error("wrap_socket failed", self.host)
|
print_error("wrap_socket failed", self.host)
|
||||||
|
|
|
@ -17,8 +17,12 @@ def set_verbosity(b):
|
||||||
global is_verbose
|
global is_verbose
|
||||||
is_verbose = b
|
is_verbose = b
|
||||||
|
|
||||||
|
|
||||||
def print_error(*args):
|
def print_error(*args):
|
||||||
if not is_verbose: return
|
if not is_verbose: return
|
||||||
|
print_stderr(*args)
|
||||||
|
|
||||||
|
def print_stderr(*args):
|
||||||
args = [str(item) for item in args]
|
args = [str(item) for item in args]
|
||||||
sys.stderr.write(" ".join(args) + "\n")
|
sys.stderr.write(" ".join(args) + "\n")
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
Loading…
Reference in New Issue