Use 'logging' module for first outputs in 'cmdline' module

This commit is contained in:
Thomas Jensen 2024-02-22 21:53:25 +01:00
parent f5e7d7b31e
commit c0bba2adf1
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB

View File

@ -102,7 +102,7 @@ void usage_long(FILE *st)
fprintf(st, " -m, --mend Mend (repair) box\n"); fprintf(st, " -m, --mend Mend (repair) box\n");
fprintf(st, " -n, --encoding <enc> Character encoding of input and output [default: %s]\n", locale_charset()); fprintf(st, " -n, --encoding <enc> Character encoding of input and output [default: %s]\n", locale_charset());
fprintf(st, " -p, --padding <fmt> Padding [default: none]\n"); fprintf(st, " -p, --padding <fmt> Padding [default: none]\n");
fprintf(st, " -q, --tag-query <qry> Query the list of designs by tag\n"); /* with "(undoc)" as query, trigger undocumented webui stuff instead */ fprintf(st, " -q, --tag-query <qry> Query the list of designs by tag\n"); /* with "(undoc)" as query, trigger undocumented behavior instead */
fprintf(st, " -r, --remove Remove box\n"); fprintf(st, " -r, --remove Remove box\n");
fprintf(st, " -s, --size <wxh> Box size (width w and/or height h)\n"); fprintf(st, " -s, --size <wxh> Box size (width w and/or height h)\n");
fprintf(st, " -t, --tabs <str> Tab stop distance and expansion [default: %de]\n", DEF_TABSTOP); fprintf(st, " -t, --tabs <str> Tab stop distance and expansion [default: %de]\n", DEF_TABSTOP);
@ -631,36 +631,47 @@ static int input_output_files(opt_t *result, char *argv[], int optind)
static void print_debug_info(opt_t *result) static void print_debug_info(opt_t *result)
{ {
if (result != NULL) { if (result != NULL && is_debug_logging(MAIN)) {
#if defined(DEBUG) log_debug(__FILE__, MAIN, "Command line option settings (excerpt):\n");
fprintf (stderr, "Command line option settings (excerpt):\n"); log_debug(__FILE__, MAIN, " - Alignment (-a): horiz %c, vert %c\n",
fprintf (stderr, "- Alignment (-a): horiz %c, vert %c\n",
result->halign ? result->halign : '?', result->valign ? result->valign : '?'); result->halign ? result->halign : '?', result->valign ? result->valign : '?');
fprintf (stderr, "- Line justification (-a): \'%c\'\n", result->justify ? result->justify : '?'); log_debug(__FILE__, MAIN, " - Line justification (-a): \'%c\'\n", result->justify ? result->justify : '?');
fprintf (stderr, "- Design Definition W shape (-c): %s\n", result->cld ? result->cld : "n/a"); log_debug(__FILE__, MAIN, " - Design Definition W shape (-c): %s\n", result->cld ? result->cld : "n/a");
fprintf (stderr, "- Color mode: %d\n", result->color); log_debug(__FILE__, MAIN, " - Color mode: %d\n", result->color);
fprintf (stderr, "- Line terminator used (-e): %s\n",
log_debug(__FILE__, MAIN, " - Debug areas: ");
int dbgfirst = 1;
for (size_t i = 0; i < NUM_LOG_AREAS; i++) {
if (result->debug[i]) {
log_debug_cont(MAIN, "%s%s", dbgfirst ? "" : ", ", log_area_names[i + 2]);
dbgfirst = 0;
}
}
log_debug_cont(MAIN, "%s\n", dbgfirst ? "(off)" : "");
log_debug(__FILE__, MAIN, " - Line terminator used (-e): %s\n",
strcmp(result->eol, "\r\n") == 0 ? "CRLF" : (strcmp(result->eol, "\r") == 0 ? "CR" : "LF")); strcmp(result->eol, "\r\n") == 0 ? "CRLF" : (strcmp(result->eol, "\r") == 0 ? "CR" : "LF"));
fprintf (stderr, "- Explicit config file (-f): %s\n", result->f ? result->f : "no"); log_debug(__FILE__, MAIN, " - Explicit config file (-f): %s\n", result->f ? result->f : "no");
fprintf (stderr, "- Indentmode (-i): \'%c\'\n", result->indentmode ? result->indentmode : '?'); log_debug(__FILE__, MAIN, " - Indentmode (-i): \'%c\'\n", result->indentmode ? result->indentmode : '?');
fprintf (stderr, "- Kill blank lines (-k): %d\n", result->killblank); log_debug(__FILE__, MAIN, " - Kill blank lines (-k): %d\n", result->killblank);
fprintf (stderr, "- Mend box (-m): %d\n", result->mend); log_debug(__FILE__, MAIN, " - Mend box (-m): %d\n", result->mend);
fprintf (stderr, "- Padding (-p): l:%d t:%d r:%d b:%d\n", log_debug(__FILE__, MAIN, " - Padding (-p): l:%d t:%d r:%d b:%d\n",
result->padding[BLEF], result->padding[BTOP], result->padding[BRIG], result->padding[BBOT]); result->padding[BLEF], result->padding[BTOP], result->padding[BRIG], result->padding[BBOT]);
fprintf (stderr, "- Tag Query / Special handling for Web UI (-q): ");
log_debug(__FILE__, MAIN, " - Tag Query / Special handling for Web UI (-q): ");
if (result->query != NULL) { if (result->query != NULL) {
for (size_t qidx = 0; result->query[qidx] != NULL; ++qidx) { for (size_t qidx = 0; result->query[qidx] != NULL; ++qidx) {
fprintf(stderr, "%s%s", qidx > 0 ? ", " : "", result->query[qidx]); log_debug_cont(MAIN, "%s%s", qidx > 0 ? ", " : "", result->query[qidx]);
} }
} else { } else {
fprintf (stderr, "(none)"); log_debug_cont(MAIN, "(none)");
} }
fprintf (stderr, "\n"); log_debug_cont(MAIN, "\n");
fprintf (stderr, "- Remove box (-r): %d\n", result->r);
fprintf (stderr, "- Requested box size (-s): %ldx%ld\n", result->reqwidth, result->reqheight); log_debug(__FILE__, MAIN, " - Remove box (-r): %d\n", result->r);
fprintf (stderr, "- Tabstop distance (-t): %d\n", result->tabstop); log_debug(__FILE__, MAIN, " - Requested box size (-s): %ldx%ld\n", result->reqwidth, result->reqheight);
fprintf (stderr, "- Tab handling (-t): \'%c\'\n", result->tabexp); log_debug(__FILE__, MAIN, " - Tabstop distance (-t): %d\n", result->tabstop);
#endif log_debug(__FILE__, MAIN, " - Tab handling (-t): \'%c\'\n", result->tabexp);
} }
} }