9
9
*/
10
10
#include "command_line_arguments.h"
11
11
12
- #include "global.h"
12
+ #include "global.h" // IWYU pragma: keep
13
13
#include "log.h"
14
14
15
15
#include "../../../toxcore/ccompat.h"
@@ -26,7 +26,7 @@ static void print_help(void)
26
26
// 2 space indent
27
27
// Make sure all lines fit into 80 columns
28
28
// Make sure options are listed in alphabetical order
29
- log_write (LOG_LEVEL_INFO ,
29
+ LOG_WRITE (LOG_LEVEL_INFO ,
30
30
"Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n"
31
31
"\n"
32
32
"Options:\n"
@@ -43,6 +43,7 @@ static void print_help(void)
43
43
" Default option when no --log-backend is\n"
44
44
" specified.\n"
45
45
" stdout Writes log messages to stdout/stderr.\n"
46
+ " --trace Enable verbose network trace logging in toxcore.\n"
46
47
" --version Print version information.\n" );
47
48
}
48
49
@@ -51,7 +52,7 @@ Cli_Status handle_command_line_arguments(
51
52
bool * run_in_foreground )
52
53
{
53
54
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" );
55
56
print_help ();
56
57
return CLI_STATUS_ERROR ;
57
58
}
@@ -64,6 +65,7 @@ Cli_Status handle_command_line_arguments(
64
65
{"help" , no_argument , nullptr , 'h' },
65
66
{"log-backend" , required_argument , nullptr , 'l' }, // optional, defaults to syslog
66
67
{"version" , no_argument , nullptr , 'v' },
68
+ {"trace" , no_argument , nullptr , 't' },
67
69
{nullptr , 0 , nullptr , 0 }
68
70
};
69
71
@@ -99,24 +101,29 @@ Cli_Status handle_command_line_arguments(
99
101
* log_backend = LOG_BACKEND_STDOUT ;
100
102
log_backend_set = true;
101
103
} 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 );
103
105
print_help ();
104
106
return CLI_STATUS_ERROR ;
105
107
}
106
108
107
109
break ;
108
110
109
111
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 );
111
113
return CLI_STATUS_DONE ;
112
114
115
+ case 't' :
116
+ LOG_WRITE (LOG_LEVEL_INFO , "Enabling trace logging in toxcore.\n" );
117
+ log_enable_trace (true);
118
+ break ;
119
+
113
120
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 ]);
115
122
print_help ();
116
123
return CLI_STATUS_ERROR ;
117
124
118
125
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 ]);
120
127
print_help ();
121
128
return CLI_STATUS_ERROR ;
122
129
}
@@ -127,7 +134,7 @@ Cli_Status handle_command_line_arguments(
127
134
}
128
135
129
136
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" );
131
138
print_help ();
132
139
return CLI_STATUS_ERROR ;
133
140
}
0 commit comments