diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp index 37cddf1f6..9117b14a7 100644 --- a/include/mapnik/json/feature_collection_grammar.hpp +++ b/include/mapnik/json/feature_collection_grammar.hpp @@ -103,7 +103,7 @@ struct feature_collection_grammar : qi::on_error ( feature_collection - , std::cerr + , std::clog << phoenix::val("Error parsing GeoJSON ") << qi::_4 << phoenix::val(" here: \"") diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index d45971817..20b13f9b1 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -316,7 +316,7 @@ struct feature_grammar : on_error ( feature - , std::cerr + , std::clog << phoenix::val("Error! Expecting ") << _4 // what failed? << phoenix::val(" here: \"") diff --git a/include/mapnik/svg/svg_transform_grammar.hpp b/include/mapnik/svg/svg_transform_grammar.hpp index dd23bad39..d6dcf9e3d 100644 --- a/include/mapnik/svg/svg_transform_grammar.hpp +++ b/include/mapnik/svg/svg_transform_grammar.hpp @@ -171,7 +171,7 @@ namespace mapnik { namespace svg { template void operator()(T const& c, qi::unused_type, qi::unused_type) const { - std::cerr << typeid(c).name() << std::endl; + MAPNIK_LOG_DEBUG(svg) << typeid(c).name(); } }; */ diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index d2158bc49..e8d62478e 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -414,7 +414,9 @@ public: { double end_x=0; double end_y=0; - std::cerr << "Curve 3 not implemented" << std::endl; + + MAPNIK_LOG_WARN(cairo_renderer) << "Curve 3 not implemented"; + path.vertex(&end_x, &end_y); curve_to(x,y,x,y,end_x,end_y); @@ -437,7 +439,7 @@ public: } else { - std::cerr << "Unimplemented drawing command: " << cm << std::endl; + MAPNIK_LOG_WARN(cairo_renderer) << "Unimplemented drawing command: " << cm; move_to(x, y); } } @@ -447,7 +449,7 @@ public: } else { - std::cerr << "Unimplemented path command: " << cm << std::endl; + MAPNIK_LOG_WARN(cairo_renderer) << "Unimplemented path command: " << cm; } } } @@ -1330,7 +1332,7 @@ void cairo_renderer_base::start_map_processing(Map const& map) if (writer.first) { //writer.first->add_box(label_ext, feature, t_, writer.second); - std::cerr << "### Warning metawriter not yet supported for LINE placement\n"; + MAPNIK_LOG_WARN(cairo_renderer) << "metawriter not yet supported for LINE placement"; } } } @@ -1457,7 +1459,7 @@ void cairo_renderer_base::start_map_processing(Map const& map) if (writer.first) { //writer.first->add_box(label_ext, feature, t_, writer.second); - std::cerr << "### Warning metawriter not yet supported for LINE placement\n"; + MAPNIK_LOG_WARN(cairo_renderer) << "metawriter not yet supported for LINE placement"; } agg::conv_transform trans(marker, matrix); diff --git a/src/formatting/base.cpp b/src/formatting/base.cpp index 3b88d581c..3b78229fe 100644 --- a/src/formatting/base.cpp +++ b/src/formatting/base.cpp @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ + // mapnik +#include #include #include #include @@ -34,9 +36,7 @@ namespace formatting { void node::to_xml(boost::property_tree::ptree &xml) const { //TODO: Should this throw a config_error? -#ifdef MAPNIK_DEBUG - std::cerr << "Error: Trying to write unsupported node type to XML.\n"; -#endif + MAPNIK_LOG_ERROR(base) << "Trying to write unsupported node type to XML."; } node_ptr node::from_xml(xml_node const& xml) diff --git a/src/formatting/expression.cpp b/src/formatting/expression.cpp index 5dfff9972..e2e184884 100644 --- a/src/formatting/expression.cpp +++ b/src/formatting/expression.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ // mapnik +#include #include #include #include @@ -29,12 +30,10 @@ #include #include -// boost -namespace mapnik -{ -namespace formatting -{ +namespace mapnik { +namespace formatting { + using boost::property_tree::ptree; void expression_format::to_xml(boost::property_tree::ptree &xml) const { @@ -108,9 +107,7 @@ void expression_format::apply(char_properties const& p, const Feature &feature, if (child_) { child_->apply(new_properties, feature, output); } else { -#ifdef MAPNIK_DEBUG - std::cerr << "Warning: Useless format: No text to format\n"; -#endif + MAPNIK_LOG_WARN(expression) << "Useless format: No text to format"; } } diff --git a/src/formatting/format.cpp b/src/formatting/format.cpp index f1fad9d3e..3f94ab77a 100644 --- a/src/formatting/format.cpp +++ b/src/formatting/format.cpp @@ -19,14 +19,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ + +// mapnik +#include #include #include #include namespace mapnik { +namespace formatting { + using boost::property_tree::ptree; -namespace formatting { void format_node::to_xml(ptree &xml) const { ptree &new_node = xml.push_back(ptree::value_type("Format", ptree()))->second; @@ -88,9 +92,7 @@ void format_node::apply(char_properties const& p, const Feature &feature, proces if (child_) { child_->apply(new_properties, feature, output); } else { -#ifdef MAPNIK_DEBUG - std::cerr << "Warning: Useless format: No text to format\n"; -#endif + MAPNIK_LOG_WARN(format) << "Useless format: No text to format"; } } diff --git a/src/graphics.cpp b/src/graphics.cpp index 08887bc22..5cb71b8a6 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ // mapnik +#include #include #include #include @@ -60,7 +61,7 @@ image_32::image_32(Cairo::RefPtr rhs) painted_ = true; if (rhs->get_format() != Cairo::FORMAT_ARGB32) { - std::cerr << "Unable to convert this Cairo format\n"; + MAPNIK_LOG_WARN(graphics) << "Unable to convert this Cairo format"; return; // throw exception ?? } diff --git a/src/map.cpp b/src/map.cpp index bd080b7e8..6b87dce16 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -596,7 +596,7 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const } catch (...) { - std::cerr << "Exception caught in \"query_point\"" << std::endl; + MAPNIK_LOG_ERROR(map) << "Exception caught in \"query_point\""; } } return featureset_ptr(); @@ -639,7 +639,7 @@ featureset_ptr Map::query_map_point(unsigned index, double x, double y) const } catch (...) { - std::cerr << "Exception caught in \"query_map_point\"" << std::endl; + MAPNIK_LOG_ERROR(map) << "Exception caught in \"query_map_point\""; } } return featureset_ptr(); diff --git a/src/mapped_memory_cache.cpp b/src/mapped_memory_cache.cpp index 28a26ab1e..de917b02c 100644 --- a/src/mapped_memory_cache.cpp +++ b/src/mapped_memory_cache.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ // mapnik +#include #include // boost @@ -82,13 +83,15 @@ boost::optional mapped_memory_cache::find(std::string const& } catch (...) { - std::cerr << "Exception caught while loading mapping memory file: " << uri << std::endl; + MAPNIK_LOG_ERROR(mapped_memory_cache) << "Exception caught while loading mapping memory file: " << uri; } } - /*else - { - std::cerr << "### WARNING Memory region does not exist file: " << uri << std::endl; - }*/ + /* + else + { + MAPNIK_LOG_WARN(mapped_memory_cache) << "Memory region does not exist file: " << uri; + } + */ return result; } diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp index 7de9e24c4..af736ba3f 100644 --- a/src/marker_cache.cpp +++ b/src/marker_cache.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ // mapnik +#include #include #include #include @@ -103,7 +104,7 @@ boost::optional marker_cache::find(std::string const& uri, bool upda } catch (...) { - std::cerr << "Exception caught while loading SVG: " << uri << std::endl; + MAPNIK_LOG_ERROR(marker_cache) << "Exception caught while loading SVG: " << uri; } } else @@ -129,13 +130,13 @@ boost::optional marker_cache::find(std::string const& uri, bool upda catch (...) { - std::cerr << "Exception caught while loading image: " << uri << std::endl; + MAPNIK_LOG_ERROR(marker_cache) << "Exception caught while loading image: " << uri; } } } else { - std::cerr << "### WARNING Marker does not exist: " << uri << std::endl; + MAPNIK_LOG_WARN(marker_cache) << "Marker does not exist: " << uri; } return result; } diff --git a/src/markers_placement.cpp b/src/markers_placement.cpp index eb6c955f0..d55f3ce28 100644 --- a/src/markers_placement.cpp +++ b/src/markers_placement.cpp @@ -108,11 +108,11 @@ bool markers_placement::get_point( //Error for this marker is too large. Skip to the next position. if (abs(error_) > max_error_ * spacing_) { - if (error_ > spacing_) { + if (error_ > spacing_) + { error_ = 0; //Avoid moving backwards -#ifdef MAPNIK_DEBUG - std::cerr << "WARNING: Extremely large error in markers_placement. Please file a bug report.\n"; -#endif + + MAPNIK_LOG_WARN(markers_placement) << "Extremely large error in markers_placement. Please file a bug report."; } spacing_left_ += spacing_ - error_; error_ = 0; @@ -211,15 +211,14 @@ void markers_placement::set_spacing_left(double sl, bool allo double delta_error = sl - spacing_left_; if (!allow_negative && delta_error < 0) { -#ifdef MAPNIK_DEBUG - std::cerr << "WARNING: Unexpected negative error in markers_placement. Please file a bug report.\n"; -#endif + MAPNIK_LOG_WARN(markers_placement) << "Unexpected negative error in markers_placement. Please file a bug report."; + return; } #ifdef MAPNIK_DEBUG if (delta_error == 0.0) { - std::cerr << "WARNING: Not moving at all in set_spacing_left()! Please file a bug report.\n"; + MAPNIK_LOG_WARN(markers_placement) << "Not moving at all in set_spacing_left()! Please file a bug report."; } #endif error_ += delta_error; diff --git a/src/memory.cpp b/src/memory.cpp index e27852edd..d8671c11b 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -20,6 +20,8 @@ * *****************************************************************************/ +// mapnik +#include #include namespace mapnik @@ -46,7 +48,7 @@ void Object::operator delete(void* p) void Object::operator delete(void* , MemoryManager* ) { - //std::cerr << "operator delete with Manager " << std::hex << p << " " << manager << std::endl; + //MAPNIK_LOG_DEBUG(memory) << "operator delete with Manager " << std::hex << p << " " << manager; } inline size_t MemoryUtils::alignPointerSize(size_t ptrSize) diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index ab211a0d7..eefbf1b6e 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -806,7 +806,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: index++; if (index >= path_positions.size()) //Bail out if we run off the end of the shape { - //std::cerr << "FAIL: Out of space" << std::endl; + //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Out of space"; return std::auto_ptr(NULL); } new_x = path_positions[index].x; @@ -843,7 +843,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: if (p.max_char_angle_delta > 0 && fabs(angle_delta) > p.max_char_angle_delta) { - //std::cerr << "FAIL: Too Bendy!" << std::endl; + //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Too Bendy!"; return std::auto_ptr(NULL); } @@ -897,7 +897,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: else { //Otherwise we have failed to find a placement - //std::cerr << "FAIL: Double upside-down!" << std::endl; + //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Double upside-down!"; return std::auto_ptr(NULL); } } @@ -949,15 +949,15 @@ bool placement_finder::test_placement(std::auto_ptr const& ) ) { - //std::cerr << "No Intersects:" << !dimensions_.intersects(e) << ": " << e << " @ " << dimensions_ << std::endl; - //std::cerr << "No Placements:" << !detector_.has_placement(e, info.get_string(), p.minimum_distance) << std::endl; + //MAPNIK_LOG_ERROR(placement_finder) << "No Intersects:" << !dimensions_.intersects(e) << ": " << e << " @ " << dimensions_; + //MAPNIK_LOG_ERROR(placement_finder) << "No Placements:" << !detector_.has_placement(e, info.get_string(), p.minimum_distance); status = false; break; } if (p.avoid_edges && !dimensions_.contains(e)) { - //std::cerr << "Fail avoid edges" << std::endl; + //MAPNIK_LOG_ERROR(placement_finder) << "Fail avoid edges"; status = false; break; } diff --git a/src/svg_parser.cpp b/src/svg_parser.cpp index 2114ac7aa..2195859be 100644 --- a/src/svg_parser.cpp +++ b/src/svg_parser.cpp @@ -79,7 +79,7 @@ agg::rgba8 parse_color(const char* str) } catch (mapnik::config_error & ex) { - std::cerr << ex.what() << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << ex.what(); } return agg::rgba8(c.red(), c.green(), c.blue(), c.alpha()); } @@ -147,10 +147,10 @@ void svg_parser::parse(std::string const& filename) xmlFreeTextReader(reader); if (ret != 0) { - std::cerr << "Failed to parse " << filename << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << "Failed to parse " << filename; } } else { - std::cerr << "Unable to open " << filename << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << "Unable to open " << filename; } } @@ -279,7 +279,7 @@ void svg_parser::parse_attr(const xmlChar * name, const xmlChar * value ) } else { - std::cerr << "Failed to find gradient fill: " << id << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << "Failed to find gradient fill: " << id; } } else @@ -316,7 +316,7 @@ void svg_parser::parse_attr(const xmlChar * name, const xmlChar * value ) } else { - std::cerr << "Failed to find gradient fill: " << id << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << "Failed to find gradient fill: " << id; } } else @@ -650,7 +650,7 @@ void svg_parser::parse_gradient_stop(xmlTextReaderPtr reader) } catch (mapnik::config_error & ex) { - std::cerr << ex.what() << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << ex.what(); } } else if (kv.first == "stop-opacity") @@ -669,7 +669,7 @@ void svg_parser::parse_gradient_stop(xmlTextReaderPtr reader) } catch (mapnik::config_error & ex) { - std::cerr << ex.what() << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << ex.what(); } } @@ -684,8 +684,13 @@ void svg_parser::parse_gradient_stop(xmlTextReaderPtr reader) temporary_gradient_.second.add_stop(offset, stop_color); - //std::cerr << "\tFound Stop: " << offset << " " << (unsigned)stop_color.red() << " " << (unsigned)stop_color.green() << " " << (unsigned)stop_color.blue() << " " << (unsigned)stop_color.alpha() << std::endl; - + /* + MAPNIK_LOG_DEBUG(svg_parser) << "\tFound Stop: " << offset << " " + << (unsigned)stop_color.red() << " " + << (unsigned)stop_color.green() << " " + << (unsigned)stop_color.blue() << " " + << (unsigned)stop_color.alpha(); + */ } bool svg_parser::parse_common_gradient(xmlTextReaderPtr reader) @@ -714,12 +719,12 @@ bool svg_parser::parse_common_gradient(xmlTextReaderPtr reader) std::string linkid = (const char *) &value[1]; if (gradient_map_.count(linkid)) { - //std::cerr << "\tLoading linked gradient properties from " << linkid << std::endl; + //MAPNIK_LOG_DEBUG(svg_parser) << "\tLoading linked gradient properties from " << linkid; temporary_gradient_.second = gradient_map_[linkid]; } else { - std::cerr << "Failed to find linked gradient " << linkid << std::endl; + MAPNIK_LOG_ERROR(svg_parser) << "Failed to find linked gradient " << linkid; } } @@ -801,7 +806,7 @@ void svg_parser::parse_radial_gradient(xmlTextReaderPtr reader) // add this here in case we have no end tag, will be replaced if we do gradient_map_[temporary_gradient_.first] = temporary_gradient_.second; - //std::cerr << "Found Radial Gradient: " << " " << cx << " " << cy << " " << fx << " " << fy << " " << r << std::endl; + //MAPNIK_LOG_DEBUG(svg_parser) << "Found Radial Gradient: " << " " << cx << " " << cy << " " << fx << " " << fy << " " << r; } void svg_parser::parse_linear_gradient(xmlTextReaderPtr reader) @@ -839,7 +844,7 @@ void svg_parser::parse_linear_gradient(xmlTextReaderPtr reader) // add this here in case we have no end tag, will be replaced if we do gradient_map_[temporary_gradient_.first] = temporary_gradient_.second; - //std::cerr << "Found Linear Gradient: " << "(" << x1 << " " << y1 << "),(" << x2 << " " << y2 << ")" << std::endl; + //MAPNIK_LOG_DEBUG(svg_parser) << "Found Linear Gradient: " << "(" << x1 << " " << y1 << "),(" << x2 << " " << y2 << ")"; } void svg_parser::parse_pattern(xmlTextReaderPtr reader) diff --git a/src/symbolizer.cpp b/src/symbolizer.cpp index 409baf9ce..8e426b9ca 100644 --- a/src/symbolizer.cpp +++ b/src/symbolizer.cpp @@ -60,7 +60,7 @@ void symbolizer_base::cache_metawriters(Map const &m) properties_complete_.insert(properties_.begin(), properties_.end()); } else { properties_complete_.clear(); - std::cerr << "WARNING: Metawriter '" << writer_name_ << "' used but not defined.\n"; + MAPNIK_LOG_WARN(symbolizer) << "Metawriter '" << writer_name_ << "' used but not defined."; } } diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index cfcc83902..c468b6fea 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -207,9 +207,7 @@ void text_symbolizer_helper::initialize_points() } else { -#ifdef MAPNIK_DEBUG - std::cerr << "ERROR: Unknown placement type in initialize_points();\n"; -#endif + MAPNIK_LOG_ERROR(symbolizer_helpers) << "ERROR: Unknown placement type in initialize_points()"; } prj_trans_.backward(label_x, label_y, z); t_.forward(&label_x, &label_y); diff --git a/src/text_placements/simple.cpp b/src/text_placements/simple.cpp index cefa199fa..51af29fb2 100644 --- a/src/text_placements/simple.cpp +++ b/src/text_placements/simple.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ // mapnik +#include #include #include #include @@ -94,7 +95,7 @@ bool text_placement_info_simple::next_position_only() displacement = std::make_pair(-abs(pdisp.first), abs(pdisp.second)); break; default: - std::cerr << "WARNING: Unknown placement\n"; + MAPNIK_LOG_WARN(text_placements) << "Unknown placement"; } position_state++; return true; @@ -146,11 +147,11 @@ void text_placements_simple::set_positions(std::string positions) ); if (first != last) { - std::cerr << "WARNING: Could not parse text_placement_simple placement string ('" << positions << "').\n"; + MAPNIK_LOG_WARN(text_placements) << "Could not parse text_placement_simple placement string ('" << positions << "')"; } if (direction_.size() == 0) { - std::cerr << "WARNING: text_placements_simple with no valid placements! ('"<< positions<<"')\n"; + MAPNIK_LOG_WARN(text_placements) << "text_placements_simple with no valid placements! ('"<< positions<<"')"; } } diff --git a/src/text_properties.cpp b/src/text_properties.cpp index 7948712ab..1f7a87cb8 100644 --- a/src/text_properties.cpp +++ b/src/text_properties.cpp @@ -65,9 +65,7 @@ void text_symbolizer_properties::process(processed_text &output, Feature const& if (tree_) { tree_->apply(format, feature, output); } else { -#ifdef MAPNIK_DEBUG - std::cerr << "Warning: text_symbolizer_properties can't produce text: No formatting tree!\n"; -#endif + MAPNIK_LOG_WARN(text_properties) << "text_symbolizer_properties can't produce text: No formatting tree!"; } } @@ -122,7 +120,8 @@ void text_symbolizer_properties::from_xml(xml_node const &sym, fontset_map const optional name_ = sym.get_opt_attr("name"); if (name_) { - std::cerr << "### WARNING: Using 'name' in TextSymbolizer/ShieldSymbolizer is deprecated!\n"; + MAPNIK_LOG_WARN(text_placements) << "Using 'name' in TextSymbolizer/ShieldSymbolizer is deprecated!"; + set_old_style_expression(parse_expression(*name_, "utf8")); }