Fix: support log4j loglevel in mi
authorDavid Goulet <dgoulet@efficios.com>
Tue, 14 Oct 2014 18:43:29 +0000 (14:43 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 14 Oct 2014 18:51:40 +0000 (14:51 -0400)
To achieve this, a couple of functions needed to send the domain of the
event so we can use the right loglevel according to the domain.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng/commands/enable_events.c
src/bin/lttng/commands/list.c
src/common/mi-lttng.c
src/common/mi-lttng.h

index dc5f51debd8288c8d26b8517d152d156006c574d..8b1215b111cfae31c2721c4a61f22211efd79d8e 100644 (file)
@@ -854,7 +854,7 @@ static int enable_events(char *session_name)
                                ev.enabled = 0;
                                success = 0;
                        }
-                       ret = mi_lttng_event(writer, &ev, 1);
+                       ret = mi_lttng_event(writer, &ev, 1, handle->domain.type);
                        if (ret) {
                                ret = CMD_ERROR;
                                goto error;
@@ -1133,7 +1133,7 @@ static int enable_events(char *session_name)
                                ev.enabled = 1;
                        }
 
-                       ret = mi_lttng_event(writer, &ev, 1);
+                       ret = mi_lttng_event(writer, &ev, 1, handle->domain.type);
                        if (ret) {
                                ret = CMD_ERROR;
                                goto error;
index a26ec064197c123356c24c0be07db2f9cc6f6d54..ea9427f4770f158458f6e8e79456f2f7d7b6c91b 100644 (file)
@@ -234,7 +234,7 @@ static void print_events(struct lttng_event *event)
                                indent6,
                                event->name,
                                logleveltype_string(event->loglevel_type),
-                               mi_lttng_loglevel_string(event->loglevel),
+                               mi_lttng_loglevel_string(event->loglevel, handle->domain.type),
                                event->loglevel,
                                enabled_string(event->enabled),
                                exclusion_string(event->exclusion),
@@ -391,7 +391,7 @@ static int mi_list_agent_ust_events(struct lttng_event *events, int count,
                }
 
                /* Write an event */
-               ret = mi_lttng_event(writer, &events[i], 0);
+               ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
                if (ret) {
                        goto end;
                }
@@ -641,7 +641,8 @@ static int mi_list_ust_event_fields(struct lttng_event_field *fields, int count,
 
                        if (!event_element_open) {
                                /* Open and write the event */
-                               ret = mi_lttng_event(writer, &cur_event, 1);
+                               ret = mi_lttng_event(writer, &cur_event, 1,
+                                               handle->domain.type);
                                if (ret) {
                                        goto end;
                                }
@@ -779,7 +780,7 @@ static int mi_list_kernel_events(struct lttng_event *events, int count,
        }
 
        for (i = 0; i < count; i++) {
-               ret = mi_lttng_event(writer, &events[i], 0);
+               ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
                if (ret) {
                        goto end;
                }
@@ -867,7 +868,7 @@ static int mi_list_syscalls(struct lttng_event *events, int count)
        }
 
        for (i = 0; i < count; i++) {
-               ret = mi_lttng_event(writer, &events[i], 0);
+               ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
                if (ret) {
                        goto end;
                }
@@ -940,7 +941,7 @@ static int mi_list_session_agent_events(struct lttng_event *events, int count)
        }
 
        for (i = 0; i < count; i++) {
-               ret = mi_lttng_event(writer, &events[i], 0);
+               ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
                if (ret) {
                        goto end;
                }
@@ -989,7 +990,8 @@ static int list_session_agent_events(void)
                        MSG("%s- %s%s (loglevel%s %s)", indent4, events[i].name,
                                        enabled_string(events[i].enabled),
                                        logleveltype_string(events[i].loglevel_type),
-                                       mi_lttng_loglevel_string(events[i].loglevel));
+                                       mi_lttng_loglevel_string(events[i].loglevel,
+                                               handle->domain.type));
                }
 
                MSG("");
@@ -1016,7 +1018,7 @@ static int mi_list_events(struct lttng_event *events, int count)
        }
 
        for (i = 0; i < count; i++) {
-               ret = mi_lttng_event(writer, &events[i], 0);
+               ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
                if (ret) {
                        goto end;
                }
index cb30e507ec10a9bc88ead14dde8fb7aa55e4cef7..c21ed5a6311491cd875d246c6d4244fb8dda26f9 100644 (file)
@@ -125,6 +125,16 @@ const char * const mi_lttng_loglevel_str_jul_off = "JUL_OFF";
 const char * const mi_lttng_loglevel_str_jul_severe = "JUL_SEVERE";
 const char * const mi_lttng_loglevel_str_jul_warning = "JUL_WARNING";
 
+/* String related to loglevel LOG4J */
+const char * const mi_lttng_loglevel_str_log4j_off = "LOG4J_OFF";
+const char * const mi_lttng_loglevel_str_log4j_fatal = "LOG4J_FATAL";
+const char * const mi_lttng_loglevel_str_log4j_error = "LOG4J_ERROR";
+const char * const mi_lttng_loglevel_str_log4j_warn = "LOG4J_WARN";
+const char * const mi_lttng_loglevel_str_log4j_info = "LOG4J_INFO";
+const char * const mi_lttng_loglevel_str_log4j_debug = "LOG4J_DEBUG";
+const char * const mi_lttng_loglevel_str_log4j_trace = "LOG4J_TRACE";
+const char * const mi_lttng_loglevel_str_log4j_all = "LOG4J_ALL";
+
 /* String related to loglevel type */
 const char * const mi_lttng_loglevel_type_all = "ALL";
 const char * const mi_lttng_loglevel_type_range = "RANGE";
@@ -148,62 +158,102 @@ const char * const mi_lttng_element_snapshots = "snapshots";
  * (see struct lttng_event loglevel)
  */
 LTTNG_HIDDEN
-const char *mi_lttng_loglevel_string(int value)
+const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain)
 {
-       switch (value) {
-       case -1:
-               return mi_lttng_element_empty;
-       case LTTNG_LOGLEVEL_EMERG:
-               return mi_lttng_loglevel_str_emerg;
-       case LTTNG_LOGLEVEL_ALERT:
-               return mi_lttng_loglevel_str_alert;
-       case LTTNG_LOGLEVEL_CRIT:
-               return mi_lttng_loglevel_str_crit;
-       case LTTNG_LOGLEVEL_ERR:
-               return mi_lttng_loglevel_str_err;
-       case LTTNG_LOGLEVEL_WARNING:
-               return mi_lttng_loglevel_str_warning;
-       case LTTNG_LOGLEVEL_NOTICE:
-               return mi_lttng_loglevel_str_notice;
-       case LTTNG_LOGLEVEL_INFO:
-               return mi_lttng_loglevel_str_info;
-       case LTTNG_LOGLEVEL_DEBUG_SYSTEM:
-               return mi_lttng_loglevel_str_debug_system;
-       case LTTNG_LOGLEVEL_DEBUG_PROGRAM:
-               return mi_lttng_loglevel_str_debug_program;
-       case LTTNG_LOGLEVEL_DEBUG_PROCESS:
-               return mi_lttng_loglevel_str_debug_process;
-       case LTTNG_LOGLEVEL_DEBUG_MODULE:
-               return mi_lttng_loglevel_str_debug_module;
-       case LTTNG_LOGLEVEL_DEBUG_UNIT:
-               return mi_lttng_loglevel_str_debug_unit;
-       case LTTNG_LOGLEVEL_DEBUG_FUNCTION:
-               return mi_lttng_loglevel_str_debug_function;
-       case LTTNG_LOGLEVEL_DEBUG_LINE:
-               return mi_lttng_loglevel_str_debug_line;
-       case LTTNG_LOGLEVEL_DEBUG:
-               return mi_lttng_loglevel_str_debug;
-       case LTTNG_LOGLEVEL_JUL_OFF:
-               return mi_lttng_loglevel_str_jul_off;
-       case LTTNG_LOGLEVEL_JUL_SEVERE:
-               return mi_lttng_loglevel_str_jul_severe;
-       case LTTNG_LOGLEVEL_JUL_WARNING:
-               return mi_lttng_loglevel_str_jul_warning;
-       case LTTNG_LOGLEVEL_JUL_INFO:
-               return mi_lttng_loglevel_str_jul_info;
-       case LTTNG_LOGLEVEL_JUL_CONFIG:
-               return mi_lttng_loglevel_str_jul_config;
-       case LTTNG_LOGLEVEL_JUL_FINE:
-               return mi_lttng_loglevel_str_jul_fine;
-       case LTTNG_LOGLEVEL_JUL_FINER:
-               return mi_lttng_loglevel_str_jul_finer;
-       case LTTNG_LOGLEVEL_JUL_FINEST:
-               return mi_lttng_loglevel_str_jul_finest;
-       case LTTNG_LOGLEVEL_JUL_ALL:
-               return mi_lttng_loglevel_str_jul_all;
-       default:
-               return mi_lttng_loglevel_str_unknown;
+       switch (domain) {
+       case LTTNG_DOMAIN_KERNEL:
+       case LTTNG_DOMAIN_UST:
+               switch (value) {
+               case -1:
+                       return mi_lttng_element_empty;
+               case LTTNG_LOGLEVEL_EMERG:
+                       return mi_lttng_loglevel_str_emerg;
+               case LTTNG_LOGLEVEL_ALERT:
+                       return mi_lttng_loglevel_str_alert;
+               case LTTNG_LOGLEVEL_CRIT:
+                       return mi_lttng_loglevel_str_crit;
+               case LTTNG_LOGLEVEL_ERR:
+                       return mi_lttng_loglevel_str_err;
+               case LTTNG_LOGLEVEL_WARNING:
+                       return mi_lttng_loglevel_str_warning;
+               case LTTNG_LOGLEVEL_NOTICE:
+                       return mi_lttng_loglevel_str_notice;
+               case LTTNG_LOGLEVEL_INFO:
+                       return mi_lttng_loglevel_str_info;
+               case LTTNG_LOGLEVEL_DEBUG_SYSTEM:
+                       return mi_lttng_loglevel_str_debug_system;
+               case LTTNG_LOGLEVEL_DEBUG_PROGRAM:
+                       return mi_lttng_loglevel_str_debug_program;
+               case LTTNG_LOGLEVEL_DEBUG_PROCESS:
+                       return mi_lttng_loglevel_str_debug_process;
+               case LTTNG_LOGLEVEL_DEBUG_MODULE:
+                       return mi_lttng_loglevel_str_debug_module;
+               case LTTNG_LOGLEVEL_DEBUG_UNIT:
+                       return mi_lttng_loglevel_str_debug_unit;
+               case LTTNG_LOGLEVEL_DEBUG_FUNCTION:
+                       return mi_lttng_loglevel_str_debug_function;
+               case LTTNG_LOGLEVEL_DEBUG_LINE:
+                       return mi_lttng_loglevel_str_debug_line;
+               case LTTNG_LOGLEVEL_DEBUG:
+                       return mi_lttng_loglevel_str_debug;
+               default:
+                       return mi_lttng_loglevel_str_unknown;
+               }
+               break;
+       case LTTNG_DOMAIN_LOG4J:
+               switch (value) {
+               case -1:
+                       return mi_lttng_element_empty;
+               case LTTNG_LOGLEVEL_LOG4J_OFF:
+                       return mi_lttng_loglevel_str_log4j_off;
+               case LTTNG_LOGLEVEL_LOG4J_FATAL:
+                       return mi_lttng_loglevel_str_log4j_fatal;
+               case LTTNG_LOGLEVEL_LOG4J_ERROR:
+                       return mi_lttng_loglevel_str_log4j_error;
+               case LTTNG_LOGLEVEL_LOG4J_WARN:
+                       return mi_lttng_loglevel_str_log4j_warn;
+               case LTTNG_LOGLEVEL_LOG4J_INFO:
+                       return mi_lttng_loglevel_str_log4j_info;
+               case LTTNG_LOGLEVEL_LOG4J_DEBUG:
+                       return mi_lttng_loglevel_str_log4j_debug;
+               case LTTNG_LOGLEVEL_LOG4J_TRACE:
+                       return mi_lttng_loglevel_str_log4j_trace;
+               case LTTNG_LOGLEVEL_LOG4J_ALL:
+                       return mi_lttng_loglevel_str_log4j_all;
+               default:
+                       return mi_lttng_loglevel_str_unknown;
+               }
+               break;
+       case LTTNG_DOMAIN_JUL:
+               switch (value) {
+               case -1:
+                       return mi_lttng_element_empty;
+               case LTTNG_LOGLEVEL_JUL_OFF:
+                       return mi_lttng_loglevel_str_jul_off;
+               case LTTNG_LOGLEVEL_JUL_SEVERE:
+                       return mi_lttng_loglevel_str_jul_severe;
+               case LTTNG_LOGLEVEL_JUL_WARNING:
+                       return mi_lttng_loglevel_str_jul_warning;
+               case LTTNG_LOGLEVEL_JUL_INFO:
+                       return mi_lttng_loglevel_str_jul_info;
+               case LTTNG_LOGLEVEL_JUL_CONFIG:
+                       return mi_lttng_loglevel_str_jul_config;
+               case LTTNG_LOGLEVEL_JUL_FINE:
+                       return mi_lttng_loglevel_str_jul_fine;
+               case LTTNG_LOGLEVEL_JUL_FINER:
+                       return mi_lttng_loglevel_str_jul_finer;
+               case LTTNG_LOGLEVEL_JUL_FINEST:
+                       return mi_lttng_loglevel_str_jul_finest;
+               case LTTNG_LOGLEVEL_JUL_ALL:
+                       return mi_lttng_loglevel_str_jul_all;
+               default:
+                       return mi_lttng_loglevel_str_unknown;
+               }
+               break;
        }
+
+       /* Reaching this means the domain is unknown. */
+       return mi_lttng_loglevel_str_unknown;
 }
 
 LTTNG_HIDDEN
@@ -877,13 +927,14 @@ end:
 
 LTTNG_HIDDEN
 int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
-               struct lttng_event *event)
+               struct lttng_event *event, enum lttng_domain_type domain)
 {
        int ret;
 
        /* Event loglevel */
        ret = mi_lttng_writer_write_element_string(writer,
-                       config_element_loglevel, mi_lttng_loglevel_string(event->loglevel));
+                       config_element_loglevel,
+                       mi_lttng_loglevel_string(event->loglevel, domain));
        if (ret) {
                goto end;
        }
