Skip to content

Commit a3f8f9a

Browse files
author
minecraft server
committed
Made log to stderr in debug mode. Fixed a bug when select() is interrupted.
1 parent 1e5ff1a commit a3f8f9a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# Info for proxy
77
#LISTEN_ADDR = ('0.0.0.0', 25564)
88
LISTEN_ADDR = ('0.0.0.0', 25565) if not DEBUG else ('0.0.0.0', 25564)
9-
SERVER_ADDR = ('127.0.0.1', 25565)
10-
#SERVER_ADDR = ('127.0.0.1', 25042)
9+
#SERVER_ADDR = ('127.0.0.1', 25565)
10+
SERVER_ADDR = ('127.0.0.1', 25042)
1111
LOG_FILE = '/var/minecraft/logs/proxy.log' if not DEBUG else '/var/minecraft/logs/proxy-debug.log'
1212
LOG_FORMAT = '%(created)f\t%(levelname)s\t%(message)s'
1313
PASSTHROUGH_LOG_FILE = '/var/minecraft/logs/passthrough.log'

proxy.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ def main():
3333
listener.listen(128)
3434
listener.setblocking(0)
3535

36-
logging.basicConfig(filename=LOG_FILE, level=logging.DEBUG, format=LOG_FORMAT)
36+
logging.basicConfig(filename=LOG_FILE, level=(logging.DEBUG if DEBUG else logging.INFO), format=LOG_FORMAT)
37+
if DEBUG:
38+
debug_handler = logging.StreamHandler() # defaults to stderr
39+
debug_handler.setFormatter(logging.Formatter(LOG_FORMAT))
40+
debug_handler.setLevel(logging.DEBUG)
41+
logging.root.addHandler(debug_handler)
42+
3743
logging.info("Starting up")
3844
if PASSTHROUGH:
3945
passthrough_log = open(PASSTHROUGH_LOG_FILE, 'w')
@@ -72,7 +78,8 @@ def main():
7278
try:
7379
r, w, x = select(conn_map.keys() + [listener], send_buffers.keys(), [])
7480
except select_error, ex:
75-
if ex.errno == errno.EINTR:
81+
ex_errno, ex_msg = ex.args
82+
if ex_errno == errno.EINTR:
7683
continue
7784
raise
7885

0 commit comments

Comments
 (0)