Skip to content

Commit aa53e60

Browse files
authored
Improved --verbose messaging for render_expired (openstreetmap#461)
1 parent 3a633e6 commit aa53e60

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

src/render_expired.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,14 @@ int main(int argc, char **argv)
380380
}
381381

382382
if (verbose) {
383-
g_logger(G_LOG_LEVEL_WARNING, "bad line %d: %s", num_all, tmp);
383+
g_logger(G_LOG_LEVEL_WARNING, "Read invalid line: %s", tmp);
384384
}
385385

386386
continue;
387387
}
388388

389389
if (verbose) {
390-
g_logger(G_LOG_LEVEL_MESSAGE, "read: x=%d y=%d z=%d", x, y, z);
390+
g_logger(G_LOG_LEVEL_MESSAGE, "Read valid line: %d/%d/%d", z, x, y);
391391
}
392392

393393
while (z > max_zoom) {
@@ -402,35 +402,35 @@ int main(int argc, char **argv)
402402
z++;
403403
}
404404

405-
if (verbose) {
406-
g_logger(G_LOG_LEVEL_MESSAGE, "loop: x=%d y=%d z=%d up to z=%d", x, y, z, min_zoom);
407-
}
408-
409405
num_read++;
410406

411407
if (progress && (num_read % 100) == 0) {
412408
g_logger(G_LOG_LEVEL_INFO, "Read and expanded %i tiles from list.", num_read);
413409
}
414410

411+
if (verbose) {
412+
g_logger(G_LOG_LEVEL_MESSAGE, "Starting loop on %d/%d/%d for zoom levels %d to %d", z, x, y, min_zoom, max_zoom);
413+
}
414+
415415
for (; z >= min_zoom; z--, x >>= 1, y >>= 1) {
416416
char name[PATH_MAX];
417417

418-
if (verbose) {
419-
g_logger(G_LOG_LEVEL_MESSAGE, "process: x=%d y=%d z=%d", x, y, z);
420-
}
421-
422418
// don't do anything if this tile was already requested.
423419
// renderd does keep a list internally to avoid enqueing the same tile
424420
// twice but in case it has already rendered the tile we don't want to
425421
// cause extra work.
426422
if (TILE_REQUESTED(z - excess_zoomlevels, x >> excess_zoomlevels, y >> excess_zoomlevels)) {
427423
if (verbose) {
428-
g_logger(G_LOG_LEVEL_MESSAGE, "already requested");
424+
g_logger(G_LOG_LEVEL_MESSAGE, "Already requested metatile containing '%d/%d/%d', moving on to next input line", z, x, y);
429425
}
430426

431427
break;
432428
}
433429

430+
if (verbose) {
431+
g_logger(G_LOG_LEVEL_MESSAGE, "Processing: %d/%d/%d", z, x, y);
432+
}
433+
434434
// mark tile as requested. (do this even if, below, the tile is not
435435
// actually requested due to not being present on disk, to avoid
436436
// unnecessary later stat'ing).
@@ -442,34 +442,35 @@ int main(int argc, char **argv)
442442

443443
num_all++;
444444
s = store->tile_stat(store, mapname, "", x, y, z);
445+
store->tile_storage_id(store, mapname, "", x, y, z, name);
445446

446447
if (s.size > 0) { // Tile exists
447448
// tile exists on disk; delete/touch/render it
448449
if (delete_from_passed && z >= delete_from) {
449450
if (progress) {
450-
g_logger(G_LOG_LEVEL_MESSAGE, "delete: %s", store->tile_storage_id(store, mapname, "", x, y, z, name));
451+
g_logger(G_LOG_LEVEL_MESSAGE, "Deleting '%s'", name);
451452
}
452453

453454
store->metatile_delete(store, mapname, x, y, z);
454455
num_unlink++;
455456
} else if (touch_from_passed && z >= touch_from) {
456457
if (progress) {
457-
g_logger(G_LOG_LEVEL_MESSAGE, "touch: %s", store->tile_storage_id(store, mapname, "", x, y, z, name));
458+
g_logger(G_LOG_LEVEL_MESSAGE, "Touching '%s'", name);
458459
}
459460

460461
store->metatile_expire(store, mapname, x, y, z);
461462
num_touch++;
462463
} else if (doRender) {
463464
if (progress) {
464-
g_logger(G_LOG_LEVEL_MESSAGE, "render: %s", store->tile_storage_id(store, mapname, "", x, y, z, name));
465+
g_logger(G_LOG_LEVEL_MESSAGE, "Rendering '%s'", name);
465466
}
466467

467468
enqueue(mapname, x, y, z);
468469
num_render++;
469470
}
470471
} else {
471472
if (verbose) {
472-
g_logger(G_LOG_LEVEL_MESSAGE, "not on disk: %s", store->tile_storage_id(store, mapname, "", x, y, z, name));
473+
g_logger(G_LOG_LEVEL_MESSAGE, "Skipping '%s' (metatile does not exist)", name);
473474
}
474475

475476
num_ignore++;

tests/render_expired_test.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,32 @@ TEST_CASE("render_expired specific", "specific testing")
103103
}
104104

105105
SECTION("--config with valid --map, --verbose and bad input lines", "should return 0") {
106+
std::string input = "z/x/y\nx y z\n";
106107
std::string map = "example-map";
107108
std::string tile_dir = P_tmpdir;
108109
std::vector<std::string> argv = {"--config", renderd_conf, "--map", map, "--tile-dir", tile_dir, "--verbose"};
109-
std::string input = "z/x/y\nx y z\n";
110110

111111
int status = run_command(test_binary, argv, input);
112112
REQUIRE(WEXITSTATUS(status) == 0);
113-
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("bad line 0: z/x/y"));
114-
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("bad line 0: x y z"));
113+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Read invalid line: z/x/y"));
114+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Read invalid line: x y z"));
115+
}
116+
117+
SECTION("--touch-from 0 with --max-zoom 19, --verbose and overlapping input lines", "should return 0") {
118+
std::string input = "16/56715/4908\n17/113420/9816\n18/226860/19632\n19/453726/39265\n";
119+
std::string tile_dir = P_tmpdir;
120+
std::vector<std::string> argv = {"--max-zoom", std::to_string(19), "--tile-dir", tile_dir, "--touch-from", std::to_string(0), "--verbose"};
121+
122+
int status = run_command(test_binary, argv, input);
123+
REQUIRE(WEXITSTATUS(status) == 0);
124+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Raising --min-zoom from '0' to '3'"));
125+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Read valid line: 16/56715/4908"));
126+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Read valid line: 17/113420/9816"));
127+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Already requested metatile containing '15/28355/2454'"));
128+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Read valid line: 18/226860/19632"));
129+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Already requested metatile containing '19/453720/39264'"));
130+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Read valid line: 19/453726/39265"));
131+
REQUIRE_THAT(err_log_lines, Catch::Matchers::Contains("Already requested metatile containing '19/453726/39265'"));
115132
}
116133

117134
SECTION("--tile-dir with invalid option", "should return 1") {

0 commit comments

Comments
 (0)