Skip to content

Commit 52a217f

Browse files
authored
Merge pull request #1356 from joto/improved-log-messages
Better and more consistent log messages in pgsql and flex output
2 parents 2b0778a + f824a03 commit 52a217f

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

src/flex-table.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ void table_connection_t::stop(bool updateable, bool append)
210210

211211
sql += " ORDER BY ";
212212
if (postgis_version.major == 2 && postgis_version.minor < 4) {
213-
log_debug("Using GeoHash for clustering");
213+
log_debug("Using GeoHash for clustering table '{}'",
214+
table().name());
214215
if (table().geom_column().srid() == 4326) {
215216
sql += "ST_GeoHash({},10)"_format(table().geom_column().name());
216217
} else {
@@ -220,7 +221,8 @@ void table_connection_t::stop(bool updateable, bool append)
220221
}
221222
sql += " COLLATE \"C\"";
222223
} else {
223-
log_debug("Using native order for clustering");
224+
log_debug("Using native order for clustering table '{}'",
225+
table().name());
224226
// Since Postgis 2.4 the order function for geometries gives
225227
// useful results.
226228
sql += table().geom_column().name();

src/middle-pgsql.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ void middle_pgsql_t::table_desc::stop(std::string const &conninfo,
9595
pg_conn_t sql_conn{conninfo};
9696

9797
if (droptemp) {
98-
log_info("Dropping table: {}", name());
98+
log_info("Dropping table '{}'", name());
9999
auto const qual_name = qualified_name(
100100
m_copy_target->schema, m_copy_target->name);
101101
sql_conn.exec("DROP TABLE IF EXISTS {}"_format(qual_name));
102102
} else if (build_indexes && !m_create_fw_dep_indexes.empty()) {
103-
log_info("Building index on table: {}", name());
103+
log_info("Building index on table '{}'", name());
104104
sql_conn.exec(m_create_fw_dep_indexes);
105105
}
106106

107-
log_info("Done postprocessing table: {} in {}", name(),
107+
log_info("Done postprocessing on table '{}' in {}", name(),
108108
util::human_readable_duration(timer.stop()));
109109
}
110110

@@ -575,7 +575,7 @@ void middle_pgsql_t::start()
575575
// (Re)create tables.
576576
m_db_connection.exec("SET client_min_messages = WARNING");
577577
for (auto const &table : m_tables) {
578-
log_debug("Setting up table: {}", table.name());
578+
log_debug("Setting up table '{}'", table.name());
579579
auto const qual_name = qualified_name(
580580
table.m_copy_target->schema, table.m_copy_target->name);
581581
m_db_connection.exec(

src/osm2pgsql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
133133
// create indexes.
134134
osmdata.stop();
135135

136-
log_info("Osm2pgsql took {} overall",
136+
log_info("Osm2pgsql took {} overall.",
137137
util::human_readable_duration(timer_overall.stop()));
138138
} catch (std::exception const &e) {
139139
log_error("{}", e.what());

src/table.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void table_t::start(std::string const &conninfo, std::string const &table_space)
7575
m_table_space = tablespace_clause(table_space);
7676

7777
connect();
78-
log_info("Setting up table: {}", m_target->name);
78+
log_info("Setting up table '{}'", m_target->name);
7979
m_sql_conn->exec("SET client_min_messages = WARNING");
8080
auto const qual_name = qualified_name(m_target->schema, m_target->name);
8181
auto const qual_tmp_name = qualified_name(
@@ -176,7 +176,7 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
176176
if (!m_append) {
177177
util::timer_t timer;
178178

179-
log_info("Sorting data and creating indexes for {}", m_target->name);
179+
log_info("Clustering table '{}' by geometry...", m_target->name);
180180

181181
// Notices about invalid geometries are expected and can be ignored
182182
// because they say nothing about the validity of the geometry in OSM.
@@ -197,15 +197,17 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
197197

198198
sql += " ORDER BY ";
199199
if (postgis_version.major == 2 && postgis_version.minor < 4) {
200-
log_debug("Using GeoHash for clustering");
200+
log_debug("Using GeoHash for clustering table '{}'",
201+
m_target->name);
201202
if (m_srid == "4326") {
202203
sql += "ST_GeoHash(way,10)";
203204
} else {
204205
sql += "ST_GeoHash(ST_Transform(ST_Envelope(way),4326),10)";
205206
}
206207
sql += " COLLATE \"C\"";
207208
} else {
208-
log_debug("Using native order for clustering");
209+
log_debug("Using native order for clustering table '{}'",
210+
m_target->name);
209211
// Since Postgis 2.4 the order function for geometries gives
210212
// useful results.
211213
sql += "way";
@@ -216,7 +218,8 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
216218
m_sql_conn->exec("DROP TABLE {}"_format(qual_name));
217219
m_sql_conn->exec(
218220
"ALTER TABLE {} RENAME TO {}"_format(qual_tmp_name, m_target->name));
219-
log_info("Creating geometry index on {}", m_target->name);
221+
222+
log_info("Creating geometry index on table '{}'...", m_target->name);
220223

221224
// Use fillfactor 100 for un-updatable imports
222225
m_sql_conn->exec("CREATE INDEX ON {} USING GIST (way) {} {}"_format(
@@ -225,7 +228,7 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
225228

226229
/* slim mode needs this to be able to apply diffs */
227230
if (updateable) {
228-
log_info("Creating osm_id index on {}", m_target->name);
231+
log_info("Creating osm_id index on table '{}'...", m_target->name);
229232
m_sql_conn->exec(
230233
"CREATE INDEX ON {} USING BTREE (osm_id) {}"_format(
231234
qual_name, tablespace_clause(table_space_index)));
@@ -234,9 +237,11 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
234237
m_target->name, "way");
235238
}
236239
}
240+
237241
/* Create hstore index if selected */
238242
if (enable_hstore_index) {
239-
log_info("Creating hstore indexes on {}", m_target->name);
243+
log_info("Creating hstore indexes on table '{}'...",
244+
m_target->name);
240245
if (m_hstore_mode != hstore_column::none) {
241246
m_sql_conn->exec(
242247
"CREATE INDEX ON {} USING GIN (tags) {}"_format(
@@ -251,7 +256,8 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
251256
}
252257
log_info("Analyzing table '{}'...", m_target->name);
253258
m_sql_conn->exec("ANALYZE {}"_format(qual_name));
254-
log_info("All indexes on {} created in {}", m_target->name,
259+
260+
log_info("All postprocessing on table '{}' done in {}.", m_target->name,
255261
util::human_readable_duration(timer.stop()));
256262
}
257263
teardown();

0 commit comments

Comments
 (0)