Documentation and fixed a bug with the log

This commit is contained in:
Kristian Krsnik 2023-10-13 14:09:03 +02:00
parent 23214ff78f
commit cfeb253cac
Signed by: Kristian
GPG Key ID: FD1330AC9F909E85

View File

@ -57,7 +57,7 @@ def loadSettings(path: str | None) -> dict:
def log(logline: str, path: str = './log.txt', stdout: bool = False) -> None: def log(logline: str, path: str = './log.txt', stdout: bool = False) -> None:
''' '''
Appends logline at the end of the file file with a timestamp Appends `logline` at the end of the file file with a timestamp.
`logline` The line to log. `logline` The line to log.
@ -130,8 +130,8 @@ def checkRecords(api: dict[str, dict[str, list[str]]], current_ip: str, log: Cal
records_to_renew[key][domain] = list(set(records_to_renew[key][domain]) - set(record['rrset_name'] for record in ( records_to_renew[key][domain] = list(set(records_to_renew[key][domain]) - set(record['rrset_name'] for record in (
filter(lambda x: current_ip in x['rrset_values'], response.json())))) filter(lambda x: current_ip in x['rrset_values'], response.json()))))
if records_to_renew[key][domain] != []: if (records := records_to_renew[key][domain]) != []:
log(f"[INFO][{','.join(records_to_renew)}] Record need to be renewed") log(f"[INFO][{','.join(records)}] Records need to be renewed")
else: else:
log(f"[ERROR][{domain}][{response.status_code}] {response.json()}") log(f"[ERROR][{domain}][{response.status_code}] {response.json()}")