From 8575c1078164c0b6a4f65a32525482a917f02cc0 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Sun, 2 Aug 2015 21:44:40 -0300 Subject: [PATCH] unit-test: Fix the geoip debug code --- src/operators/geo_lookup.cc | 10 +++++++--- src/utils/geo_lookup.cc | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/operators/geo_lookup.cc b/src/operators/geo_lookup.cc index 3350ef6b..af655596 100644 --- a/src/operators/geo_lookup.cc +++ b/src/operators/geo_lookup.cc @@ -35,9 +35,13 @@ bool GeoLookup::evaluate(Assay *assay, const std::string &exp) { GeoIPRecord *gir; bool ret = true; - //bool ret = Utils::GeoLookup::getInstance().lookup(exp, &gir, - // std::bind(&GeoLookup::debug, this, assay, _1, _2)); - + if (assay) { + ret = Utils::GeoLookup::getInstance().lookup(exp, &gir, + std::bind(&GeoLookup::debug, this, assay, _1, _2)); + } else { + ret = Utils::GeoLookup::getInstance().lookup(exp, &gir, + nullptr); + } if (ret && gir) { if (gir->country_code) { assay->store_variable("GEO:COUNTRY_CODE", gir->country_code); diff --git a/src/utils/geo_lookup.cc b/src/utils/geo_lookup.cc index e1d898e6..d860c114 100644 --- a/src/utils/geo_lookup.cc +++ b/src/utils/geo_lookup.cc @@ -56,7 +56,10 @@ bool GeoLookup::setDataBase(const std::string& filePath) { bool GeoLookup::lookup(const std::string& target, GeoIPRecord **gir, std::function debug) { if (m_gi == NULL) { - debug(4, "GeoIP: Database is not open. Use: SecGeoLookupDb directive."); + if (debug) { + debug(4, "GeoIP: Database is not open. " \ + "Use: SecGeoLookupDb directive."); + } return false; }