3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

Merge branch 'master' into devel

This commit is contained in:
James Lu 2016-03-25 16:01:34 -07:00
commit 75ec95b8d3
2 changed files with 21 additions and 7 deletions

19
log.py
View File

@ -20,14 +20,22 @@ curdir = os.path.dirname(os.path.realpath(__file__))
logdir = os.path.join(curdir, 'log')
os.makedirs(logdir, exist_ok=True)
# Basic logging setup, set up here on first import, logs to STDOUT based
# on the log level configured.
_format = '%(asctime)s [%(levelname)s] %(message)s'
logformatter = logging.Formatter(_format)
logging.basicConfig(level=stdout_level, format=_format)
# Set up logging to STDERR
stdout_handler = logging.StreamHandler()
stdout_handler.setFormatter(logformatter)
stdout_handler.setLevel(stdout_level)
# Get the main logger object; plugins can import this variable for convenience.
log = logging.getLogger()
log.addHandler(stdout_handler)
# This is confusing, but we have to set the root logger to accept all events. Only this way
# can other loggers filter out events on their own, instead of having everything dropped by
# the root logger. https://stackoverflow.com/questions/16624695
log.setLevel(1)
def makeFileLogger(filename, level=None):
"""
@ -40,8 +48,9 @@ def makeFileLogger(filename, level=None):
filelogger = logging.FileHandler(target, mode='w')
filelogger.setFormatter(logformatter)
if level: # Custom log level was defined, use that instead.
filelogger.setLevel(level)
# If no log level is specified, use the same one as STDOUT.
level = level or stdout_level
filelogger.setLevel(level)
log.addHandler(filelogger)

View File

@ -1185,12 +1185,17 @@ def handle_disconnect(irc, numeric, command, args):
for name, ircobj in world.networkobjects.copy().items():
if name != irc.name and ircobj.connected.is_set():
try:
rsid = relayservers[ircobj.name][irc.name]
rsid = relayservers[name][irc.name]
except KeyError:
continue
else:
ircobj.proto.squit(ircobj.sid, rsid, text='Relay network lost connection.')
del relayservers[name][irc.name]
try:
del relayservers[name][irc.name]
except KeyError:
pass
try:
del relayservers[irc.name]
except KeyError: