Skip to content

Commit 99fbf5e

Browse files
committed
Change default for --log-progress option from auto to true
1 parent 31ec03c commit 99fbf5e

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

docs/osm2pgsql.1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ Set log level (`debug', `info' (default), `warn', or `error').
6969
.TP
7070
.B \-\-log\-progress=VALUE
7171
Enable (\f[C]true\f[]) or disable (\f[C]false\f[]) progress logging.
72-
The default is \f[C]auto\f[] which will enable progress logging on the
72+
Setting this to \f[C]auto\f[] will enable progress logging on the
7373
console and disable it if the output is redirected to a file.
74+
Default: true.
7475
.RS
7576
.RE
7677
.TP

docs/osm2pgsql.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ mandatory for short options too.
5757
: Set log level ('debug', 'info' (default), 'warn', or 'error').
5858

5959
\--log-progress=VALUE
60-
: Enable (`true`) or disable (`false`) progress logging. The default is
61-
`auto` which will enable progress logging on the console and disable it
62-
if the output is redirected to a file.
60+
: Enable (`true`) or disable (`false`) progress logging. Setting this to
61+
`auto` will enable progress logging on the console and disable it
62+
if the output is redirected to a file. Default: true.
6363

6464
\--log-sql
6565
: Enable logging of SQL commands for debugging.

src/logging.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ class logger
6363
bool show_progress() const noexcept { return m_show_progress; }
6464

6565
void enable_progress() noexcept { m_show_progress = true; }
66-
6766
void disable_progress() noexcept { m_show_progress = false; }
67+
void auto_progress() noexcept { m_show_progress = osmium::util::isatty(2); }
6868

6969
private:
7070
log_level m_current_level = log_level::info;
7171
bool m_log_sql = false;
7272
bool m_log_sql_data = false;
73-
bool m_show_progress = osmium::util::isatty(2);
73+
bool m_show_progress = true;
7474

7575
}; // class logger
7676

src/options.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ Logging options:\n\
152152
--log-level=LEVEL Set log level ('debug', 'info' (default), 'warn',\n\
153153
or 'error').\n\
154154
--log-progress=VALUE Enable ('true') or disable ('false') progress\n\
155-
logging. The default is 'auto' which will enable progress\n\
155+
logging. If set to 'auto' osm2pgsql will enable progress\n\
156156
logging on the console and disable it if the output is\n\
157-
redirected to a file.\n\
157+
redirected to a file. Default: true.\n\
158158
--log-sql Enable logging of SQL commands for debugging.\n\
159159
--log-sql-data Enable logging of all data added to the database.\n\
160160
-v|--verbose Same as '--log-level=debug'.\n\
@@ -608,13 +608,11 @@ options_t::options_t(int argc, char *argv[]) : options_t()
608608
break;
609609
case 401: // --log-progress=VALUE
610610
if (std::strcmp(optarg, "true") == 0) {
611-
log_progress = optarg;
612611
get_logger().enable_progress();
613612
} else if (std::strcmp(optarg, "false") == 0) {
614-
log_progress = optarg;
615613
get_logger().disable_progress();
616614
} else if (std::strcmp(optarg, "auto") == 0) {
617-
log_progress = optarg;
615+
get_logger().auto_progress();
618616
} else {
619617
throw std::runtime_error{
620618
"Unknown value for --log-progress option: {}"_format(
@@ -729,10 +727,4 @@ void options_t::check_options()
729727
"You have to set the config file with the -S|--style option."};
730728
}
731729
}
732-
733-
if (log_progress.empty() && !get_logger().show_progress()) {
734-
log_info("Progress logging disabled because you are not logging to the "
735-
"console.");
736-
log_info(" Use --log-progress=true to override this.");
737-
}
738730
}

src/options.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class options_t
137137
database_options_t database_options;
138138
std::string output_backend{"pgsql"};
139139
std::string input_format; ///< input file format (default: autodetect)
140-
std::string log_progress; ///< setting of the --log-progress option
141140
osmium::Box bbox;
142141
bool extra_attributes = false;
143142

0 commit comments

Comments
 (0)