Trace path creation made on the client side
authorDavid Goulet <david.goulet@polymtl.ca>
Tue, 26 Jul 2011 15:43:35 +0000 (11:43 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Tue, 26 Jul 2011 15:43:35 +0000 (11:43 -0400)
The traces output path is set on the client side with the date and time
if no output path is specified.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
ltt-sessiond/session.c
lttng/commands/create.c

index ff79bf2a969bde74e1045f7c0c126e6eea46df16..7a7bf3e572eaf500f34df226789af94efd4bf240 100644 (file)
@@ -184,10 +184,7 @@ int destroy_session(char *name)
 int create_session(char *name, char *path)
 {
        int ret;
-       char date_time[NAME_MAX];
        struct ltt_session *new_session;
-       time_t rawtime;
-       struct tm *timeinfo;
 
        new_session = find_session_by_name(name);
        if (new_session != NULL) {
@@ -217,15 +214,7 @@ int create_session(char *name, char *path)
 
        /* Define session system path */
        if (path != NULL) {
-               if (strstr(name, "auto-") == NULL) {
-                       time(&rawtime);
-                       timeinfo = localtime(&rawtime);
-                       strftime(date_time, sizeof(date_time), "-%Y%m%d-%H%M%S", timeinfo);
-               } else {
-                       date_time[0] = '\0';
-               }
-
-               if (asprintf(&new_session->path, "%s/%s%s", path, name, date_time) < 0) {
+               if (asprintf(&new_session->path, "%s", path) < 0) {
                        ret = -ENOMEM;
                        goto error_asprintf;
                }
index dbed8f021568f53c38b37432a078639f911fa77d..b8bbdb7e7ba453434279a320b538fddb36dd9f9d 100644 (file)
@@ -65,17 +65,23 @@ static void usage(FILE *ofp)
 static int create_session()
 {
        int ret, have_name = 0;
-       char name[NAME_MAX];
+       char datetime[16];
        char *session_name, *traces_path = NULL, *alloc_path = NULL;
        time_t rawtime;
        struct tm *timeinfo;
 
+       /* Get date and time for automatic session name/path */
+       time(&rawtime);
+       timeinfo = localtime(&rawtime);
+       strftime(datetime, sizeof(datetime), "%Y%m%d-%H%M%S", timeinfo);
+
        /* Auto session name creation */
        if (opt_session_name == NULL) {
-               time(&rawtime);
-               timeinfo = localtime(&rawtime);
-               strftime(name, sizeof(name), "auto-%Y%m%d-%H%M%S", timeinfo);
-               session_name = name;
+               ret = asprintf(&session_name, "auto-%s", datetime);
+               if (ret < 0) {
+                       perror("asprintf session name");
+                       goto error;
+               }
                DBG("Auto session name set to %s", session_name);
        } else {
                session_name = opt_session_name;
@@ -92,7 +98,8 @@ static int create_session()
                        goto error;
                }
 
-               ret = asprintf(&traces_path, "%s/" LTTNG_DEFAULT_TRACE_DIR_NAME, alloc_path);
+               ret = asprintf(&traces_path, "%s/" LTTNG_DEFAULT_TRACE_DIR_NAME
+                               "/%s-%s", alloc_path, session_name, datetime);
                if (ret < 0) {
                        perror("asprintf trace dir name");
                        goto error;
@@ -117,7 +124,7 @@ static int create_session()
 
        MSG("Session %s created.", session_name);
        if (have_name) {
-               MSG("Traces will be written in %s/%s-<date>-<time>" , traces_path, session_name);
+               MSG("Traces will be written in %s" , traces_path);
        } else {
                MSG("Traces will be written in %s/%s", traces_path, session_name);
        }
This page took 0.039094 seconds and 4 git commands to generate.