diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-03-12 15:39:07 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-03-12 15:39:07 -0700 |
commit | ba933b3f452156bf0a4ce63a0de89c9bcb861387 (patch) | |
tree | be7aea599e6f1d7a84f28965508ba6c8527547a9 /src/mbgl | |
parent | 4c7939b96eddb53f1700edfaea7abe1fa5b0e886 (diff) | |
parent | 124b49562ddfe951ad82243b56a859a46a58bd57 (diff) | |
download | qtlocation-mapboxgl-ba933b3f452156bf0a4ce63a0de89c9bcb861387.tar.gz |
Merge pull request #984 from mapbox/log_stderr_printf
Get rid of printf and cout by using Log::*
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/geometry/glyph_atlas.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/geometry/line_atlas.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/geometry/sprite_atlas.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/map/tile_parser.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/renderer/fill_bucket.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.cpp | 25 | ||||
-rw-r--r-- | src/mbgl/style/style_parser.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/clip_ids.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/util/raster.cpp | 3 |
9 files changed, 35 insertions, 26 deletions
diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp index 4aaa77f38d..67e6303200 100644 --- a/src/mbgl/geometry/glyph_atlas.cpp +++ b/src/mbgl/geometry/glyph_atlas.cpp @@ -1,6 +1,7 @@ #include <mbgl/geometry/glyph_atlas.hpp> #include <mbgl/platform/gl.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/platform/platform.hpp> #include <cassert> @@ -60,7 +61,7 @@ Rect<uint16_t> GlyphAtlas::addGlyph_impl(uint64_t tile_id, const std::string& fa Rect<uint16_t> rect = bin.allocate(pack_width, pack_height); if (rect.w == 0) { - fprintf(stderr, "glyph bitmap overflow"); + Log::Error(Event::OpenGL, "glyph bitmap overflow"); return rect; } diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index b396d93259..bf6944fbc0 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -1,5 +1,6 @@ #include <mbgl/geometry/line_atlas.hpp> #include <mbgl/platform/gl.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/platform/platform.hpp> #include <sstream> @@ -46,7 +47,7 @@ LinePatternPos LineAtlas::addDash(const std::vector<float> &dasharray, bool roun const uint8_t offset = 128; if (nextRow + dashheight > height) { - fprintf(stderr, "[WARNING] line atlas bitmap overflow\n"); + Log::Warning(Event::OpenGL, "line atlas bitmap overflow"); return LinePatternPos(); } diff --git a/src/mbgl/geometry/sprite_atlas.cpp b/src/mbgl/geometry/sprite_atlas.cpp index 93440b0e6c..077550ff74 100644 --- a/src/mbgl/geometry/sprite_atlas.cpp +++ b/src/mbgl/geometry/sprite_atlas.cpp @@ -1,5 +1,6 @@ #include <mbgl/geometry/sprite_atlas.hpp> #include <mbgl/platform/gl.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/platform/platform.hpp> #include <mbgl/util/math.hpp> #include <mbgl/util/std.hpp> @@ -129,7 +130,7 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::getImage(const std::string& name, cons Rect<dimension> rect = allocateImage(pos.width / pos.pixelRatio, pos.height / pos.pixelRatio); if (rect.w == 0) { if (debug::spriteWarnings) { - fprintf(stderr, "[WARNING] sprite atlas bitmap overflow\n"); + Log::Warning(Event::Sprite, "sprite atlas bitmap overflow"); } return rect; } @@ -210,7 +211,7 @@ void SpriteAtlas::setSprite(util::ptr<Sprite> sprite_) { const SpritePosition& src = sprite->getSpritePosition(name); if (!src) { if (debug::spriteWarnings) { - fprintf(stderr, "[WARNING] sprite doesn't have image with name '%s'\n", name.c_str()); + Log::Warning(Event::Sprite, "sprite doesn't have image with name '%s'", name.c_str()); } return true; } @@ -220,7 +221,7 @@ void SpriteAtlas::setSprite(util::ptr<Sprite> sprite_) { return true; } else { if (debug::spriteWarnings) { - fprintf(stderr, "[WARNING] sprite icon dimension mismatch\n"); + Log::Warning(Event::Sprite, "sprite icon dimension mismatch"); } return false; } diff --git a/src/mbgl/map/tile_parser.cpp b/src/mbgl/map/tile_parser.cpp index 48f5b1405f..c50c394e2c 100644 --- a/src/mbgl/map/tile_parser.cpp +++ b/src/mbgl/map/tile_parser.cpp @@ -1,5 +1,6 @@ #include <mbgl/map/tile_parser.hpp> #include <mbgl/map/vector_tile_data.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/style/style.hpp> #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer_group.hpp> @@ -85,7 +86,7 @@ void TileParser::parseStyleLayers(util::ptr<const StyleLayerGroup> group) { } } } else { - fprintf(stderr, "[WARNING] layer '%s' does not have buckets\n", layer_desc->id.c_str()); + Log::Warning(Event::ParseTile, "layer '%s' does not have buckets", layer_desc->id.c_str()); } } } @@ -198,12 +199,13 @@ std::unique_ptr<Bucket> TileParser::createBucket(const StyleBucket &bucketDesc) } else if (bucketDesc.type == StyleLayerType::Raster) { return nullptr; } else { - fprintf(stderr, "[WARNING] unknown bucket render type for layer '%s' (source layer '%s')\n", bucketDesc.name.c_str(), bucketDesc.source_layer.c_str()); + Log::Warning(Event::ParseTile, "unknown bucket render type for layer '%s' (source layer '%s')", + bucketDesc.name.c_str(), bucketDesc.source_layer.c_str()); } } else { // The layer specified in the bucket does not exist. Do nothing. if (debug::tileParseWarnings) { - fprintf(stderr, "[WARNING] layer '%s' does not exist in tile %d/%d/%d\n", + Log::Warning(Event::ParseTile, "layer '%s' does not exist in tile %d/%d/%d", bucketDesc.source_layer.c_str(), tile.id.z, tile.id.x, tile.id.y); } } diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 19ee302125..26d0d1f4be 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -6,6 +6,7 @@ #include <mbgl/style/style_layout.hpp> #include <mbgl/util/std.hpp> #include <mbgl/platform/gl.hpp> +#include <mbgl/platform/log.hpp> #include <cassert> @@ -173,12 +174,12 @@ void FillBucket::tessellate() { } else { #if defined(DEBUG) // TODO: We're missing a vertex that was not part of the line. - fprintf(stderr, "undefined element buffer\n"); + Log::Error(Event::OpenGL, "undefined element buffer"); #endif } } else { #if defined(DEBUG) - fprintf(stderr, "undefined element buffer\n"); + Log::Error(Event::OpenGL, "undefined element buffer"); #endif } } @@ -187,7 +188,7 @@ void FillBucket::tessellate() { triangleGroup.elements_length += triangle_count; } else { #if defined(DEBUG) - fprintf(stderr, "tessellation failed\n"); + Log::Error(Event::OpenGL, "tessellation failed"); #endif } diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 9f66d6c446..544198fe61 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -1,4 +1,5 @@ #include <mbgl/renderer/painter.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/style/style.hpp> #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer_group.hpp> @@ -234,11 +235,11 @@ void Painter::render(const Style& style, const std::set<util::ptr<StyleSource>>& frameHistory.record(time, state.getNormalizedZoom()); // Actually render the layers - if (debug::renderTree) { std::cout << "{" << std::endl; indent++; } + if (debug::renderTree) { Log::Info(Event::Render, "{"); indent++; } if (style.layers) { renderLayers(*style.layers); } - if (debug::renderTree) { std::cout << "}" << std::endl; indent--; } + if (debug::renderTree) { Log::Info(Event::Render, "}"); indent--; } // Finalize the rendering, e.g. by calling debug render calls per tile. // This guarantees that we have at least one function per tile called. @@ -258,7 +259,7 @@ void Painter::renderLayers(const StyleLayerGroup &group) { // objects first. if (debug::renderTree) { - std::cout << std::string(indent++ * 4, ' ') << "OPAQUE {" << std::endl; + Log::Info(Event::Render, "%*s%s", indent++ * 4, "", "OPAQUE {"); } int i = 0; for (auto it = group.layers.rbegin(), end = group.layers.rend(); it != end; ++it, ++i) { @@ -267,14 +268,14 @@ void Painter::renderLayers(const StyleLayerGroup &group) { renderLayer(**it); } if (debug::renderTree) { - std::cout << std::string(--indent * 4, ' ') << "}" << std::endl; + Log::Info(Event::Render, "%*s%s", --indent * 4, "", "}"); } // - SECOND PASS ----------------------------------------------------------- // Make a second pass, rendering translucent objects. This time, we render // bottom-to-top. if (debug::renderTree) { - std::cout << std::string(indent++ * 4, ' ') << "TRANSLUCENT {" << std::endl; + Log::Info(Event::Render, "%*s%s", indent++ * 4, "", "TRANSLUCENT {"); } --i; for (auto it = group.layers.begin(), end = group.layers.end(); it != end; ++it, --i) { @@ -283,7 +284,7 @@ void Painter::renderLayers(const StyleLayerGroup &group) { renderLayer(**it); } if (debug::renderTree) { - std::cout << std::string(--indent * 4, ' ') << "}" << std::endl; + Log::Info(Event::Render, "%*s%s", --indent * 4, "", "}"); } } @@ -293,20 +294,20 @@ void Painter::renderLayer(const StyleLayer &layer_desc, const Tile::ID* id, cons // This layer defines a background color/image. if (debug::renderTree) { - std::cout << std::string(indent * 4, ' ') << "- " << layer_desc.id << " (" - << layer_desc.type << ")" << std::endl; + Log::Info(Event::Render, "%*s- %s (%s)", indent * 4, "", layer_desc.id.c_str(), + StyleLayerTypeClass(layer_desc.type).c_str()); } renderBackground(layer_desc); } else { // This is a singular layer. if (!layer_desc.bucket) { - fprintf(stderr, "[WARNING] layer '%s' is missing bucket\n", layer_desc.id.c_str()); + Log::Warning(Event::Render, "layer '%s' is missing bucket", layer_desc.id.c_str()); return; } if (!layer_desc.bucket->style_source) { - fprintf(stderr, "[WARNING] can't find source for layer '%s'\n", layer_desc.id.c_str()); + Log::Warning(Event::Render, "can't find source for layer '%s'", layer_desc.id.c_str()); return; } @@ -349,8 +350,8 @@ void Painter::renderLayer(const StyleLayer &layer_desc, const Tile::ID* id, cons } if (debug::renderTree) { - std::cout << std::string(indent * 4, ' ') << "- " << layer_desc.id << " (" - << layer_desc.type << ")" << std::endl; + Log::Info(Event::Render, "%*s- %s (%s)", indent * 4, "", layer_desc.id.c_str(), + StyleLayerTypeClass(layer_desc.type).c_str()); } if (!id) { style_source.source->render(*this, layer_desc); diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 6d84679685..25bf9bf665 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -75,7 +75,7 @@ template<> bool StyleParser::parseRenderProperty(JSVal value, bool &target, cons target = property.GetBool(); return true; } else { - fprintf(stderr, "[WARNING] '%s' must be a boolean\n", name); + Log::Warning(Event::ParseStyle, "'%s' must be a boolean", name); } } return false; diff --git a/src/mbgl/util/clip_ids.cpp b/src/mbgl/util/clip_ids.cpp index 9c391c38ad..8b1dcf8dd0 100644 --- a/src/mbgl/util/clip_ids.cpp +++ b/src/mbgl/util/clip_ids.cpp @@ -1,6 +1,7 @@ #include <mbgl/util/clip_ids.hpp> #include <mbgl/map/tile.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/util/math.hpp> #include <list> @@ -89,7 +90,7 @@ void ClipIDGenerator::update(std::forward_list<Tile *> tiles) { } if (bit_offset > 8) { - fprintf(stderr, "stencil mask overflow\n"); + Log::Error(Event::OpenGL, "stencil mask overflow"); } } diff --git a/src/mbgl/util/raster.cpp b/src/mbgl/util/raster.cpp index 724936972c..72e266af94 100644 --- a/src/mbgl/util/raster.cpp +++ b/src/mbgl/util/raster.cpp @@ -1,5 +1,6 @@ #include <mbgl/platform/platform.hpp> #include <mbgl/platform/gl.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/util/raster.hpp> #include <mbgl/util/uv_detail.hpp> @@ -40,7 +41,7 @@ bool Raster::load(const std::string &data) { void Raster::bind(bool linear) { if (!width || !height) { - fprintf(stderr, "trying to bind texture without dimension\n"); + Log::Error(Event::OpenGL, "trying to bind texture without dimension"); return; } |