Skip to content
Browse files

- replace all instances of std::cerr with MAPNIK_LOG_*

  • Loading branch information...
1 parent a0feb26 commit fb94e4a2ec2d260e88641d2bfbe13dcf9ae7be55 @kunitoki kunitoki committed
View
2 include/mapnik/json/feature_collection_grammar.hpp
@@ -103,7 +103,7 @@ struct feature_collection_grammar :
qi::on_error<qi::fail>
(
feature_collection
- , std::cerr
+ , std::clog
<< phoenix::val("Error parsing GeoJSON ")
<< qi::_4
<< phoenix::val(" here: \"")
View
2 include/mapnik/json/feature_grammar.hpp
@@ -316,7 +316,7 @@ struct feature_grammar :
on_error<fail>
(
feature
- , std::cerr
+ , std::clog
<< phoenix::val("Error! Expecting ")
<< _4 // what failed?
<< phoenix::val(" here: \"")
View
2 include/mapnik/svg/svg_transform_grammar.hpp
@@ -171,7 +171,7 @@ namespace mapnik { namespace svg {
template <typename T>
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();
}
};
*/
View
12 src/cairo_renderer.cpp
@@ -414,7 +414,9 @@ class cairo_context : private boost::noncopyable
{
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 @@ class cairo_context : private boost::noncopyable
}
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 @@ class cairo_context : private boost::noncopyable
}
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<agg::path_storage, agg::trans_affine> trans(marker, matrix);
View
6 src/formatting/base.cpp
@@ -19,7 +19,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
+
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/formatting/base.hpp>
#include <mapnik/formatting/list.hpp>
#include <mapnik/formatting/registry.hpp>
@@ -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)
View
13 src/formatting/expression.cpp
@@ -21,6 +21,7 @@
*****************************************************************************/
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/formatting/expression.hpp>
#include <mapnik/ptree_helpers.hpp>
#include <mapnik/expression_string.hpp>
@@ -29,12 +30,10 @@
#include <mapnik/feature.hpp>
#include <mapnik/xml_node.hpp>
-// 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";
}
}
View
10 src/formatting/format.cpp
@@ -19,14 +19,18 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
+
+// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/formatting/format.hpp>
#include <mapnik/ptree_helpers.hpp>
#include <mapnik/xml_node.hpp>
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";
}
}
View
3 src/graphics.cpp
@@ -21,6 +21,7 @@
*****************************************************************************/
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/global.hpp>
@@ -60,7 +61,7 @@ image_32::image_32(Cairo::RefPtr<Cairo::ImageSurface> 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 ??
}
View
4 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();
View
13 src/mapped_memory_cache.cpp
@@ -21,6 +21,7 @@
*****************************************************************************/
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/mapped_memory_cache.hpp>
// boost
@@ -82,13 +83,15 @@ boost::optional<mapped_region_ptr> 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;
}
View
7 src/marker_cache.cpp
@@ -21,6 +21,7 @@
*****************************************************************************/
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/marker.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/svg/svg_parser.hpp>
@@ -103,7 +104,7 @@ boost::optional<marker_ptr> 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_ptr> 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;
}
View
15 src/markers_placement.cpp
@@ -108,11 +108,11 @@ bool markers_placement<Locator, Detector>::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<Locator, Detector>::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;
View
4 src/memory.cpp
@@ -20,6 +20,8 @@
*
*****************************************************************************/
+// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/memory.hpp>
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)
View
12 src/placement_finder.cpp
@@ -806,7 +806,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::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<text_path>(NULL);
}
new_x = path_positions[index].x;
@@ -843,7 +843,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::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<text_path>(NULL);
}
@@ -897,7 +897,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::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<text_path>(NULL);
}
}
@@ -949,15 +949,15 @@ bool placement_finder<DetectorT>::test_placement(std::auto_ptr<text_path> 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;
}
View
31 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)
View
2 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.";
}
}
View
4 src/symbolizer_helpers.cpp
@@ -207,9 +207,7 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::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);
View
7 src/text_placements/simple.cpp
@@ -21,6 +21,7 @@
*****************************************************************************/
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/text_placements/simple.hpp>
#include <mapnik/ptree_helpers.hpp>
#include <mapnik/xml_node.hpp>
@@ -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<<"')";
}
}
View
7 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<std::string> name_ = sym.get_opt_attr<std::string>("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"));
}

0 comments on commit fb94e4a

Please sign in to comment.
Something went wrong with that request. Please try again.