Make the --verbose flag universal
Previously, the --verbose flag was only present in debug builds. Now it's present whether you define DEBUG or not. What changes is the amount of information printed to stderr: DEBUG sets the --verbose log level to 0 (debug), while DEBUG unset sets it to 1 (info). This makes driving the binary slightly simpler as you don't have to detect whether it's a debug build by scanning for "--verbose" in the help output.
This commit is contained in:
10
src/mode.c
10
src/mode.c
@@ -207,7 +207,7 @@ void read_serve_param( int c, char **ip_addr, char **ip_port, char **file, char
|
|||||||
log_level = 4;
|
log_level = 4;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
log_level = 0;
|
log_level = VERBOSE_LOG_LEVEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exit_err( serve_help_text );
|
exit_err( serve_help_text );
|
||||||
@@ -255,7 +255,7 @@ void read_listen_param( int c,
|
|||||||
log_level = 4;
|
log_level = 4;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
log_level = 0;
|
log_level = VERBOSE_LOG_LEVEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exit_err( listen_help_text );
|
exit_err( listen_help_text );
|
||||||
@@ -289,7 +289,7 @@ void read_readwrite_param( int c, char **ip_addr, char **ip_port, char **bind_ad
|
|||||||
log_level = 4;
|
log_level = 4;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
log_level = 0;
|
log_level = VERBOSE_LOG_LEVEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exit_err( read_help_text );
|
exit_err( read_help_text );
|
||||||
@@ -311,7 +311,7 @@ void read_sock_param( int c, char **sock, char *help_text )
|
|||||||
log_level = 4;
|
log_level = 4;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
log_level = 0;
|
log_level = VERBOSE_LOG_LEVEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exit_err( help_text );
|
exit_err( help_text );
|
||||||
@@ -347,7 +347,7 @@ void read_mirror_param( int c, char **sock, char **ip_addr, char **ip_port, char
|
|||||||
log_level = 4;
|
log_level = 4;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
log_level = 0;
|
log_level = VERBOSE_LOG_LEVEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exit_err( mirror_help_text );
|
exit_err( mirror_help_text );
|
||||||
|
18
src/mode.h
18
src/mode.h
@@ -51,23 +51,23 @@ void mode(char* mode, int argc, char **argv);
|
|||||||
#define GETOPT_SIZE GETOPT_ARG( OPT_SIZE, 'S' )
|
#define GETOPT_SIZE GETOPT_ARG( OPT_SIZE, 'S' )
|
||||||
#define GETOPT_BIND GETOPT_ARG( OPT_BIND, 'b' )
|
#define GETOPT_BIND GETOPT_ARG( OPT_BIND, 'b' )
|
||||||
|
|
||||||
#ifdef DEBUG
|
#define OPT_VERBOSE "verbose"
|
||||||
# define OPT_VERBOSE "verbose"
|
#define SOPT_VERBOSE "v"
|
||||||
# define SOPT_VERBOSE "v"
|
#define GETOPT_VERBOSE GETOPT_FLAG( OPT_VERBOSE, 'v' )
|
||||||
# define GETOPT_VERBOSE GETOPT_FLAG( OPT_VERBOSE, 'v' )
|
#define VERBOSE_LINE \
|
||||||
# define VERBOSE_LINE \
|
|
||||||
"\t--" OPT_VERBOSE ",-" SOPT_VERBOSE "\t\tOutput debug information.\n"
|
"\t--" OPT_VERBOSE ",-" SOPT_VERBOSE "\t\tOutput debug information.\n"
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
# define VERBOSE_LOG_LEVEL 0
|
||||||
#else
|
#else
|
||||||
# define GETOPT_VERBOSE {0}
|
# define VERBOSE_LOG_LEVEL 1
|
||||||
# define VERBOSE_LINE ""
|
|
||||||
# define SOPT_VERBOSE ""
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OPT_QUIET "quiet"
|
#define OPT_QUIET "quiet"
|
||||||
#define SOPT_QUIET "q"
|
#define SOPT_QUIET "q"
|
||||||
#define GETOPT_QUIET GETOPT_FLAG( OPT_QUIET, 'q' )
|
#define GETOPT_QUIET GETOPT_FLAG( OPT_QUIET, 'q' )
|
||||||
#define QUIET_LINE \
|
#define QUIET_LINE \
|
||||||
"\t--" OPT_QUIET ",-" SOPT_QUIET "\t\tOutput only fatal informatio.\n"
|
"\t--" OPT_QUIET ",-" SOPT_QUIET "\t\tOutput only fatal information.\n"
|
||||||
|
|
||||||
|
|
||||||
#define HELP_LINE \
|
#define HELP_LINE \
|
||||||
|
Reference in New Issue
Block a user