Separate out the debug facilities into their own files. Clean up and add a few associated methods.

This commit is contained in:
Mike Brady
2025-11-27 12:37:16 +00:00
parent 26f91f1e0d
commit 54445ee8f5
10 changed files with 370 additions and 207 deletions
+11 -9
View File
@@ -422,11 +422,10 @@ int parse_options(int argc, char **argv) {
poptSetOtherOptionHelp(optCon, "[OPTIONS]* ");
/* Now do options processing just to get a debug log destination and level */
debuglev = 0;
while ((c = poptGetNextOpt(optCon)) >= 0) {
switch (c) {
case 'v':
debuglev++;
increase_debug_level();
break;
case 'u':
inform("Warning: the option -u is no longer needed and is deprecated. Debug and statistics "
@@ -807,7 +806,7 @@ int parse_options(int argc, char **argv) {
warn("The \"general\" \"log_verbosity\" setting is deprecated. Please use the "
"\"diagnostics\" \"log_verbosity\" setting instead.");
if ((value >= 0) && (value <= 3))
debuglev = value;
set_debug_level(value);
else
die("Invalid log verbosity setting option choice \"%d\". It should be between 0 and 3, "
"inclusive.",
@@ -817,7 +816,7 @@ int parse_options(int argc, char **argv) {
/* Get the verbosity setting. */
if (config_lookup_int(config.cfg, "diagnostics.log_verbosity", &value)) {
if ((value >= 0) && (value <= 3))
debuglev = value;
set_debug_level(value);
else
die("Invalid diagnostics log_verbosity setting option choice \"%d\". It should be "
"between 0 and 3, "
@@ -1708,7 +1707,7 @@ int parse_options(int argc, char **argv) {
#endif
if (tdebuglev != 0)
debuglev = tdebuglev;
set_debug_level(tdebuglev);
// now set the initial volume to the default volume
config.airplay_volume =
@@ -2268,6 +2267,10 @@ const char *av_channel_layout_name(uint64_t channel_layout) {
#endif
int main(int argc, char **argv) {
// initialise debug messages stuff -- level 1, no elapsed time, relative time, file and line
// the debug level will be reset to zero if no debug level is set
// debug_init(int level, int show_elapsed_time, int show_relative_time, int show_file_and_line)
debug_init(1, 0, 1, 1);
memset(&config, 0, sizeof(config)); // also clears all strings, BTW
/* Check if we are called with -V or --version parameter */
if (argc >= 2 && ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0))) {
@@ -2298,7 +2301,7 @@ int main(int argc, char **argv) {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
avcodec_register_all();
#endif
if (debuglev == 0)
if (debug_level() == 0)
av_log_set_level(AV_LOG_ERROR);
else
av_log_set_level(AV_LOG_VERBOSE);
@@ -2321,8 +2324,7 @@ int main(int argc, char **argv) {
pid = getpid();
config.log_fd = -1;
conns = NULL; // no connections active
ns_time_at_startup = get_absolute_time_in_ns();
ns_time_at_last_debug_message = ns_time_at_startup;
#ifdef CONFIG_LIBDAEMON
daemon_set_verbosity(LOG_DEBUG);
@@ -2698,7 +2700,7 @@ int main(int argc, char **argv) {
#endif
debug(2, "Log Verbosity is %d.", debuglev);
debug(2, "Log Verbosity is %d.", debug_level());
config.output = audio_get_output(config.output_name);
if (!config.output) {