Skip to content

Commit fb9b50b

Browse files
committed
Improved formatting.
1 parent 07d6472 commit fb9b50b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dockerDDNS.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020

2121
args = parser.parse_args()
2222

23-
if args.log_file == '-':
24-
logging.basicConfig(level=getattr(logging,args.log_level.upper()))
25-
else:
26-
logging.basicConfig(level=getattr(logging,args.log_level.upper()), filename=args.log_file)
23+
logging.basicConfig(level=getattr(logging,args.log_level.upper()),
24+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
25+
filename=(args.log_file if args.log_file != '-' else None))
2726

2827
if args.zone is None:
2928
args.zone = args.domain
@@ -52,14 +51,15 @@
5251
if m:
5352
event = m.group(2)
5453
container_id = m.group(1)
55-
logging.info("Got event %s for container %s", event, container_id)
54+
logging.debug("Got event %s for container %s", event, container_id)
5655

5756
if event == "start":
58-
logging.info("Starting %s", container_id)
5957
detail = c.inspect_container(container_id)
6058
container_hostname = detail["Config"]["Hostname"]
6159
container_name = detail["Name"].split('/',1)[1]
6260
container_ip = detail["NetworkSettings"]["IPAddress"]
61+
62+
logging.info("Updating %s to ip (%s|%s) -> %s", container_id, container_hostname, container_name, container_ip)
6363
nsupdate = Popen(['nsupdate', '-k', args.key], stdin=PIPE)
6464
nsupdate.stdin.write(bytes(zone_update_template.format(args.server, args.zone, container_hostname, args.domain, container_ip), "UTF-8"))
6565
if container_name != container_hostname:

0 commit comments

Comments
 (0)