@@ -998,7 +1049,7 @@ int mi_lttng_events_open(struct mi_writer *writer)
 
 LTTNG_HIDDEN
 int mi_lttng_event(struct mi_writer *writer,
-               struct lttng_event *event, int is_open)
+               struct lttng_event *event, int is_open, enum lttng_domain_type domain)
 {
        int ret;
 
@@ -1011,7 +1062,7 @@ int mi_lttng_event(struct mi_writer *writer,
        case LTTNG_EVENT_TRACEPOINT:
        {
                if (event->loglevel != -1) {
-                       ret = mi_lttng_event_tracepoint_loglevel(writer, event);
+                       ret = mi_lttng_event_tracepoint_loglevel(writer, event, domain);
                } else {
                        ret = mi_lttng_event_tracepoint_no_loglevel(writer, event);
                }
index e5ca544737f373bee2a56e8bbd0aef5fc4e489a1..a181e0b1045cc9fd95c8d5880f3f985c51b1a80b 100644 (file)
@@ -149,6 +149,16 @@ const char * const mi_lttng_loglevel_str_jul_off;
 const char * const mi_lttng_loglevel_str_jul_severe;
 const char * const mi_lttng_loglevel_str_jul_warning;
 
+/* String related to loglevel Log4j */
+const char * const mi_lttng_loglevel_str_log4j_off;
+const char * const mi_lttng_loglevel_str_log4j_fatal;
+const char * const mi_lttng_loglevel_str_log4j_error;
+const char * const mi_lttng_loglevel_str_log4j_warn;
+const char * const mi_lttng_loglevel_str_log4j_info;
+const char * const mi_lttng_loglevel_str_log4j_debug;
+const char * const mi_lttng_loglevel_str_log4j_trace;
+const char * const mi_lttng_loglevel_str_log4j_all;
+
 /* String related to loglevel type */
 const char * const mi_lttng_loglevel_type_all;
 const char * const mi_lttng_loglevel_type_range;
@@ -168,7 +178,7 @@ const char * const mi_lttng_element_snapshot_session_name;
 const char * const mi_lttng_element_snapshots;
 
 /* Utility string function  */
-const char *mi_lttng_loglevel_string(int value);
+const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
 const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
@@ -436,12 +446,13 @@ int mi_lttng_event_common_attributes(struct mi_writer *writer,
  *
  * writer An instance of a mi writer.
  * event single trace event.
+ * domain Event's domain
  *
  * Returns zero if the element's value could be written.
  * Negative values indicate an error.
  */
 int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
-               struct lttng_event *event);
+               struct lttng_event *event, enum lttng_domain_type domain);
 
 /*
  * Machine interface for kernel tracepoint event with no loglevel.
@@ -504,12 +515,13 @@ int mi_lttng_events_open(struct mi_writer *writer);
  *         This should be used carefully and the client
  *         must close the event element.
  *         Use case: nested additional information
+ * domain Event's domain
  *
  * Returns zero if the element's value could be written.
  * Negative values indicate an error.
  */
 int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
-               int is_open);
+               int is_open, enum lttng_domain_type domain);
 
 /*
  * Machine interface for struct lttng_event_field.
This page took 0.033366 seconds and 4 git commands to generate.