TimothyYe / godns

A dynamic DNS client tool that supports AliDNS, Cloudflare, Google Domains, DNSPod, HE.net & DuckDNS & DreamHost, etc, written in Go.
https://timothyye.github.io/godns/
Apache License 2.0
1.5k stars 220 forks source link

Logging tweaks - moving to formatted logging (from Info to Infof) and adding whitespaces where necessary. #139

Closed adam-ah closed 2 years ago

adam-ah commented 2 years ago

Console example

Logging example to console before

INFO[0000] GoDNS started, entering main loop...
INFO[0000] Creating DNS handler with provider:Cloudflare
INFO[0000] Checking IP for domain domain.com
INFO[0003] Querying records with type:A
 NFO[0003] Record OK: vpn.domain.com - 0.0.0.0

Notice the missing I at INFO on last line and the crowded provider:Cloudflare and type:A log lines.

After

INFO[0000] GoDNS started, entering main loop...
INFO[0000] Creating DNS handler with provider: Cloudflare
INFO[0000] Checking IP for domain domain.com
INFO[0001] Querying records with type: A
INFO[0001] Record OK: vpn.domain.com - 0.0.0.0

File log example

Log redirected to file before

time="2022-03-26T10:20:01+11:00" level=info msg="GoDNS started, entering main loop..."
time="2022-03-26T10:20:01+11:00" level=info msg="Creating DNS handler with provider:Cloudflare"
time="2022-03-26T10:20:02+11:00" level=info msg="Checking IP for domain domain.com"
time="2022-03-26T10:20:06+11:00" level=info msg="Querying records with type:A"
time="2022-03-26T10:20:08+11:00" level=info msg="Record OK: vpn.domain.com - 0.0.0.0\r\n"

Notice the invalid \r\n at the end of the log line

After

time="2022-03-26T10:59:24+11:00" level=info msg="GoDNS started, entering main loop..."
time="2022-03-26T10:59:24+11:00" level=info msg="Creating DNS handler with provider: Cloudflare"
time="2022-03-26T10:59:25+11:00" level=info msg="Checking IP for domain domain.com"
time="2022-03-26T10:59:26+11:00" level=info msg="Querying records with type: A"
time="2022-03-26T10:59:26+11:00" level=info msg="Record OK: vpn.domain.com - 0.0.0.0"
TimothyYe commented 2 years ago

Thanks for the contribution!