From aefbca0956ffb313939a1fc411849328bced895d Mon Sep 17 00:00:00 2001 From: Mike Tonks Date: Fri, 10 Jul 2015 16:59:34 +0100 Subject: [PATCH] Increase verbosity of logging messages #2 --- governor.py | 8 ++++++-- helpers/ha.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/governor.py b/governor.py index 07322773..1929b949 100755 --- a/governor.py +++ b/governor.py @@ -7,8 +7,9 @@ from helpers.postgresql import Postgresql from helpers.ha import Ha +LOG_LEVEL = logging.DEBUG if os.getenv('DEBUG', None) else logging.INFO -logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) +logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=LOG_LEVEL) f = open(sys.argv[1], "r") config = yaml.load(f.read()) @@ -40,6 +41,7 @@ def stop_postgresql(): logging.info("Governor Starting up: Empty Data Dir") # racing to initialize if etcd.race("/initialize", postgresql.name): + logging.info("Governor Starting up: Initialisation Race ... WON!!!") logging.info("Governor Starting up: Initialise Postgres") postgresql.initialize() logging.info("Governor Starting up: Initialise Complete") @@ -47,6 +49,7 @@ def stop_postgresql(): logging.info("Governor Starting up: Starting Postgres") postgresql.start() else: + logging.info("Governor Starting up: Initialisation Race ... LOST") logging.info("Governor Starting up: Sync Postgres from Leader") synced_from_leader = False while not synced_from_leader: @@ -70,10 +73,11 @@ def stop_postgresql(): logging.info("Governor Running: Starting Running Loop") while True: - logging.info(ha.run_cycle()) + logging.info("Governor Running: %s" % ha.run_cycle()) # create replication slots if postgresql.is_leader(): + logging.info("Governor Running: I am the Leader") for node in etcd.get_client_path("/members?recursive=true")["node"]["nodes"]: member = node["key"].split('/')[-1] if member != postgresql.name: diff --git a/helpers/ha.py b/helpers/ha.py index bd770524..b7495409 100644 --- a/helpers/ha.py +++ b/helpers/ha.py @@ -40,6 +40,7 @@ def run_cycle(self): try: if self.state_handler.is_healthy(): if self.is_unlocked(): + logging.info("Leader is unlocked - starting election") if self.state_handler.is_healthiest_node(self.etcd): if self.acquire_lock(): if not self.state_handler.is_leader():