Use EXTRA_VERSION_NAME and EXTRA_VERSION_DESCRIPTION
[lttng-tools.git] / src / bin / lttng-relayd / main.c
index 6720eca9687f6d9633dc9c5928eb904a2ab36d89..1c272c392cd5cdc135d79ec442ea42e7a4653257 100644 (file)
@@ -62,6 +62,7 @@
 #include <common/buffer-view.h>
 #include <common/string-utils/format.h>
 
+#include "version.h"
 #include "cmd.h"
 #include "ctf-trace.h"
 #include "index.h"
@@ -96,7 +97,7 @@ enum relay_connection_status {
 
 /* command line options */
 char *opt_output_path;
-static int opt_daemon, opt_background;
+static int opt_daemon, opt_background, opt_print_version;
 
 /*
  * We need to wait for listener and live listener threads, as well as
@@ -188,6 +189,20 @@ static struct option long_options[] = {
 
 static const char *config_ignore_options[] = { "help", "config", "version" };
 
+static void print_version(void) {
+       fprintf(stdout, "%s\n", VERSION);
+}
+
+static void relayd_config_log(void)
+{
+       DBG("LTTng-relayd " VERSION " - " VERSION_NAME "%s%s",
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
+       if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
+               DBG("LTTng-relayd extra version description:\n\t" EXTRA_VERSION_DESCRIPTION "\n");
+       }
+}
+
 /*
  * Take an option from the getopt output and set it in the right variable to be
  * used later.
@@ -278,8 +293,8 @@ static int set_option(int opt, const char *arg, const char *optname)
                }
                exit(EXIT_FAILURE);
        case 'V':
-               fprintf(stdout, "%s\n", VERSION);
-               exit(EXIT_SUCCESS);
+               opt_print_version = 1;
+               break;
        case 'o':
                if (lttng_is_setuid_setgid()) {
                        WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
@@ -3665,6 +3680,14 @@ int main(int argc, char **argv)
                goto exit_options;
        }
 
+       relayd_config_log();
+
+       if (opt_print_version) {
+               print_version();
+               retval = 0;
+               goto exit_options;
+       }
+
        /* Try to create directory if -o, --output is specified. */
        if (opt_output_path) {
                if (*opt_output_path != '/') {
This page took 0.024632 seconds and 5 git commands to generate.