feat(worker): add -v flag for verbose logging
Multiple -v increase verbosity: -v=DEBUG, -vv=DEBUG2, -vvv=DEBUG3. Same pattern as controller and scheduler.
This commit is contained in:
parent
e959ee61fc
commit
0df1cf5f8d
1 changed files with 16 additions and 2 deletions
|
|
@ -295,6 +295,7 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
int ret = XCECD_OK;
|
int ret = XCECD_OK;
|
||||||
|
int verbose = 0;
|
||||||
__attribute__((unused)) char worker_log[1024] = { 0 };
|
__attribute__((unused)) char worker_log[1024] = { 0 };
|
||||||
const char* peers_str = NULL;
|
const char* peers_str = NULL;
|
||||||
xce_cluster_config_t cluster_cfg = {0};
|
xce_cluster_config_t cluster_cfg = {0};
|
||||||
|
|
@ -345,7 +346,7 @@ int main(int argc, char* argv[])
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "n:l:h", long_opts, NULL))
|
while ((opt = getopt_long(argc, argv, "n:l:vh", long_opts, NULL))
|
||||||
!= -1) {
|
!= -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'n':
|
case 'n':
|
||||||
|
|
@ -359,12 +360,15 @@ int main(int argc, char* argv[])
|
||||||
logdir = strdup(optarg);
|
logdir = strdup(optarg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose++;
|
||||||
|
break;
|
||||||
case OPT_PEERS:
|
case OPT_PEERS:
|
||||||
peers_str = optarg;
|
peers_str = optarg;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
printf("Usage: %s [-n name] [-l log_dir] "
|
printf("Usage: %s [-n name] [-l log_dir] [-v] "
|
||||||
"[--peers ctrl-1=host:port,...] "
|
"[--peers ctrl-1=host:port,...] "
|
||||||
"[-h help]\n",
|
"[-h help]\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
|
|
@ -372,6 +376,16 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Map -v count to log level (same pattern as controller/scheduler).
|
||||||
|
* 0=INFO (default), 1=DEBUG, 2=DEBUG2, 3+=DEBUG3. */
|
||||||
|
if (verbose >= 3) {
|
||||||
|
config.debug_level = XCE_LOG_DEBUG3;
|
||||||
|
} else if (verbose == 2) {
|
||||||
|
config.debug_level = XCE_LOG_DEBUG2;
|
||||||
|
} else if (verbose == 1) {
|
||||||
|
config.debug_level = XCE_LOG_DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
/* Performed after argument parsing so -h/--help exits immediately
|
/* Performed after argument parsing so -h/--help exits immediately
|
||||||
* without requiring root privileges. */
|
* without requiring root privileges. */
|
||||||
check_user();
|
check_user();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue