# HG changeset patch # User Matthew Wild # Date 1451927119 0 # Node ID fed4cf6b1f43faa56c3d1f21adbd29ab8c73bf9e # Parent fd7b581560d5e9d6c46387efe5485ae65907da82 geoip: Improved logging diff -r fd7b581560d5 -r fed4cf6b1f43 geoip.lua --- 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)