Logs via logging library
This commit is contained in:
@@ -29,6 +29,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
|
import logging
|
||||||
from typing import Optional, Tuple, Dict, Any
|
from typing import Optional, Tuple, Dict, Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@@ -200,24 +201,24 @@ def update_once() -> Dict[str, Any]:
|
|||||||
|
|
||||||
def pretty_print(result: Dict[str, Any]):
|
def pretty_print(result: Dict[str, Any]):
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
print(pformat(result))
|
logging.info(pformat(result))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print(f"Starting updater for {FULL_DOMAIN} (zone {ZONE}) backend={BACKEND}")
|
logging.info(f"Starting updater for {FULL_DOMAIN} (zone {ZONE}) backend={BACKEND}")
|
||||||
if BACKEND not in ("HTTP_API", "RFC2136"):
|
if BACKEND not in ("HTTP_API", "RFC2136"):
|
||||||
print("ERROR: BACKEND must be HTTP_API or RFC2136", file=sys.stderr)
|
logging.error("BACKEND must be HTTP_API or RFC2136", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
if BACKEND == "HTTP_API" and not TDNS_API_TOKEN:
|
if BACKEND == "HTTP_API" and not TDNS_API_TOKEN:
|
||||||
print("ERROR: TDNS_API_TOKEN required for HTTP_API backend", file=sys.stderr)
|
logging.error("TDNS_API_TOKEN required for HTTP_API backend", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
if BACKEND == "RFC2136" and not RFC2136_SERVER:
|
if BACKEND == "RFC2136" and not RFC2136_SERVER:
|
||||||
print("ERROR: RFC2136_SERVER required for RFC2136 backend", file=sys.stderr)
|
logging.error("RFC2136_SERVER required for RFC2136 backend", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
if not ZONE:
|
if not ZONE:
|
||||||
print("ERROR: ZONE not defined", file=sys.stderr)
|
logging.error("ZONE not defined", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
if not RECORD_NAME:
|
if not RECORD_NAME:
|
||||||
print("ERROR: RECORD_NAME not defined", file=sys.stderr)
|
logging.error("RECORD_NAME not defined", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Reference in New Issue
Block a user