99 */
1010#include "command_line_arguments.h"
1111
12- #include "global.h"
12+ #include "global.h" // IWYU pragma: keep
1313#include "log.h"
1414
1515#include "../../../toxcore/ccompat.h"
@@ -26,7 +26,7 @@ static void print_help(void)
2626 // 2 space indent
2727 // Make sure all lines fit into 80 columns
2828 // Make sure options are listed in alphabetical order
29- log_write (LOG_LEVEL_INFO ,
29+ LOG_WRITE (LOG_LEVEL_INFO ,
3030 "Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n"
3131 "\n"
3232 "Options:\n"
@@ -43,6 +43,7 @@ static void print_help(void)
4343 " Default option when no --log-backend is\n"
4444 " specified.\n"
4545 " stdout Writes log messages to stdout/stderr.\n"
46+ " --trace Enable verbose network trace logging in toxcore.\n"
4647 " --version Print version information.\n" );
4748}
4849
@@ -51,7 +52,7 @@ Cli_Status handle_command_line_arguments(
5152 bool * run_in_foreground )
5253{
5354 if (argc < 2 ) {
54- log_write (LOG_LEVEL_ERROR , "Error: No arguments provided.\n\n" );
55+ LOG_WRITE (LOG_LEVEL_ERROR , "Error: No arguments provided.\n\n" );
5556 print_help ();
5657 return CLI_STATUS_ERROR ;
5758 }
@@ -64,6 +65,7 @@ Cli_Status handle_command_line_arguments(
6465 {"help" , no_argument , nullptr , 'h' },
6566 {"log-backend" , required_argument , nullptr , 'l' }, // optional, defaults to syslog
6667 {"version" , no_argument , nullptr , 'v' },
68+ {"trace" , no_argument , nullptr , 't' },
6769 {nullptr , 0 , nullptr , 0 }
6870 };
6971
@@ -99,24 +101,29 @@ Cli_Status handle_command_line_arguments(
99101 * log_backend = LOG_BACKEND_STDOUT ;
100102 log_backend_set = true;
101103 } else {
102- log_write (LOG_LEVEL_ERROR , "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n" , optarg );
104+ LOG_WRITE (LOG_LEVEL_ERROR , "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n" , optarg );
103105 print_help ();
104106 return CLI_STATUS_ERROR ;
105107 }
106108
107109 break ;
108110
109111 case 'v' :
110- log_write (LOG_LEVEL_INFO , "Version: %lu\n" , DAEMON_VERSION_NUMBER );
112+ LOG_WRITE (LOG_LEVEL_INFO , "Version: %lu\n" , DAEMON_VERSION_NUMBER );
111113 return CLI_STATUS_DONE ;
112114
115+ case 't' :
116+ LOG_WRITE (LOG_LEVEL_INFO , "Enabling trace logging in toxcore.\n" );
117+ log_enable_trace (true);
118+ break ;
119+
113120 case '?' :
114- log_write (LOG_LEVEL_ERROR , "Error: Unrecognized option %s\n\n" , argv [optind - 1 ]);
121+ LOG_WRITE (LOG_LEVEL_ERROR , "Error: Unrecognized option %s\n\n" , argv [optind - 1 ]);
115122 print_help ();
116123 return CLI_STATUS_ERROR ;
117124
118125 case ':' :
119- log_write (LOG_LEVEL_ERROR , "Error: No argument provided for option %s\n\n" , argv [optind - 1 ]);
126+ LOG_WRITE (LOG_LEVEL_ERROR , "Error: No argument provided for option %s\n\n" , argv [optind - 1 ]);
120127 print_help ();
121128 return CLI_STATUS_ERROR ;
122129 }
@@ -127,7 +134,7 @@ Cli_Status handle_command_line_arguments(
127134 }
128135
129136 if (!cfg_file_path_set ) {
130- log_write (LOG_LEVEL_ERROR , "Error: The required --config option wasn't specified\n\n" );
137+ LOG_WRITE (LOG_LEVEL_ERROR , "Error: The required --config option wasn't specified\n\n" );
131138 print_help ();
132139 return CLI_STATUS_ERROR ;
133140 }
0 commit comments