Permalink
Browse files

remove 'info' and 'fatal' severities for logging to simplify framewor…

…k - closes #1400
  • Loading branch information...
1 parent 62d6699 commit a986aedd057476702688b7a877ad671fe1bc1700 Dane Springmeyer committed Aug 16, 2012
View
@@ -33,6 +33,7 @@ except:
HAS_DISTUTILS = False
LIBDIR_SCHEMA_DEFAULT='lib'
+severities = ['debug', 'warn', 'error', 'none']
py3 = None
@@ -343,7 +344,7 @@ opts.AddVariables(
# Variables for logging and statistics
BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'),
BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'),
- ('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. "info", "debug", "warn", "error", "fatal", "none")', 'error'),
+ ('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities), 'error'),
# Other variables
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
@@ -1470,7 +1471,6 @@ if not preconfigured:
ndebug_flags = '-DNDEBUG'
# Enable logging in debug mode (always) and release mode (when specified)
- severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none']
if env['DEFAULT_LOG_SEVERITY']:
if env['DEFAULT_LOG_SEVERITY'] not in severities:
severities_list = ', '.join(["'%s'" % s for s in severities])
@@ -39,22 +39,14 @@ void export_logger()
;
enum_<mapnik::logger::severity_type>("severity_type")
- .value("Info", logger::info)
.value("Debug", logger::debug)
.value("Warn", logger::warn)
.value("Error", logger::error)
- .value("Fatal", logger::fatal)
.value("None", logger::none)
;
class_<logger,bases<singleton<logger,CreateStatic> >,
boost::noncopyable>("logger",no_init)
- .def_readonly("Info", logger::info)
- .def_readonly("Debug", logger::debug)
- .def_readonly("Warn", logger::warn)
- .def_readonly("Error", logger::error)
- .def_readonly("Fatal", logger::fatal)
- .def_readonly("None", logger::none)
.def("get_severity", &logger::get_severity)
.def("set_severity", &logger::set_severity)
.def("get_object_severity", &logger::get_object_severity)
View
@@ -55,12 +55,10 @@ namespace mapnik {
public:
enum severity_type
{
- info,
- debug,
- warn,
- error,
- fatal,
- none
+ debug = 0,
+ warn = 1,
+ error = 2
+ none = 3
};
typedef boost::unordered_map<std::string, severity_type> severity_map;
@@ -180,7 +178,7 @@ namespace mapnik {
/*
Base log class, should not log anything when no MAPNIK_LOG is defined
- This is used for info/debug/warn reporting that should not output
+ This is used for debug/warn reporting that should not output
anything when not compiling for speed.
*/
template<template <class Ch, class Tr, class A> class OutputPolicy,
@@ -240,7 +238,7 @@ namespace mapnik {
/*
Base log class that always log, regardless of MAPNIK_LOG.
- This is used for error/fatal reporting that should always log something
+ This is used for error reporting that should always log something
*/
template<template <class Ch, class Tr, class A> class OutputPolicy,
logger::severity_type Severity,
@@ -288,20 +286,18 @@ namespace mapnik {
};
- typedef base_log<clog_sink, logger::info> base_log_info;
typedef base_log<clog_sink, logger::debug> base_log_debug;
typedef base_log<clog_sink, logger::warn> base_log_warn;
typedef base_log_always<clog_sink, logger::error> base_log_error;
- typedef base_log_always<clog_sink, logger::fatal> base_log_fatal;
} // namespace detail
// real interfaces
- class MAPNIK_DECL info : public detail::base_log_info {
+ class MAPNIK_DECL warn : public detail::base_log_warn {
public:
- info() : detail::base_log_info() {}
- info(const char* object_name) : detail::base_log_info(object_name) {}
+ warn() : detail::base_log_warn() {}
+ warn(const char* object_name) : detail::base_log_warn(object_name) {}
};
class MAPNIK_DECL debug : public detail::base_log_debug {
@@ -310,31 +306,16 @@ namespace mapnik {
debug(const char* object_name) : detail::base_log_debug(object_name) {}
};
- class MAPNIK_DECL warn : public detail::base_log_warn {
- public:
- warn() : detail::base_log_warn() {}
- warn(const char* object_name) : detail::base_log_warn(object_name) {}
- };
-
class MAPNIK_DECL error : public detail::base_log_error {
public:
error() : detail::base_log_error() {}
error(const char* object_name) : detail::base_log_error(object_name) {}
};
- class MAPNIK_DECL fatal : public detail::base_log_fatal {
- public:
- fatal() : detail::base_log_fatal() {}
- fatal(const char* object_name) : detail::base_log_fatal(object_name) {}
- };
-
-
// logging helpers
- #define MAPNIK_LOG_INFO(s) mapnik::info(#s)
#define MAPNIK_LOG_DEBUG(s) mapnik::debug(#s)
#define MAPNIK_LOG_WARN(s) mapnik::warn(#s)
#define MAPNIK_LOG_ERROR(s) mapnik::error(#s)
- #define MAPNIK_LOG_FATAL(s) mapnik::fatal(#s)
}
#endif // MAPNIK_DEBUG_HPP
@@ -261,7 +261,7 @@ class MAPNIK_DECL enumeration {
{
if (our_strings_[i] == 0 )
{
- MAPNIK_LOG_FATAL(enumeration)
+ MAPNIK_LOG_ERROR(enumeration)
<< "### FATAL: Not enough strings for enum "
<< our_name_ << " defined in file '" << filename
<< "' at line " << line_no;
@@ -270,7 +270,7 @@ class MAPNIK_DECL enumeration {
}
if ( std::string("") != our_strings_[THE_MAX])
{
- MAPNIK_LOG_FATAL(enumeration)
+ MAPNIK_LOG_ERROR(enumeration)
<< "### FATAL: The string array for enum " << our_name_
<< " defined in file '" << filename << "' at line " << line_no
<< " has too many items or is not terminated with an "
@@ -146,7 +146,6 @@ class svg_renderer : boost::noncopyable
unsigned g = stop_color.green();
unsigned b = stop_color.blue();
unsigned a = stop_color.alpha();
- //MAPNIK_LOG_DEBUG(svg_renderer) << "svg_renderer: r=" << r << ",g=" << g << ",b=" << b << ",a=" << a;
m_gradient_lut.add_color(st.first, agg::rgba8_pre(r, g, b, int(a * opacity)));
}
m_gradient_lut.build_lut();
@@ -152,7 +152,7 @@ featureset_ptr kismet_datasource::features(query const& q) const
{
if (! is_bound_) bind();
- MAPNIK_LOG_INFO(kismet) << "kismet_datasource::features()";
+ MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features()";
// TODO: use box2d to filter bbox before adding to featureset_ptr
// mapnik::box2d<double> const& e = q.get_bbox();
@@ -170,7 +170,7 @@ featureset_ptr kismet_datasource::features_at_point(coord2d const& pt) const
{
if (! is_bound_) bind();
- MAPNIK_LOG_INFO(kismet) << "kismet_datasource::features_at_point()";
+ MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features_at_point()";
return featureset_ptr();
}
@@ -106,9 +106,10 @@ feature_ptr osm_featureset<filterT>::next()
static_cast<osm_way*>(cur_item)->nodes[count]->lat);
}
feature->add_geometry(geom);
- } else
+ }
+ else
{
- MAPNIK_LOG_FATAL(osm_featureset) << "Current item is neither node nor way.\n";
+ MAPNIK_LOG_ERROR(osm_featureset) << "Current item is neither node nor way.\n";
}
std::set<std::string>::const_iterator itr = attribute_names_.begin();
View
@@ -58,9 +58,9 @@ bool logger::format_env_check_ = true;
logger::severity_type logger::severity_level_ =
#if MAPNIK_DEFAULT_LOG_SEVERITY == 0
- logger::info
- #elif MAPNIK_DEFAULT_LOG_SEVERITY == 1
logger::debug
+ #elif MAPNIK_DEFAULT_LOG_SEVERITY == 1
+ logger::info
#elif MAPNIK_DEFAULT_LOG_SEVERITY == 2
logger::warn
#elif MAPNIK_DEFAULT_LOG_SEVERITY == 3
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+from nose.tools import *
+import mapnik
+
+def test_logger_init():
+ eq_(mapnik.severity_type.Debug,0)
+ eq_(mapnik.severity_type.Warn,1)
+ eq_(mapnik.severity_type.Error,2)
+ eq_(mapnik.severity_type.None,3)
+ default = mapnik.logger.get_severity()
+ mapnik.logger.set_severity(mapnik.severity_type.Debug)
+ eq_(mapnik.logger.get_severity(),mapnik.severity_type.Debug)
+ mapnik.logger.set_severity(default)
+
+if __name__ == "__main__":
+ [eval(run)() for run in dir() if 'test_' in run]

0 comments on commit a986aed

Please sign in to comment.