Changeset 177357 in webkit


Ignore:
Timestamp:
Dec 16, 2014 2:24:13 AM (9 years ago)
Author:
g.czajkowski@samsung.com
Message:

[EFL] Add logging domain for MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=139642

Reviewed by Gyuyoung Kim.

Similarly to EWebKit2, provide logging facility for MiniBrowser
based on Eina Log module to have a convenient way to display
all/subset/none messages for EFL based libraries and MiniBrowser.

Usage:

  1. Disable all messages: EINA_LOG_LEVEL=0 ./Tools/Scripts/run-launcher --efl
  1. Enable all messages: EINA_LOG_LEVEL=7 ./Tools/Scripts/run-launcher --efl
  1. Enable MiniBrowser and EWebkit2 messages only: EINA_LOG_LEVELS="minibrowser:7,ewebkit2:7" ./Tools/Scripts/run-launcher --efl

More information and examples you can find here:
http://docs.enlightenment.org/auto/eet/tutorial_log_page.html

  • MiniBrowser/efl/main.c:

(on_mouse_wheel):
(on_window_resize):
(save_page_contents_callback):
(script_execute_callback):
(on_key_down):
(on_download_request):
(on_download_finished):
(on_download_failed):
(quit):
(on_refresh_button_clicked):
(on_stop_button_clicked):
(navigation_button_longpress_process):
(on_popup_menu_item_clicked):
(popup_menu_populate):
(on_popup_menu_show):
(on_window_create):
(context_menu_item_selected_cb):
(context_menu_populate):
(on_context_menu_show):
(on_context_menu_hide):
(on_navigation_policy_decision):
(window_create):
(parse_cookies_policy):
(elm_main):
(has_scheme):
(list_item_label_get):
(on_popup_menu_hide):
(on_window_close):
(on_home_button_clicked):
Replace locally info() macro with newly introduced
one which uses Eina Log module. There is no logic change.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r177315 r177357  
     12014-12-16  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
     2
     3        [EFL] Add logging domain for MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=139642
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        Similarly to EWebKit2, provide logging facility for MiniBrowser
     9        based on Eina Log module to have a convenient way to display
     10        all/subset/none messages for EFL based libraries and MiniBrowser.
     11
     12        Usage:
     13        1. Disable all messages:
     14           EINA_LOG_LEVEL=0 ./Tools/Scripts/run-launcher --efl
     15
     16        2. Enable all messages:
     17           EINA_LOG_LEVEL=7 ./Tools/Scripts/run-launcher --efl
     18
     19        3. Enable MiniBrowser and EWebkit2 messages only:
     20           EINA_LOG_LEVELS="minibrowser:7,ewebkit2:7" ./Tools/Scripts/run-launcher --efl
     21
     22        More information and examples you can find here:
     23        http://docs.enlightenment.org/auto/eet/tutorial_log_page.html
     24
     25        * MiniBrowser/efl/main.c:
     26        (on_mouse_wheel):
     27        (on_window_resize):
     28        (save_page_contents_callback):
     29        (script_execute_callback):
     30        (on_key_down):
     31        (on_download_request):
     32        (on_download_finished):
     33        (on_download_failed):
     34        (quit):
     35        (on_refresh_button_clicked):
     36        (on_stop_button_clicked):
     37        (navigation_button_longpress_process):
     38        (on_popup_menu_item_clicked):
     39        (popup_menu_populate):
     40        (on_popup_menu_show):
     41        (on_window_create):
     42        (context_menu_item_selected_cb):
     43        (context_menu_populate):
     44        (on_context_menu_show):
     45        (on_context_menu_hide):
     46        (on_navigation_policy_decision):
     47        (window_create):
     48        (parse_cookies_policy):
     49        (elm_main):
     50        (has_scheme):
     51        (list_item_label_get):
     52        (on_popup_menu_hide):
     53        (on_window_close):
     54        (on_home_button_clicked):
     55        Replace locally info() macro with newly introduced
     56        one which uses Eina Log module. There is no logic change.
     57
    1582014-12-15  Dániel Bátyai  <dbatyai.u-szeged@partner.samsung.com>
    259
  • trunk/Tools/MiniBrowser/efl/main.c

    r177256 r177357  
    3838static const double LIST_ITEM_HEIGHT = 24.35;
    3939
    40 #define info(format, args...)       \
    41     do {                            \
    42         if (verbose)                \
    43             printf(format"\n", ##args); \
    44     } while (0)
    45 
    46 static int verbose = 1;
    4740static Eina_List *windows = NULL;
    4841static char *evas_engine_name = NULL;
     
    7164// The zoom values are chosen to be like in Mozilla Firefox 3.
    7265const static float zoomLevels[] = {0.3, 0.5, 0.67, 0.8, 0.9, 1.0, 1.1, 1.2, 1.33, 1.5, 1.7, 2.0, 2.4, 3.0};
     66static int _log_domain_id = -1;
     67
     68#define INFO(...) EINA_LOG_DOM_INFO(_log_domain_id, __VA_ARGS__)
     69#define ERROR(...) EINA_LOG_DOM_ERR(_log_domain_id, __VA_ARGS__)
    7370
    7471static Eina_Bool
     
    317314        if (ev->z == -1 && zoom_level_set(ewk_view, window->current_zoom_level + 1)) {
    318315            window->current_zoom_level++;
    319             info("Zoom in (Ctrl + 'scroll up') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
     316            INFO("Zoom in (Ctrl + 'scroll up') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
    320317        } else if (ev->z == 1 && zoom_level_set(ewk_view, window->current_zoom_level - 1)) {
    321318            window->current_zoom_level--;
    322             info("Zoom out (Ctrl + 'scroll down') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
     319            INFO("Zoom out (Ctrl + 'scroll down') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
    323320        }
    324321    }
     
    331328
    332329    if (!window) {
    333         info("ERROR: window is NULL.");
     330        ERROR("Window is NULL.");
    334331        return;
    335332    }
     
    482479        eina_strbuf_append_printf(fileNameWithMht, "%s.mht", fileName);
    483480        ef = eet_open(eina_strbuf_string_get(fileNameWithMht), EET_FILE_MODE_WRITE);
    484         info("Saving file to: %s", eina_strbuf_string_get(fileNameWithMht));
     481        INFO("Saving file to: %s", eina_strbuf_string_get(fileNameWithMht));
    485482        eina_strbuf_free(fileNameWithMht);
    486483    } else {
    487484        ef = eet_open(fileName, EET_FILE_MODE_WRITE);
    488         info("Saving file to: %s", fileName);
     485        INFO("Saving file to: %s", fileName);
    489486    }
    490487
    491488    if (!ef) {
    492         info("ERROR: Could not create File");
     489        ERROR("Could not create File");
    493490        return;
    494491    }
     
    496493    eet_write(ef, "MHTML data", data, strlen(data), 0 /* compress */);
    497494    eet_close(ef);
    498     info("SUCCESS: saved.");
     495    INFO("SUCCESS: saved.");
    499496
    500497    eina_stringshare_del(fileName);
     
    510507    if (return_value) {
    511508        eina_strbuf_append(text_buffer, return_value);
    512         info("selected text is: %s", eina_strbuf_string_get(text_buffer));
     509        INFO("selected text is: %s", eina_strbuf_string_get(text_buffer));
    513510        elm_entry_entry_set(window->search.search_field, eina_strbuf_string_get(text_buffer));   
    514511    }
     
    535532
    536533    if (!strcmp(ev->key, "Left") && altPressed) {
    537         info("Back (Alt+Left) was pressed");
     534        INFO("Back (Alt+Left) was pressed");
    538535        if (!ewk_view_back(ewk_view))
    539             info("Back ignored: No back history");
     536            INFO("Back ignored: No back history");
    540537    } else if (!strcmp(ev->key, "Right") && altPressed) {
    541         info("Forward (Alt+Right) was pressed");
     538        INFO("Forward (Alt+Right) was pressed");
    542539        if (!ewk_view_forward(ewk_view))
    543             info("Forward ignored: No forward history");
     540            INFO("Forward ignored: No forward history");
    544541    } else if (!strcmp(ev->key, "Home") && altPressed) {
    545         info("Home (Alt+Home) was pressed");
     542        INFO("Home (Alt+Home) was pressed");
    546543        ewk_view_url_set(window->ewk_view, DEFAULT_URL);
    547544    } else if (!strcmp(ev->key, "F3")) {
    548545        currentEncoding = (currentEncoding + 1) % (sizeof(encodings) / sizeof(encodings[0]));
    549         info("Set encoding (F3) pressed. New encoding to %s", encodings[currentEncoding]);
     546        INFO("Set encoding (F3) pressed. New encoding to %s", encodings[currentEncoding]);
    550547        ewk_view_custom_encoding_set(ewk_view, encodings[currentEncoding]);
    551548    } else if ((!strcmp(ev->key, "F5") && ctrlPressed) || (!strcmp(ev->key, "r") && (shiftPressed & ctrlPressed))) {
    552         info("Reload ignoring cache (Ctrl+F5 or Ctrl+Shift+r) was pressed, reloading and bypassing cache...");
     549        INFO("Reload ignoring cache (Ctrl+F5 or Ctrl+Shift+r) was pressed, reloading and bypassing cache...");
    553550        ewk_view_reload_bypass_cache(ewk_view);
    554551    } else if (!strcmp(ev->key, "F5") || (!strcmp(ev->key, "r") && ctrlPressed)) {
    555         info("Reload (F5 or Ctrl+r) was pressed, reloading...");
     552        INFO("Reload (F5 or Ctrl+r) was pressed, reloading...");
    556553        ewk_view_reload(ewk_view);
    557554    } else if (!strcmp(ev->key, "F6")) {
    558         info("Stop (F6) was pressed, stop loading.");
     555        INFO("Stop (F6) was pressed, stop loading.");
    559556        ewk_view_stop(ewk_view);
    560557    } else if (!strcmp(ev->key, "F7")) {
     
    562559        mode = (++mode) % (EWK_PAGINATION_MODE_BOTTOM_TO_TOP + 1);
    563560        if (ewk_view_pagination_mode_set(ewk_view, mode))
    564             info("Change Pagination Mode (F7) was pressed, changed to: %d", mode);
     561            INFO("Change Pagination Mode (F7) was pressed, changed to: %d", mode);
    565562        else
    566             info("Change Pagination Mode (F7) was pressed, but NOT changed!");
     563            INFO("Change Pagination Mode (F7) was pressed, but NOT changed!");
    567564    } else if (!strcmp(ev->key, "F11")) {
    568         info("Fullscreen (F11) was pressed, toggling window/fullscreen.");
     565        INFO("Fullscreen (F11) was pressed, toggling window/fullscreen.");
    569566        elm_win_fullscreen_set(window->elm_window, !elm_win_fullscreen_get(window->elm_window));
    570567    } else if (!strcmp(ev->key, "n") && ctrlPressed) {
    571         info("Create new window (Ctrl+n) was pressed.");
     568        INFO("Create new window (Ctrl+n) was pressed.");
    572569        Browser_Window *window = window_create(NULL, 0, 0);
    573570        ewk_view_url_set(window->ewk_view, DEFAULT_URL);
     
    575572        windows = eina_list_append(windows, window);
    576573    } else if (!strcmp(ev->key, "i") && ctrlPressed) {
    577         info("Show Inspector (Ctrl+i) was pressed.");
     574        INFO("Show Inspector (Ctrl+i) was pressed.");
    578575        ewk_view_inspector_show(ewk_view);
    579576    } else if (!strcmp(ev->key, "f") && ctrlPressed) {
    580         info("Show Search Box (Ctrl+f) was pressed.");
     577        INFO("Show Search Box (Ctrl+f) was pressed.");
    581578        const char get_data_script[] = "window.getSelection().toString();";
    582579        ewk_view_script_execute(ewk_view, get_data_script, script_execute_callback, (void*)(window));
     
    593590        if (zoom_level_set(ewk_view, window->current_zoom_level - 1))
    594591            window->current_zoom_level--;
    595         info("Zoom out (Ctrl + '-') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
     592        INFO("Zoom out (Ctrl + '-') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
    596593    } else if (ctrlPressed && (!strcmp(ev->key, "equal") || !strcmp(ev->key, "KP_Add"))) {
    597594        if (zoom_level_set(ewk_view, window->current_zoom_level + 1))
    598595            window->current_zoom_level++;
    599         info("Zoom in (Ctrl + '+') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
     596        INFO("Zoom in (Ctrl + '+') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
    600597    } else if (ctrlPressed && !strcmp(ev->key, "0")) {
    601598        if (zoom_level_set(ewk_view, DEFAULT_ZOOM_LEVEL))
    602599            window->current_zoom_level = DEFAULT_ZOOM_LEVEL;
    603         info("Zoom to default (Ctrl + '0') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
     600        INFO("Zoom to default (Ctrl + '0') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);
    604601    } else if (ctrlPressed && !strcmp(ev->key, "s")) {
    605602        Eina_Strbuf *default_file = eina_strbuf_new();
     
    607604        const char *title = ewk_view_title_get(window->ewk_view);
    608605        eina_strbuf_append_printf(default_file, "%s/%s.mht", home_path ? home_path : "/home", title ? title : "title");
    609         info("Pressed (CTRL + S) : Saving Current Page.");
     606        INFO("Pressed (CTRL + S) : Saving Current Page.");
    610607        Eina_Stringshare *save_file_name = show_file_entry_dialog(window, "SAVE", eina_strbuf_string_get(default_file));
    611608        if (!save_file_name)
     
    620617        Eina_Strbuf *uri_path = eina_strbuf_new();
    621618        eina_strbuf_append_printf(uri_path, "file://%s", open_file_name);
    622         info("pressed (CTRL + L) : Loading Page %s", eina_strbuf_string_get(uri_path));
     619        INFO("pressed (CTRL + L) : Loading Page %s", eina_strbuf_string_get(uri_path));
    623620        ewk_view_url_set(ewk_view, eina_strbuf_string_get(uri_path));
    624621        eina_strbuf_free(uri_path);
     
    760757        url = eina_strbuf_string_steal(destination_path);
    761758        if (mkstemp(url) == -1) {
    762             info("ERROR: Could not generate a unique file name.");
     759            ERROR("Could not generate a unique file name.");
    763760            return;
    764761        }
     
    767764
    768765    ewk_download_job_destination_set(download, eina_strbuf_string_get(destination_path));
    769     info("Downloading: %s", eina_strbuf_string_get(destination_path));
     766    INFO("Downloading: %s", eina_strbuf_string_get(destination_path));
    770767    eina_strbuf_free(destination_path);
    771768    eina_stringshare_del(save_file_path);
     
    849846{
    850847    Ewk_Download_Job *download = (Ewk_Download_Job *)event_info;
    851     info("Download finished: %s",  ewk_download_job_destination_get(download));
     848    INFO("Download finished: %s",  ewk_download_job_destination_get(download));
    852849}
    853850
     
    855852on_download_failed(void *user_data, Evas_Object *ewk_view, void *event_info)
    856853{
    857     info("Download failed!");
     854    INFO("Download failed!");
    858855}
    859856
     
    988985quit(Eina_Bool success, const char *msg)
    989986{
     987    if (msg)
     988        success ? INFO(msg) : ERROR(msg);
     989
     990    eina_log_domain_unregister(_log_domain_id);
    990991    ewk_shutdown();
    991992    elm_shutdown();
    992 
    993     if (msg)
    994         fputs(msg, (success) ? stdout : stderr);
    995993
    996994    if (!success)
     
    11821180    Eina_Bool ctrlPressed = evas_key_modifier_is_set(evas_key_modifier_get(evas), "Control");
    11831181    if (ctrlPressed) {
    1184         info("Reloading and bypassing cache...");
     1182        INFO("Reloading and bypassing cache...");
    11851183        ewk_view_reload_bypass_cache(window->ewk_view);
    11861184    } else {
    1187         info("Reloading...");
     1185        INFO("Reloading...");
    11881186        ewk_view_reload(window->ewk_view);
    11891187    }
     
    11951193    Browser_Window *window = (Browser_Window *)user_data;
    11961194
    1197     info("Stop was Pressed. Aborting load...");
     1195    INFO("Stop was Pressed. Aborting load...");
    11981196    ewk_view_stop(window->ewk_view);
    11991197}
     
    12551253
    12561254    item_count = eina_list_count(window->history.history_list_items);
    1257     info("navigation_button_longpress_process : Item count = %d forward_navigation_enabled = %d", item_count, forward_navigation_enabled);
     1255    INFO("navigation_button_longpress_process : Item count = %d forward_navigation_enabled = %d", item_count, forward_navigation_enabled);
    12581256
    12591257    EINA_LIST_FOREACH(window->history.history_list_items, l, data) {
    12601258        title = ewk_back_forward_list_item_title_get(data);
    1261         info(" title = %s", title);
     1259        INFO(" title = %s", title);
    12621260        elm_genlist_item_append(window->history.history_list, list_item, (void *)(title), NULL, ELM_GENLIST_ITEM_NONE, on_list_item_select, data);
    12631261    }
     
    14961494    Elm_Object_Item *item = (Elm_Object_Item *)event_info;
    14971495
    1498     info("Selected popup menu index: %u", elm_menu_item_index_get(item));
     1496    INFO("Selected popup menu index: %u", elm_menu_item_index_get(item));
    14991497    ewk_popup_menu_selected_index_set(window->popup.ewk_menu, elm_menu_item_index_get(item));
    15001498
     
    15301528            break;
    15311529        default:
    1532             info("Unrecognized popup menu item type!");
     1530            INFO("Unrecognized popup menu item type!");
    15331531            break;
    15341532        }
     
    15491547    popup_menu_populate(window->popup.elm_menu, ewk_menu, window);
    15501548
    1551     info("Showing popup menu at (%d, %d)", rect.x, rect.y);
     1549    INFO("Showing popup menu at (%d, %d)", rect.x, rect.y);
    15521550    elm_menu_move(window->popup.elm_menu, rect.x, rect.y);
    15531551    evas_object_show(window->popup.elm_menu);
     
    16811679    windows = eina_list_append(windows, window);
    16821680
    1683     info("minibrowser: location(%d,%d) size=(%d,%d)", x, y, width, height);
     1681    INFO("minibrowser: location(%d,%d) size=(%d,%d)", x, y, width, height);
    16841682
    16851683    return new_view;
     
    16971695{
    16981696    if (!data) {
    1699         info("ERROR: context menu callback data is NULL.");
     1697        ERROR("Context menu callback data is NULL.");
    17001698        return;
    17011699    }
    17021700
    17031701    Ewk_Context_Menu_Item *ewk_item = (Ewk_Context_Menu_Item *)data;
    1704     info("Selected context menu item: %s.", ewk_context_menu_item_title_get(ewk_item));
     1702    INFO("Selected context menu item: %s.", ewk_context_menu_item_title_get(ewk_item));
    17051703    ewk_context_menu_item_select(ewk_context_menu_item_parent_menu_get(ewk_item), ewk_item);
    17061704    ewk_context_menu_hide(ewk_context_menu_item_parent_menu_get(ewk_item));
     
    17111709{
    17121710    if (!context_menu || !ewk_menu) {
    1713         info("ERROR: necessary objects are NULL.");
     1711        ERROR("Necessary objects are NULL.");
    17141712        return;
    17151713    }
     
    17531751
    17541752    if (!window || !menu) {
    1755         info("ERROR: necessary objects are NULL.");
     1753        ERROR("Necessary objects are NULL.");
    17561754        return EINA_FALSE;
    17571755    }
     
    17601758
    17611759    if (!window->context_menu.elm_menu) {
    1762         info("ERROR: could not create menu widget.");
     1760        ERROR("Could not create menu widget.");
    17631761        return EINA_FALSE;
    17641762    }
     
    17681766    context_menu_populate(window->context_menu.elm_menu, menu, NULL);
    17691767
    1770     info("Showing context menu at (%d, %d).", x, y);
     1768    INFO("Showing context menu at (%d, %d).", x, y);
    17711769    elm_menu_move(window->context_menu.elm_menu, x, y);
    17721770    evas_object_show(window->context_menu.elm_menu);
     
    17811779
    17821780    if (!window || !window->context_menu.elm_menu) {
    1783         info("ERROR: necessary objects are NULL.");
     1781        ERROR("Necessary objects are NULL.");
    17841782        return EINA_FALSE;
    17851783    }
     
    19701968        ewk_view_url_set(window->ewk_view, ewk_url_request_url_get(ewk_navigation_policy_request_get(decision)));
    19711969        windows = eina_list_append(windows, window);
    1972         info("Mouse middle button pressed, open link in new window");
     1970        INFO("Mouse middle button pressed, open link in new window");
    19731971
    19741972        ewk_navigation_policy_decision_reject(decision);
     
    20102008    Browser_Window *window = calloc(1, sizeof(Browser_Window));
    20112009    if (!window) {
    2012         info("ERROR: could not create browser window.");
     2010        ERROR("Could not create browser window.");
    20132011        return NULL;
    20142012    }
     
    22552253    ewk_settings_frame_flattening_enabled_set(settings, frame_flattening_enabled);
    22562254    ewk_settings_local_storage_enabled_set(settings, local_storage_enabled);
    2257     info("HTML5 local storage is %s for this view.", local_storage_enabled ? "enabled" : "disabled");
     2255    INFO("HTML5 local storage is %s for this view.", local_storage_enabled ? "enabled" : "disabled");
    22582256    elm_win_fullscreen_set(window->elm_window, fullscreen_enabled);
    22592257    ewk_settings_developer_extras_enabled_set(settings, EINA_TRUE);
     
    23142312        return EWK_COOKIE_ACCEPT_POLICY_NEVER;
    23152313    if (strcmp(input_string, "no-third-party"))
    2316         info("Unrecognized type for cookies policy: %s.", input_string);
     2314        INFO("Unrecognized type for cookies policy: %s.", input_string);
    23172315    return EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY;
    23182316}
     
    23792377        return EXIT_FAILURE;
    23802378
     2379    _log_domain_id = eina_log_domain_register("minibrowser", EINA_COLOR_YELLOW);
     2380
    23812381    ewk_view_smart_class_set(miniBrowserViewSmartClass());
    23822382
     
    23852385
    23862386    if (args < 0)
    2387         return quit(EINA_FALSE, "ERROR: could not parse options.\n");
     2387        return quit(EINA_FALSE, "Could not parse options.");
    23882388
    23892389    if (quitOption)
     
    24252425    window = window_create(NULL, 0, 0);
    24262426    if (!window)
    2427         return quit(EINA_FALSE, "ERROR: could not create browser window.\n");
     2427        return quit(EINA_FALSE, "Could not create browser window.");
    24282428
    24292429    if (args < argc) {
Note: See TracChangeset for help on using the changeset viewer.