2014-02-25 20:32:12 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-02-14 15:14:06 -08:00
|
|
|
#include <Eo.h>
|
2014-02-25 20:32:12 -08:00
|
|
|
#include <Eina.h>
|
2016-06-10 02:03:40 -07:00
|
|
|
#include <Elementary.h>
|
2014-02-25 20:32:12 -08:00
|
|
|
|
|
|
|
#include "edi_logpanel.h"
|
2014-12-01 14:54:17 -08:00
|
|
|
#include "edi_config.h"
|
2014-02-25 20:32:12 -08:00
|
|
|
|
|
|
|
#include "edi_private.h"
|
|
|
|
|
2015-02-14 15:14:06 -08:00
|
|
|
#define _EDI_LOG_ERROR "err"
|
|
|
|
|
2014-11-04 14:21:49 -08:00
|
|
|
static Evas_Object *_info_widget;
|
|
|
|
static Elm_Code *_elm_code;
|
2014-02-25 20:32:12 -08:00
|
|
|
|
2015-10-10 12:19:40 -07:00
|
|
|
static Eina_Bool
|
2015-10-10 12:45:56 -07:00
|
|
|
_edi_logpanel_ignore(Eina_Log_Level level, const char *fnc)
|
2015-10-10 12:19:40 -07:00
|
|
|
{
|
2015-10-10 12:45:56 -07:00
|
|
|
if (level <= EINA_LOG_LEVEL_DBG)
|
|
|
|
return !strncmp(fnc, "_eo_", 4) || !strncmp(fnc, "_evas_", 6) ||
|
|
|
|
!strncmp(fnc, "_ecore_", 7) || !strncmp(fnc, "_edje_", 6) ||
|
2016-09-10 14:58:38 -07:00
|
|
|
!strncmp(fnc, "_elm_", 5) || !strncmp(fnc, "_drm_", 5) ||
|
|
|
|
!strncmp(fnc, "_eina_", 6);
|
2015-10-10 12:45:56 -07:00
|
|
|
|
2015-10-10 12:19:40 -07:00
|
|
|
return !strncmp(fnc, "_evas_object_smart_need_recalculate_set", strlen(fnc));
|
|
|
|
}
|
|
|
|
|
2015-02-14 15:14:06 -08:00
|
|
|
static void
|
|
|
|
_edi_logpanel_print_cb(const Eina_Log_Domain *domain, Eina_Log_Level level,
|
|
|
|
const char *file, const char *fnc, int line, const char *fmt,
|
|
|
|
void *data EINA_UNUSED, va_list args)
|
2014-02-25 20:32:12 -08:00
|
|
|
{
|
2015-02-14 15:14:06 -08:00
|
|
|
unsigned int printed, buffer_len = 512;
|
2014-02-25 20:32:12 -08:00
|
|
|
char buffer [buffer_len];
|
|
|
|
|
2017-03-21 15:44:33 -07:00
|
|
|
if (_edi_log_dom == -1) return;
|
|
|
|
|
2015-10-10 12:45:56 -07:00
|
|
|
if (_edi_logpanel_ignore(level, fnc))
|
2015-10-10 12:19:40 -07:00
|
|
|
return;
|
|
|
|
|
2014-02-25 20:32:12 -08:00
|
|
|
printed = snprintf(buffer, buffer_len, "%s:%s:%s (%d): ",
|
|
|
|
domain->domain_str, file, fnc, line);
|
|
|
|
vsnprintf(buffer + printed, buffer_len - printed, fmt, args);
|
|
|
|
|
2015-02-14 15:14:06 -08:00
|
|
|
elm_code_file_line_append(_elm_code->file, buffer, strlen(buffer),
|
|
|
|
(level <= EINA_LOG_LEVEL_ERR) ? _EDI_LOG_ERROR : NULL);
|
|
|
|
}
|
|
|
|
|
2016-07-01 02:17:54 -07:00
|
|
|
static void
|
2016-09-04 10:48:08 -07:00
|
|
|
_edi_logpanel_line_cb(void *data EINA_UNUSED, const Efl_Event *event)
|
2015-02-14 15:14:06 -08:00
|
|
|
{
|
|
|
|
Elm_Code_Line *line;
|
|
|
|
|
2016-04-13 18:48:33 -07:00
|
|
|
line = (Elm_Code_Line *)event->info;
|
2015-02-14 15:14:06 -08:00
|
|
|
|
|
|
|
if (line->data)
|
|
|
|
line->status = ELM_CODE_STATUS_TYPE_ERROR;
|
2014-02-25 20:32:12 -08:00
|
|
|
}
|
|
|
|
|
2015-03-08 14:07:02 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_edi_logpanel_config_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
|
|
|
{
|
2015-06-02 00:22:36 -07:00
|
|
|
elm_code_widget_font_set(_info_widget, _edi_project_config->font.name, _edi_project_config->font.size);
|
2015-03-08 14:07:02 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2015-01-10 09:43:12 -08:00
|
|
|
void edi_logpanel_add(Evas_Object *parent)
|
2014-02-25 20:32:12 -08:00
|
|
|
{
|
2015-01-26 11:05:34 -08:00
|
|
|
Elm_Code_Widget *widget;
|
2014-11-04 14:21:49 -08:00
|
|
|
Elm_Code *code;
|
2014-02-25 20:32:12 -08:00
|
|
|
|
2014-11-16 15:52:41 -08:00
|
|
|
code = elm_code_create();
|
2015-06-02 00:22:36 -07:00
|
|
|
widget = elm_code_widget_add(parent, code);
|
2016-03-09 16:06:50 -08:00
|
|
|
elm_obj_code_widget_font_set(widget, _edi_project_config->font.name, _edi_project_config->font.size);
|
|
|
|
elm_obj_code_widget_gravity_set(widget, 0.0, 1.0);
|
2016-08-18 07:05:09 -07:00
|
|
|
efl_event_callback_add(widget, &ELM_CODE_EVENT_LINE_LOAD_DONE, _edi_logpanel_line_cb, NULL);
|
2014-11-04 14:21:49 -08:00
|
|
|
evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(widget);
|
2014-02-25 20:32:12 -08:00
|
|
|
|
2014-11-04 14:21:49 -08:00
|
|
|
_elm_code = code;
|
|
|
|
_info_widget = widget;
|
2014-02-25 20:32:12 -08:00
|
|
|
|
2015-02-14 15:14:06 -08:00
|
|
|
eina_log_print_cb_set(_edi_logpanel_print_cb, NULL);
|
2014-02-25 20:32:12 -08:00
|
|
|
eina_log_color_disable_set(EINA_TRUE);
|
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_box_pack_end(parent, widget);
|
2015-03-08 14:07:02 -07:00
|
|
|
ecore_event_handler_add(EDI_EVENT_CONFIG_CHANGED, _edi_logpanel_config_changed, NULL);
|
2014-02-25 20:32:12 -08:00
|
|
|
}
|