From bc92a46c6415a38dcd716f0b1770102019447827 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 4 Mar 2016 10:43:14 +0100 Subject: [PATCH] Add support for MAPNIK_LOG_SEVERITY env variable --- utils/mapnik-render/mapnik-render.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utils/mapnik-render/mapnik-render.cpp b/utils/mapnik-render/mapnik-render.cpp index c39922639..4dbe166c6 100644 --- a/utils/mapnik-render/mapnik-render.cpp +++ b/utils/mapnik-render/mapnik-render.cpp @@ -30,6 +30,22 @@ int main (int argc,char** argv) mapnik::logger logger; logger.set_severity(mapnik::logger::error); + const char *envsev = std::getenv("MAPNIK_LOG_SEVERITY"); + if ( envsev != nullptr) + { + if ( ! strncmp(envsev, "deb", 3) ) + logger.set_severity(mapnik::logger::debug); + else if ( ! strncmp(envsev, "warn", 4) ) + logger.set_severity(mapnik::logger::warn); + else if ( ! strncmp(envsev, "err", 3) ) + logger.set_severity(mapnik::logger::error); + else + MAPNIK_LOG_ERROR("logger") << + "Invalid value for MAPNIK_LOG_SEVERITY" + " environment variable, expected " + "'debug', 'warning' or 'error'"; + } + try { po::options_description desc("mapnik-render utility");