[Bf-blender-cvs] [a4dd4ecfca3] soc-2020-info-editor: Interface: convert print to clog

Mateusz Grzeliński noreply at git.blender.org
Sat Jul 11 10:43:40 CEST 2020


Commit: a4dd4ecfca365cbbae10a885f619903b9ed84c3a
Author: Mateusz Grzeliński
Date:   Fri Jul 10 10:42:35 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rBa4dd4ecfca365cbbae10a885f619903b9ed84c3a

Interface: convert print to clog

===================================================================

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_anim.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_region_menu_pie.c
M	source/blender/editors/interface/interface_region_menu_popup.c
M	source/blender/editors/interface/interface_style.c
M	source/blender/editors/interface/interface_template_search_menu.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/view2d.c

===================================================================

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 9f6c6fff680..73416605664 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -21,6 +21,7 @@
  * \ingroup edinterface
  */
 
+#include <CLG_log.h>
 #include <ctype.h>
 #include <float.h>
 #include <limits.h>
@@ -80,6 +81,8 @@
 
 #include "interface_intern.h"
 
+static CLG_LogRef LOG = {"interface"};
+
 /* prototypes. */
 static void ui_but_to_pixelrect(struct rcti *rect,
                                 const struct ARegion *region,
@@ -1327,20 +1330,14 @@ static bool ui_but_event_property_operator_string(const bContext *C,
             data_path = BLI_sprintfN("scene.%s", path);
             MEM_freeN(path);
           }
-#if 0
           else {
-            printf("ERROR in %s(): Couldn't get path for scene property - %s\n",
-                   __func__,
-                   RNA_property_identifier(prop));
+            CLOG_ERROR(
+                &LOG, "Couldn't get path for scene property - %s", RNA_property_identifier(prop));
           }
-#endif
         }
       }
-      else {
-        // puts("other id");
-      }
 
-      // printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path);
+      CLOG_VERBOSE(&LOG, 4, "prop shortcut: '%s' (%s)", RNA_property_identifier(prop), data_path);
     }
 
     /* we have a datapath! */
@@ -2153,7 +2150,7 @@ void ui_but_v3_get(uiBut *but, float vec[3])
   }
   else {
     if (but->editvec == NULL) {
-      fprintf(stderr, "%s: can't get color, should never happen\n", __func__);
+      CLOG_ERROR(&LOG, "can not get color, should never happen");
       zero_v3(vec);
     }
   }
@@ -2303,7 +2300,7 @@ bool ui_but_is_rna_valid(uiBut *but)
   if (but->rnaprop == NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) {
     return true;
   }
-  printf("property removed %s: %p\n", but->drawstr, but->rnaprop);
+  CLOG_INFO(&LOG, "property removed %s: %p", but->drawstr, but->rnaprop);
   return false;
 }
 
@@ -6357,13 +6354,10 @@ void UI_but_func_search_set(uiBut *but,
   search->arg_free_fn = search_arg_free_fn;
 
   if (search_exec_fn) {
-#ifdef DEBUG
     if (but->func) {
       /* watch this, can be cause of much confusion, see: T47691 */
-      printf("%s: warning, overwriting button callback with search function callback!\n",
-             __func__);
+      CLOG_STR_WARN(&LOG, "overwriting button callback with search function callback!");
     }
-#endif
     UI_but_func_set(but, search_exec_fn, search->arg, active);
   }
 
@@ -6408,13 +6402,11 @@ static void operator_enum_search_update_fn(const struct bContext *C,
   PropertyRNA *prop = ot->prop;
 
   if (prop == NULL) {
-    printf("%s: %s has no enum property set\n", __func__, ot->idname);
+    CLOG_ERROR(&LOG, "%s has no enum property set", ot->idname);
   }
   else if (RNA_property_type(prop) != PROP_ENUM) {
-    printf("%s: %s \"%s\" is not an enum property\n",
-           __func__,
-           ot->idname,
-           RNA_property_identifier(prop));
+    CLOG_ERROR(
+        &LOG, "%s \"%s\" is not an enum property", ot->idname, RNA_property_identifier(prop));
   }
   else {
     PointerRNA *ptr = UI_but_operator_ptr_get(but); /* Will create it if needed! */
@@ -6453,7 +6445,7 @@ static void operator_enum_search_exec_fn(struct bContext *UNUSED(C), void *but,
        * because one of its parameters is the button itself! */
     }
     else {
-      printf("%s: op->prop for '%s' is NULL\n", __func__, ot->idname);
+      CLOG_INFO(&LOG, "op->prop for '%s' is NULL", ot->idname);
     }
   }
 }
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 5bf2147aff5..035e2456a16 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -18,6 +18,7 @@
  * \ingroup edinterface
  */
 
+#include <CLG_log.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -54,6 +55,8 @@
 
 #include "interface_intern.h"
 
+static CLG_LogRef LOG = {"interface.anim"};
+
 static FCurve *ui_but_get_fcurve(
     uiBut *but, AnimData **adt, bAction **action, bool *r_driven, bool *r_special)
 {
@@ -142,9 +145,10 @@ void ui_but_anim_decorate_update_from_flag(uiBut *but)
   const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(but);
 
   if (!but_anim) {
-    printf("Could not find button with matching property to decorate (%s.%s)\n",
-           RNA_struct_identifier(but->rnasearchpoin.type),
-           RNA_property_identifier(but->rnasearchprop));
+    CLOG_ERROR(&LOG,
+               "Could not find button with matching property to decorate (%s.%s)",
+               RNA_struct_identifier(but->rnasearchpoin.type),
+               RNA_property_identifier(but->rnasearchprop));
     return;
   }
 
@@ -242,17 +246,13 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
 
   /* button must have RNA-pointer to a numeric-capable property */
   if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
-    if (G.debug & G_DEBUG) {
-      printf("ERROR: create expression failed - button has no RNA info attached\n");
-    }
+    CLOG_ERROR(&LOG, "create expression failed - button has no RNA info attached");
     return false;
   }
 
   if (RNA_property_array_check(but->rnaprop) != 0) {
     if (but->rnaindex == -1) {
-      if (G.debug & G_DEBUG) {
-        printf("ERROR: create expression failed - can't create expression for entire array\n");
-      }
+      CLOG_ERROR(&LOG, "create expression failed - can't create expression for entire array");
       return false;
     }
   }
@@ -262,9 +262,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
    * don't allow drivers to be created for them */
   id = but->rnapoin.owner_id;
   if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
-    if (G.debug & G_DEBUG) {
-      printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id);
-    }
+    CLOG_ERROR(&LOG, "create expression failed - invalid data-block for adding drivers (%p)", id);
     return false;
   }
 
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index bad833265d9..ff0515fff3f 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -21,6 +21,7 @@
  * \ingroup edinterface
  */
 
