Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verbose Flag Prints to stderr, not stdout #119

Open
jdnordy opened this issue Sep 18, 2020 · 2 comments
Open

verbose Flag Prints to stderr, not stdout #119

jdnordy opened this issue Sep 18, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@jdnordy
Copy link

jdnordy commented Sep 18, 2020

Bug:

When running geoipudate -v, I noticed that it prints to stderr instead of stdout. I ran into this issue when trying to print output to a log file.

Example 1:
geoipupdate -v 1>/var/www/test.txt

terminal:

Using config file /usr/local/etc/GeoIP.conf
Using database directory {DATABASE_DIR}
Performing get filename request to https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-City
Acquired lock file lock ({FILE_PATH}/.geoipupdate.lock)
Calculated MD5 sum for {FILE_PATH}/GeoLite2-City.mmdb: d90975ccfa5460d7ee2b2a9a4ebd93ae
Performing update request to https://updates.maxmind.com/geoip/databases/GeoLite2-City/update?db_md5=d90975ccfa5460d7ee2b2a9a4ebd93ae
No new updates available for GeoLite2-City

test.txt:

// empty

Example 2:
geoipupdate -v 2>/var/www/test.txt

terminal:

// empty

test.txt

Using config file /usr/local/etc/GeoIP.conf
Using database directory {DATABASE_DIR}
Performing get filename request to https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-City
Acquired lock file lock ({FILE_PATH}/.geoipupdate.lock)
Calculated MD5 sum for {FILE_PATH}/GeoLite2-City.mmdb: d90975ccfa5460d7ee2b2a9a4ebd93ae
Performing update request to https://updates.maxmind.com/geoip/databases/GeoLite2-City/update?db_md5=d90975ccfa5460d7ee2b2a9a4ebd93ae
No new updates available for GeoLite2-City

Possible Solution:

Instead of of using log.Printf() for verbose flag output, use fmt.Printf()

@horgh
Copy link
Contributor

horgh commented Oct 1, 2020

I agree it can be unexpected, but I don't know that it's necessarily a bug or necessary to change. stderr is often used this way, e.g. see its description on https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html ("standard error (for writing diagnostic output)").

@horgh horgh added the enhancement New feature or request label Oct 1, 2020
@skymal4ik
Copy link

Vote for using stdout for such messages too - it is just additional information, not errors IMO. As for me, it breaks automation (e.g. ansible playbooks) logic, - it's just weird to check stderr if new update was received or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants