From: David Goulet Date: Thu, 21 Apr 2011 19:02:15 +0000 (-0400) Subject: Add lttngerr support to ltt-sessiond X-Git-Tag: v2.0-pre1~186 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=75462a81e727e0b081dd21805836302bfbd77788 Add lttngerr support to ltt-sessiond Now using the lttngerr API for message/error printing. Also add the quiet option to the ltt-sessiond. The lttng auto spawn session daemon option was also modified to use that quiet option to not to pollute stdout when that spawned daemon is killed. Signed-off-by: David Goulet --- diff --git a/ltt-sessiond/ltt-sessiond.c b/ltt-sessiond/ltt-sessiond.c index f257ddb09..a51593a96 100644 --- a/ltt-sessiond/ltt-sessiond.c +++ b/ltt-sessiond/ltt-sessiond.c @@ -38,7 +38,9 @@ #include "liblttsessiondcomm.h" #include "ltt-sessiond.h" +#include "lttngerr.h" +/* Const values */ const char default_home_dir[] = DEFAULT_HOME_DIR; const char default_tracing_group[] = DEFAULT_TRACING_GROUP; const char default_ust_sock_dir[] = DEFAULT_UST_SOCK_DIR; @@ -71,6 +73,8 @@ const char *progname; const char *opt_tracing_group; static int opt_sig_parent; static int opt_daemon; +int opt_verbose; +int opt_quiet; static int is_root; /* Set to 1 if the daemon is running as root */ static pid_t ppid; @@ -256,7 +260,7 @@ static int connect_app(pid_t pid) sock = ustctl_connect_pid(pid); if (sock < 0) { - fprintf(stderr, "Fail connecting to the PID %d\n", pid); + ERR("Fail connecting to the PID %d\n", pid); } return sock; @@ -544,7 +548,8 @@ static void usage(void) "\t-d, --daemonize\t\tStart as a daemon.\n" "\t-g, --group NAME\t\tSpecify the tracing group name. (default: tracing)\n" "\t-V, --version\t\tShow version number.\n" - "\t-S, --sig-parent\t\tSend SIGCHLD to parent pid to notify readiness.\n", + "\t-S, --sig-parent\t\tSend SIGCHLD to parent pid to notify readiness.\n" + "\t-q, --quiet\t\tNo output at all.\n", progname); } @@ -563,12 +568,13 @@ static int parse_args(int argc, char **argv) { "help", 0, 0, 'h' }, { "group", 1, 0, 'g' }, { "version", 0, 0, 'V' }, + { "quiet", 0, 0, 'q' }, { NULL, 0, 0, 0 } }; while (1) { int option_index = 0; - c = getopt_long(argc, argv, "dhVS" "a:c:g:s:", long_options, &option_index); + c = getopt_long(argc, argv, "dhqVS" "a:c:g:s:", long_options, &option_index); if (c == -1) { break; } @@ -601,6 +607,9 @@ static int parse_args(int argc, char **argv) case 'S': opt_sig_parent = 1; break; + case 'q': + opt_quiet = 1; + break; default: /* Unknown option or other error. * Error is printed by getopt, just return */ @@ -711,7 +720,7 @@ static int set_socket_perms(void) (grp = getgrnam(default_tracing_group)); if (grp == NULL) { - fprintf(stderr, "Missing tracing group. Aborting execution.\n"); + ERR("Missing tracing group. Aborting execution.\n"); ret = -1; goto end; } @@ -791,8 +800,8 @@ static void sighandler(int sig) static void cleanup() { /* */ - fprintf(stdout, "\n\n%c[%d;%dm*** assert failed *** ==> %c[%dm", 27,1,31,27,0); - fprintf(stdout, "%c[%d;%dm Matthew, BEET driven development works!%c[%dm\n",27,1,33,27,0); + MSG("\n\n%c[%d;%dm*** assert failed *** ==> %c[%dm", 27,1,31,27,0); + MSG("%c[%d;%dm Matthew, BEET driven development works!%c[%dm\n",27,1,33,27,0); /* */ unlink(client_unix_sock_path); @@ -855,7 +864,7 @@ int main(int argc, char **argv) * socket needed by the daemon are present, this test fails */ if ((ret = check_existing_daemon()) == 0) { - fprintf(stderr, "Already running daemon.\n"); + ERR("Already running daemon.\n"); goto error; } diff --git a/lttng/lttng.c b/lttng/lttng.c index 095ebe5e1..f4fab034f 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -170,7 +170,7 @@ static int spawn_sessiond(char *pathname) /* Spawn session daemon and tell * it to signal us when ready. */ - ret = execlp(pathname, "ltt-sessiond", "--sig-parent", NULL); + ret = execlp(pathname, "ltt-sessiond", "--sig-parent", "--quiet", NULL); if (ret < 0) { if (errno == ENOENT) { ERR("No session daemon found. Use --sessiond-path.");