itti_analyzer.c 4.93 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

Cedric Roux's avatar
Cedric Roux committed
22 23 24 25 26 27 28
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

#include <gtk/gtk.h>

winckel's avatar
winckel committed
29 30
#include <libxml/parser.h>

Cedric Roux's avatar
Cedric Roux committed
31 32 33 34 35 36 37 38
#include "xml_parse.h"
#include "resolvers.h"
#include "locate_root.h"
#include "file.h"
#include "ui_main_screen.h"

#include "rc.h"

39 40 41 42 43 44 45
#define G_LOG_LEVELS (G_LOG_LEVEL_ERROR     | \
                      G_LOG_LEVEL_CRITICAL  | \
                      G_LOG_LEVEL_WARNING   | \
                      G_LOG_LEVEL_MESSAGE   | \
                      G_LOG_LEVEL_INFO      | \
                      G_LOG_LEVEL_DEBUG)

Cedric Roux's avatar
Cedric Roux committed
46 47 48
int debug_buffers = 1;
int debug_parser = 0;

49 50
static void console_log_handler(const char *log_domain, GLogLevelFlags log_level,
                                const char *message, gpointer user_data)
51
{
52
    GLogLevelFlags domain_log_level = (GLogLevelFlags) user_data;
53 54 55 56
    time_t curr;
    struct tm *today;
    const char *level;

57
    if (ui_main_data.log_flags & domain_log_level & log_level)
58 59 60
    {
        switch (log_level & G_LOG_LEVEL_MASK)
        {
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        case G_LOG_LEVEL_ERROR:
            level = "Err ";
            break;
        case G_LOG_LEVEL_CRITICAL:
            level = "Crit";
            break;
        case G_LOG_LEVEL_WARNING:
            level = "Warn";
            break;
        case G_LOG_LEVEL_MESSAGE:
            level = "Msg ";
            break;
        case G_LOG_LEVEL_INFO:
            level = "Info";
            break;
        case G_LOG_LEVEL_DEBUG:
            level = "Dbg ";
            break;
        default:
            fprintf(stderr, "unknown log_level %u\n", log_level);
            level = NULL;
            g_assert_not_reached();
winckel's avatar
winckel committed
83
            break;
84
        }
85

86 87 88
        /* create a "timestamp" */
        time(&curr);
        today = localtime(&curr);
89

90
        fprintf(stderr, "%02u:%02u:%02u %-9s %s %s\n", today->tm_hour, today->tm_min, today->tm_sec,
91 92
                log_domain != NULL ? log_domain : "", level, message);
    }
93 94
}

Cedric Roux's avatar
Cedric Roux committed
95 96 97 98
int main(int argc, char *argv[])
{
    int ret = 0;

99 100 101 102 103 104 105 106
    GLogLevelFlags log_flags;

    log_flags = (GLogLevelFlags)
        (G_LOG_LEVEL_ERROR      |
        G_LOG_LEVEL_CRITICAL    |
        G_LOG_LEVEL_WARNING     |
        G_LOG_LEVEL_MESSAGE     |
        G_LOG_LEVEL_INFO        |
107
        G_LOG_LEVEL_DEBUG);
108

winckel's avatar
winckel committed
109 110 111 112
    /* This initialize the library and check potential ABI mismatches
     * between the version it was compiled for and the actual shared
     * library used.
     */
113 114
    LIBXML_TEST_VERSION;
    xmlInitParser();
winckel's avatar
winckel committed
115

116 117 118
    /* Initialize the widget set */
    gtk_init(&argc, &argv);

119 120 121 122 123 124 125
    /* Parse command line options */
    ui_gtk_parse_arg (argc, argv);

    /* Set log handlers:
     *                 Domain,      Levels,    Handler,             Domain enabled levels */
    g_log_set_handler( NULL,        log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS));
    g_log_set_handler("BUFFERS",    log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS & (~(G_LOG_LEVEL_DEBUG))));
126
    g_log_set_handler("PARSER",     log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS & (~(G_LOG_LEVEL_DEBUG))));
127 128 129 130 131 132
    g_log_set_handler("RESOLVER",   log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS & (~(G_LOG_LEVEL_DEBUG))));
    g_log_set_handler("UI",         log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS & (~(G_LOG_LEVEL_DEBUG))));
    g_log_set_handler("UI_CB",      log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS));
    g_log_set_handler("UI_FILTER",  log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS & (~(G_LOG_LEVEL_DEBUG))));
    g_log_set_handler("UI_INTER",   log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS));
    g_log_set_handler("UI_TREE",    log_flags, console_log_handler, (gpointer) (G_LOG_LEVELS & (~(G_LOG_LEVEL_DEBUG))));
133

Cedric Roux's avatar
Cedric Roux committed
134 135
    CHECK_FCT(ui_gtk_initialize(argc, argv));

136 137 138
    /* Enter the main event loop, and wait for user interaction */
    gtk_main ();

139 140 141 142 143
    /* Free the global variables that may
     * have been allocated by the parser.
     */
    xmlCleanupParser ();

Cedric Roux's avatar
Cedric Roux committed
144 145
    return ret;
}