Skip to content

Commit

Permalink
Log exceptions to stderr
Browse files Browse the repository at this point in the history
Can now redirect the error stream to get notified on errors.
  • Loading branch information
francoisfreitag committed Sep 27, 2019
1 parent 6ce6fc7 commit 39f0775
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dyn_gandi.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ def livedns_handle(domain, ip, records):
print("Updated record %s/%s from %s to %s" % (rec['name'], rec['type'], dns_ip, ip))
print("API response: %s" % json.dumps(r_update, indent=2))
except Exception as e:
print("%s, Error: %s. Backup snapshot uuid: %s." % (message, repr(e), snapshot_uuid))
print(
"%s, Error: %s. Backup snapshot uuid: %s."
% (message, repr(e), snapshot_uuid),
file=sys.stderr,
)
raise e

# delete snapshot
Expand All @@ -159,7 +163,7 @@ def main():
ip_resolver = IpResolver(url=config['ip']['resolver_url'], alt_url=config['ip'].get('resolver_url_alt', None))
ip = ip_resolver.resolve_ip()
except IpResolverError as e:
print("%s - %s [ERROR]" % (today, str(e)))
print("%s - %s [ERROR]" % (today, str(e)), file=sys.stderr)
raise RuntimeWarning("IP resolver returned an error: %s" % str(e))

if verbose:
Expand Down

0 comments on commit 39f0775

Please sign in to comment.