Skip to content

Commit 326c016

Browse files
committed
Add more useful verbose logging
1 parent 3d984ae commit 326c016

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sqlgrep/sqlgrep.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ vector<column_details> get_all_string_columns(session & sql)
122122
for (auto& column : details)
123123
{
124124
column.number_of_rows = get_number_of_rows(sql, column.schema, column.table, column.column, cache);
125+
write_verbose("Number of rows in "s + column.schema + "." + column.table + "." + column.column + ": " + to_string(column.number_of_rows) + ".");
125126
}
126127

127128
return details;
@@ -177,7 +178,9 @@ void display_all_matches(session & sql, vector<column_details> const & all_colum
177178

178179
completed_rows += column.number_of_rows;
179180
auto const now = chrono::steady_clock::now();
180-
if (!matches.empty() || (now - last_displayed).count() / 1'000'000'000 > 2) {
181+
auto const nanoseconds_per_second = 1'000'000'000;
182+
write_verbose("Completed "s + to_string(completed_rows) + " rows in " + to_string((now - start_time).count() / nanoseconds_per_second) + " seconds.");
183+
if (!matches.empty() || (now - last_displayed).count() / nanoseconds_per_second > 2) {
181184
write_progress(total_rows, completed_rows, now - start_time);
182185
last_displayed = now;
183186
}
@@ -193,6 +196,7 @@ void find_and_display_matches(string_view to_find, int const maximum_results_per
193196
auto all_columns = get_all_string_columns(sql);
194197
cout << "Searching " << all_columns.size() << " columns for '" << to_find << "'..." << endl;
195198
uint64_t const total_rows = accumulate(begin(all_columns), end(all_columns), 0, [](int acc, column_details const & b) { return acc + b.number_of_rows; });
199+
write_verbose("Total number of rows to search: "s + to_string(total_rows) + ".");
196200
display_all_matches(sql, all_columns, to_find, maximum_results_per_column, total_rows);
197201
}
198202

0 commit comments

Comments
 (0)