takes_argument_t takes_argument;
/** If not CMD_RUN_TOR, what should Tor do when it starts? */
tor_cmdline_mode_t command;
+ /** If nonzero, set the quiet level to this. 1 is "hush", 2 is "quiet" */
+ int quiet;
} CMDLINE_ONLY_OPTIONS[] = {
{ .name="-f",
.takes_argument=ARGUMENT_NECESSARY },
.takes_argument=ARGUMENT_NECESSARY },
{ .name="--hash-password",
.takes_argument=ARGUMENT_NECESSARY,
- .command=CMD_HASH_PASSWORD },
+ .command=CMD_HASH_PASSWORD,
+ .quiet=1 },
{ .name="--dump-config",
.takes_argument=ARGUMENT_OPTIONAL,
- .command=CMD_DUMP_CONFIG },
+ .command=CMD_DUMP_CONFIG,
+ .quiet=2 },
{ .name="--list-fingerprint",
.command=CMD_LIST_FINGERPRINT },
{ .name="--keygen",
{ .name="--verify-config",
.command=CMD_VERIFY_CONFIG },
{ .name="--ignore-missing-torrc" },
- { .name="--quiet" },
- { .name="--hush" },
+ { .name="--quiet",
+ .quiet=2 },
+ { .name="--hush",
+ .quiet=1 },
{ .name="--version",
- .command=CMD_OTHER },
+ .command=CMD_OTHER,
+ .quiet=1 },
{ .name="--list-modules",
- .command=CMD_OTHER },
+ .command=CMD_OTHER,
+ .quiet=1 },
{ .name="--library-versions",
- .command=CMD_OTHER },
+ .command=CMD_OTHER,
+ .quiet=1 },
{ .name="-h",
- .command=CMD_OTHER },
+ .command=CMD_OTHER,
+ .quiet=1 },
{ .name="--help",
- .command=CMD_OTHER },
+ .command=CMD_OTHER,
+ .quiet=1 },
{ .name="--list-torrc-options",
- .command=CMD_OTHER },
+ .command=CMD_OTHER,
+ .quiet=1 },
{ .name="--list-deprecated-options",
.command=CMD_OTHER },
{ .name="--nt-service" },
is_a_command = true;
result->command = CMDLINE_ONLY_OPTIONS[j].command;
}
+ int quiet = CMDLINE_ONLY_OPTIONS[j].quiet;
+ if (quiet > result->quiet_level)
+ result->quiet_level = quiet;
break;
}
}
hs_init();
{
- /* We search for the "quiet" option first, since it decides whether we
- * will log anything at all to the command line. */
+ /* We check for the "quiet"/"hush" settings first, since they decide
+ whether we log anything at all to stdout. */
parsed_cmdline_t *cmdline;
- const config_line_t *cl = NULL;
cmdline = config_parse_commandline(argc, argv, 1);
- if (cmdline != NULL) {
- cl = cmdline->cmdline_opts;
- }
- for (; cl; cl = cl->next) {
- if (!strcmp(cl->key, "--hush"))
- quiet = 1;
- if (!strcmp(cl->key, "--quiet") ||
- !strcmp(cl->key, "--dump-config"))
- quiet = 2;
- /* The following options imply --hush */
- if (!strcmp(cl->key, "--version") || !strcmp(cl->key, "--digests") ||
- !strcmp(cl->key, "--list-torrc-options") ||
- !strcmp(cl->key, "--library-versions") ||
- !strcmp(cl->key, "--list-modules") ||
- !strcmp(cl->key, "--hash-password") ||
- !strcmp(cl->key, "-h") || !strcmp(cl->key, "--help")) {
- if (quiet < 1)
- quiet = 1;
- }
- }
+ if (cmdline)
+ quiet = cmdline->quiet_level;
parsed_cmdline_free(cmdline);
}
/* give it somewhere to log to initially */
switch (quiet) {
case 2:
- /* no initial logging */
+ /* --quiet: no initial logging */
break;
case 1:
+ /* --hush: log at warning or higher. */
add_temp_log(LOG_WARN);
break;
default: