Mon, 04 Jan 2016 17:05:19 +0000
geoip: Improved logging
geoip.lua | file | annotate | diff | comparison | revisions |
--- a/geoip.lua Mon Jan 04 17:04:29 2016 +0000 +++ b/geoip.lua Mon Jan 04 17:05:19 2016 +0000 @@ -2,10 +2,15 @@ local ok, err = pcall(function () local city_db_path = os.getenv("GEOIP_CITY_DB"); - if not city_db_path then return; end + if not city_db_path then + log("debug", "GEOIP_CITY_DB not set"); + return; + end + log("debug", "Loading geoip database"); local city_db = assert(require "geoip.city".open(city_db_path)); - + log("debug", "Loaded geoip database successfully"); + events.add_handler("new-client", function (info) local ip = info.conn:ip(); local location = city_db:query_by_addr(ip); @@ -21,6 +26,8 @@ table.insert(l, location.country_name); end conn.location = table.concat(l, ", "); + else + log("debug", "Failed to find location for IP %q: %s", tostring(ip), tostring(err)); end end); end)