- Enhanced parsing of -l/--loglevel option

- Demote one message w/exception to debug
 - Hopefully improved user error message when fingerprint is bad
This commit is contained in:
junglecow 2006-12-27 18:38:50 +00:00
parent 45341476db
commit 847d9fe6e9
3 changed files with 17 additions and 17 deletions

View File

@ -470,8 +470,8 @@ class Connection(ConnectionHandlers):
self.disconnect(on_purpose = True)
self.dispatch('STATUS', 'offline')
self.dispatch('CONNECTION_LOST',
(_('Bad fingerprint for "%s"') % self._hostname,
_("Server's key changed, or spy attack.")))
(_('Security error connecting to "%s"') % self._hostname,
_("The server's key has changed, or someone is trying to hack your connection.")))
if self.on_connect_auth:
self.on_connect_auth(None)
self.on_connect_auth = None

View File

@ -423,7 +423,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
# get as many bites, as possible, but not more than RECV_BUFSIZE
received = self._recv(RECV_BUFSIZE)
except (socket.error, socket.herror, socket.gaierror), e:
log.error("_do_receive: got %s:", e.__class__, exc_info=True)
log.debug("_do_receive: got %s:", e.__class__, exc_info=True)
#traceback.print_exc()
#print "Current Stack:"
#traceback.print_stack()

View File

@ -23,11 +23,11 @@ import urllib
import logging
consoleloghandler = logging.StreamHandler()
consoleloghandler.setLevel(logging.WARNING)
consoleloghandler.setLevel(1)
consoleloghandler.setFormatter(
logging.Formatter('%(asctime)s %(name)s: %(levelname)s: %(message)s'))
log = logging.getLogger('gajim')
log.setLevel(logging.INFO)
log.setLevel(logging.WARNING)
log.addHandler(consoleloghandler)
log.propagate = False
log = logging.getLogger('gajim.gajim')
@ -53,20 +53,19 @@ def parseLogTarget(arg):
return 'gajim.' + arg
def parseAndSetLogLevels(arg):
directives = arg.split(',')
for directive in directives:
for directive in arg.split(','):
directive = directive.strip()
target, level = directive.split('=')
target = parseLogTarget(target.strip())
targets, level = directive.rsplit('=', 1)
level = parseLogLevel(level.strip())
if target == '':
consoleloghandler.setLevel(level)
print "consoleloghandler level set to %s" % level
else:
logger = logging.getLogger(target)
logger.setLevel(level)
print "Logger %s level set to %d" % (target, level)
for target in targets.split('='):
target = parseLogTarget(target.strip())
if target == '':
consoleloghandler.setLevel(level)
print "consoleloghandler level set to %s" % level
else:
logger = logging.getLogger(target)
logger.setLevel(level)
print "Logger %s level set to %d" % (target, level)
def parseOpts():
profile = ''
@ -97,6 +96,7 @@ def parseOpts():
return profile, verbose
profile, verbose = parseOpts()
del parseOpts, parseAndSetLogLevels, parseLogTarget, parseLogLevel
import message_control