Commit 73539a20 authored by Federico Sismondi's avatar Federico Sismondi
Browse files

added as default amq.topic as default AMQP_EXCHANGE env var

parent 8a0ea192
......@@ -389,17 +389,26 @@ if __name__ == '__main__':
try:
AMQP_EXCHANGE = str(os.environ['AMQP_EXCHANGE'])
print('Imported AMQP_EXCHANGE env var: %s' % AMQP_EXCHANGE)
except KeyError as e:
AMQP_EXCHANGE = "default"
AMQP_EXCHANGE = "amq.topic"
print('Cannot retrieve environment variables for AMQP EXCHANGE. Loading default: %s' %AMQP_EXCHANGE)
try:
AMQP_URL = str(os.environ['AMQP_URL'])
print('Imported AMQP_URL env var: %s' % AMQP_URL)
p = six.moves.urllib_parse.urlparse(AMQP_URL)
AMQP_USER = p.username
AMQP_SERVER = p.hostname
logging.info(
"Env variables imported for AMQP connection, User: {0} @ Server: {1} ".format(AMQP_USER, AMQP_SERVER))
except KeyError as e:
print('Cannot retrieve environment variables for AMQP connection. Loading defaults..')
# load default values
AMQP_URL = "amqp://{0}:{1}@{2}/{3}".format("guest", "guest", "localhost", "/")
......
......@@ -40,8 +40,10 @@ except ImportError:
pass
VERSION = '0.0.3'
# defaults vars
AMQP_URL = 'amqp://guest:guest@localhost'
AMQP_EXCHANGE = 'default'
AMQP_EXCHANGE = 'amq.default'
try:
AMQP_URL = str(os.environ['AMQP_URL'])
......@@ -182,7 +184,7 @@ class RabbitMQHandler(logging.Handler):
Example setup::
handler = RabbitMQHandler('amqp://guest:guest@localhost')
"""
def __init__(self, url, name, exchange="default"):
def __init__(self, url, name, exchange=AMQP_EXCHANGE):
logging.Handler.__init__(self)
self.connection = pika.BlockingConnection(pika.URLParameters(url))
self.channel = self.connection.channel()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment