diff options
| author | Jonathan Robie <jonathan@apache.org> | 2010-12-22 22:22:13 +0000 |
|---|---|---|
| committer | Jonathan Robie <jonathan@apache.org> | 2010-12-22 22:22:13 +0000 |
| commit | f9a0fec8230a3b1f48ff57483c3639d937336114 (patch) | |
| tree | b1f19281bae1c9953075d31bec830feef7e8e323 /qpid/extras | |
| parent | 0836e38953b8a1b6c0dc1a8899874b094d6115b6 (diff) | |
| download | qpid-python-f9a0fec8230a3b1f48ff57483c3639d937336114.tar.gz | |
Added logging to QMF console connections.
Warning if a broker can not be found, error if SASL authentication fails or other connection errors when connecting to an existing broker. Default log level is ERROR.
qpid-printevents allows the log level to be set. It also allows the user to specify that a connection is required, in which case it terminates if a connection can not be established.
Examples:
$ ./qpid-printevents --sasl-mechanism PLAIN nonexistent-broker
=> Not an error. Waits for the broker to be started.
$ ./qpid-printevents --sasl-mechanism PLAIN localhost
2010-12-22 17:07:18,365 ERROR Could not connect to broker localhost:5672 (None, 'No acceptable SASL authentication mechanism available')
=> Connection error condition in output - SASL authentication failed
because user name and password are not supplied.
But qpid-printevents keeps running, waiting for you to start the
broker.
$ ./qpid-printevents --sasl-mechanism PLAIN --log-level critical
=> Connection error condition in output - SASL authentication failed
because user name and password are not supplied.
No output in this case, because the log level has been set to
critical.
$ ./qpid-printevents --sasl-mechanism PLAIN --require-connection localhost
2010-12-22 17:11:03,791 ERROR Could not connect to broker localhost:5672 (None, 'No acceptable SASL authentication mechanism available')
Failed: ConnectionFailed - (None, 'No acceptable SASL authentication mechanism available')
=> Connection error condition.
qpid-printevents terminates because --require-connection was specified.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1052086 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/extras')
| -rw-r--r-- | qpid/extras/qmf/src/py/qmf/console.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/qpid/extras/qmf/src/py/qmf/console.py b/qpid/extras/qmf/src/py/qmf/console.py index 15e12fbb6b..319cc97d89 100644 --- a/qpid/extras/qmf/src/py/qmf/console.py +++ b/qpid/extras/qmf/src/py/qmf/console.py @@ -39,8 +39,8 @@ from Queue import Queue, Empty from time import time, strftime, gmtime, sleep from cStringIO import StringIO -#import qpid.log -#qpid.log.enable(name="qpid.io.cmd", level=qpid.log.DEBUG) +import qpid.log +qpid.log.enable(name="qpid.qmf") #=================================================================================================== # CONSOLE @@ -2509,6 +2509,14 @@ class Broker(Thread): except Exception, e: self.error = "Exception during connection setup: %s - %s" % (e.__class__.__name__, e) + + log = qpid.log.getLogger("qpid.qmf") + + if e[0] == -2: + log.warning("Could not connect to broker " + self.host + ":" + str(self.port) + " " + str(e)) + else: + log.error("Could not connect to broker " + self.host + ":" + str(self.port) + " " + str(e)) + self.conn_exc = e return False # connection failed |