+#include <CLG_log.h>
 #include <assert.h>
 #include <ctype.h>
 #include <float.h>
@@ -116,6 +117,8 @@
  */
 #define UI_DRAG_MAP_SOFT_RANGE_PIXEL_MAX 1000
 
+static CLG_LogRef LOG = {"interface.handlers"};
+
 /* proto */
 static int ui_do_but_EXIT(bContext *C,
                           uiBut *but,
@@ -1360,7 +1363,12 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl
       }
       else {
         /* highly unlikely */
-        printf("%s: cant find button\n", __func__);
+        CLOG_ERROR(&LOG,
+                   "can not find button (%p), type: %u, str: %s, tip: %s",
+                   but,
+                   but->type,
+                   but->str,
+                   but->tip);
       }
       /* end */
     }
@@ -3022,9 +3030,7 @@ static bool ui_textedit_insert_ascii(uiBut *but, uiHandleButtonData *data, char
   char buf[2] = {ascii, '\0'};
 
   if (UI_but_is_utf8(but) && (BLI_str_utf8_size(buf) == -1)) {
-    printf(
-        "%s: entering invalid ascii char into an ascii key (%d)\n", __func__, (int)(uchar)ascii);
-
+    CLOG_ERROR(&LOG, "entering invalid ascii char into an ascii key (%d)", (int)(uchar)ascii);
     return false;
   }
 
@@ -3345,7 +3351,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
       /* not a file?, strip non utf-8 chars */
       if (strip) {
         /* wont happen often so isn't that annoying to keep it here for a while */
-        printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip);
+        CLOG_ERROR(&LOG, "invalid utf8 - stripped chars %d", strip);
       }
     }
 
@@ -8598,9 +8604,7 @@ static bool ui_handle_button_activate_by_type(bContext *C, ARegion *region, uiBu
     ui_handle_button_activate(C, region, but, BUTTON_ACTIVATE);
   }
   else {
-#ifdef DEBUG
-    printf("%s: error, unhandled type: %u\n", __func__, but->type);
-#endif
+    CLOG_ERROR(&LOG, "unhandled type: %u", but->type);
     return false;
   }
   return true;
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index e1f72cd2898..5bda5aa5d31 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "CLG_log.h"
 #include "MEM_guardedalloc.h"
 
 #include "GPU_batch.h"
@@ -83,6 +84,8 @@
 #  define ICON_GRID_H 32
 #endif /* WITH_HEADLESS */
 
+static CLG_LogRef LOG = {"interface.icons"};
+
 typedef struct IconImage {
   int w;
   int h;
@@ -942,17 +945,17 @@ static void init_internal_icons(void)
       bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL);
 
       if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
-        printf(
+        CLOG_WARN(&LOG,
             "\n***WARNING***\n"
             "Icons file '%s' too small.\n"
-            "Using built-in Icons instead\n",
+            "Using built-in Icons instead",
             iconfilestr);
         IMB_freeImBuf(bbuf);
         bbuf = NULL;
       }
     }
     else {
-      printf("%s: 'icons' data path not found, continuing\n", __func__);
+      CLOG_STR_WARN("'icons' data path not found, continuing");
     }
   }
 #    endif
@@ -1057,7 +1060,7 @@ static void init_iconfile_list(struct ListBase *list)
 
         /* bad size or failed to load */
         if ((ifilex != ICON_IMAGE_W) || (ifiley != ICON_IMAGE_H)) {
-          printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
+          CLOG_WARN(&LOG, "icon '%s' is wrong size %dx%d", iconfilestr, ifilex, ifiley);
           continue;
         }
 #  endif /* removed */
@@ -1199,9 +1202,7 @@ int UI_icon_get_width(int ic

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list