[Bf-blender-cvs] [421669b8246] soc-2020-info-editor: Convert print to CLOGs

Mateusz Grzeliński noreply at git.blender.org
Thu Jul 2 11:19:15 CEST 2020


Commit: 421669b8246a3d60826404b745f3599fa8659c60
Author: Mateusz Grzeliński
Date:   Thu Jul 2 10:47:14 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB421669b8246a3d60826404b745f3599fa8659c60

Convert print to CLOGs

- change printing function style to be CLOG friendly
- remove G.debug and ifdef guards in favour of CLOG_INFO

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

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/BKE_brush.h
M	source/blender/blenkernel/BKE_customdata.h
M	source/blender/blenkernel/BKE_idprop.h
M	source/blender/blenkernel/BKE_image.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/bvhutils.c
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/curveprofile.c
M	source/blender/blenkernel/intern/customdata.c
M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/blenkernel/intern/idprop.c
M	source/blender/blenkernel/intern/idprop_utils.c
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenkernel/intern/linestyle.c

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

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 9162ed56655..2d656cb1c9d 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -380,9 +380,9 @@ void DM_calc_loop_tangents(DerivedMesh *dm,
 
 /* debug only */
 #ifndef NDEBUG
-char *DM_debug_info(DerivedMesh *dm);
+char *DM_debug_sprintfN(DerivedMesh *dm);
 void DM_debug_print(DerivedMesh *dm);
-void DM_debug_print_cdlayers(CustomData *cdata);
+char *DM_debug_sprintfN_cdlayers(CustomData *data);
 
 bool DM_is_valid(DerivedMesh *dm);
 #endif
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 4e9430ab3e1..94fa295d687 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -152,7 +152,7 @@ void BKE_brush_scale_size(int *r_brush_size,
   ((void)0)
 
 /* debugging only */
-void BKE_brush_debug_print_state(struct Brush *br);
+char *BKE_brush_debug_sprintfN_state(struct Brush *br);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 42beda352f5..c4b915f718f 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -77,7 +77,7 @@ typedef enum eCDAllocType {
 
 #define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type))
 
-void customData_mask_layers__print(const struct CustomData_MeshMasks *mask);
+char *customData_mask_layers__sprintN(const struct CustomData_MeshMasks *mask);
 
 typedef void (*cd_interp)(
     const void **sources, const float *weights, const float *sub_weights, int count, void *dest);
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 8f8d930a513..1c4b94c2507 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -195,7 +195,6 @@ char *IDP_reprN(const struct IDProperty *prop, uint *r_len);
 void IDP_repr_fn(const IDProperty *prop,
                  void (*str_append_fn)(void *user_data, const char *str, uint str_len),
                  void *user_data);
-void IDP_print(const struct IDProperty *prop);
 char *IDP_sprintN(const IDProperty *prop);
 
 #ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 1e5573ab014..39e538d479a 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -282,7 +282,7 @@ void BKE_image_packfiles_from_mem(struct ReportList *reports,
                                   const size_t data_len);
 
 /* prints memory statistics for images */
-void BKE_image_print_memlist(struct Main *bmain);
+char *BKE_image_sprintfN_memlist(struct Main *bmain);
 
 /* empty image block, of similar type and filename */
 struct Image *BKE_image_copy(struct Main *bmain, const struct Image *ima);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 8a5be6b9cb3..a8d1faa5113 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2302,7 +2302,7 @@ static void dm_debug_info_layers(DynStr *dynstr,
   }
 }
 
-char *DM_debug_info(DerivedMesh *dm)
+char *DM_debug_sprintfN(DerivedMesh *dm)
 {
   DynStr *dynstr = BLI_dynstr_new();
   char *ret;
@@ -2355,20 +2355,22 @@ char *DM_debug_info(DerivedMesh *dm)
   return ret;
 }
 
+/** better use CLOG_STR_INFO_N(&LOG, 1, DM_debug_sprintfN(dm)); */
 void DM_debug_print(DerivedMesh *dm)
 {
-  char *str = DM_debug_info(dm);
+  char *str = DM_debug_sprintfN(dm);
   puts(str);
   fflush(stdout);
   MEM_freeN(str);
 }
 
-void DM_debug_print_cdlayers(CustomData *data)
+char *DM_debug_sprintfN_cdlayers(CustomData *data)
 {
   int i;
   const CustomDataLayer *layer;
 
-  printf("{\n");
+  DynStr *message = BLI_dynstr_new();
+  BLI_dynstr_append(message, "{\n");
 
   for (i = 0, layer = data->layers; i < data->totlayer; i++, layer++) {
 
@@ -2377,16 +2379,21 @@ void DM_debug_print_cdlayers(CustomData *data)
     const char *structname;
     int structnum;
     CustomData_file_write_info(layer->type, &structname, &structnum);
-    printf("        dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
-           name,
-           structname,
-           layer->type,
-           (const void *)layer->data,
-           size,
-           (int)(MEM_allocN_len(layer->data) / size));
-  }
-
-  printf("}\n");
+    BLI_dynstr_appendf(
+        message,
+        "        dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
+        name,
+        structname,
+        layer->type,
+        (const void *)layer->data,
+        size,
+        (int)(MEM_allocN_len(layer->data) / size));
+  }
+  BLI_dynstr_append(message, "}");
+
+  char *cstring = BLI_dynstr_get_cstring(message);
+  BLI_dynstr_free(message);
+  return cstring;
 }
 
 bool DM_is_valid(DerivedMesh *dm)
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index a24b317b819..d271125ca42 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -21,6 +21,7 @@
  * and functions for writing *partial* files (only selected data-blocks).
  */
 
+#include <CLG_log.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -69,6 +70,8 @@
 #  include "BPY_extern.h"
 #endif
 
+static CLG_LogRef LOG = {"bke.blendfile"};
+
 /* -------------------------------------------------------------------- */
 /** \name High Level `.blend` file read/write.
  * \{ */
@@ -690,7 +693,6 @@ bool BKE_blendfile_userdef_write_all(ReportList *reports)
     bool ok_write;
     BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
 
-    printf("Writing userprefs: '%s' ", filepath);
     if (use_template_userpref) {
       ok_write = BKE_blendfile_userdef_write_app_template(filepath, reports);
     }
@@ -699,10 +701,10 @@ bool BKE_blendfile_userdef_write_all(ReportList *reports)
     }
 
     if (ok_write) {
-      printf("ok\n");
+      CLOG_INFO(&LOG, 0, "Writing userprefs ok: '%s'", filepath);
     }
     else {
-      printf("fail\n");
+      CLOG_ERROR(&LOG, "Writing userprefs fail: '%s'", filepath);
       ok = false;
     }
   }
@@ -715,12 +717,11 @@ bool BKE_blendfile_userdef_write_all(ReportList *reports)
       /* Also save app-template prefs */
       BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
 
-      printf("Writing userprefs app-template: '%s' ", filepath);
       if (BKE_blendfile_userdef_write(filepath, reports) != 0) {
-        printf("ok\n");
+        CLOG_INFO(&LOG, 0, "Writing userprefs app-template ok: '%s'", filepath);
       }
       else {
-        printf("fail\n");
+        CLOG_ERROR(&LOG, "Writing userprefs app-template fail: '%s'", filepath);
         ok = false;
       }
     }
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index a8f52593429..e87139c512d 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -19,6 +19,8 @@
  */
 
 #include "MEM_guardedalloc.h"
+#include <BLI_dynstr.h>
+#include <CLG_log.h>
 
 #include "DNA_brush_types.h"
 #include "DNA_defaults.h"
@@ -1360,27 +1362,29 @@ Brush *BKE_brush_copy(Main *bmain, const Brush *brush)
   return brush_copy;
 }
 
-void BKE_brush_debug_print_state(Brush *br)
+char *BKE_brush_debug_sprintfN_state(Brush *br)
 {
   /* create a fake brush and set it to the defaults */
   Brush def = {{NULL}};
   brush_defaults(&def);
+  DynStr *message = BLI_dynstr_new();
+  BLI_dynstr_appendf(message, "Brush (%p) setting vs default value:\n", br);
 
 #define BR_TEST(field, t) \
   if (br->field != def.field) \
-  printf("br->" #field " = %" #t ";\n", br->field)
+  BLI_dynstr_appendf(message, "br->" #field " = %" #t ";\n", br->field)
 
 #define BR_TEST_FLAG(_f) \
   if ((br->flag & _f) && !(def.flag & _f)) \
-    printf("br->flag |= " #_f ";\n"); \
+    BLI_dynstr_appendf(message, "br->flag |= " #_f ";\n"); \
   else if (!(br->flag & _f) && (def.flag & _f)) \
-  printf("br->flag &= ~" #_f ";\n")
+  BLI_dynstr_appendf(message, "br->flag &= ~" #_f ";\n")
 
 #define BR_TEST_FLAG_OVERLAY(_f) \
   if ((br->overlay_flags & _f) && !(def.overlay_flags & _f)) \
-    printf("br->overlay_flags |= " #_f ";\n"); \
+    BLI_dynstr_appendf(message, "br->overlay_flags |= " #_f ";\n"); \
   else if (!(br->overlay_flags & _f) && (def.overlay_flags & _f)) \
-  printf("br->overlay_flags &= ~" #_f ";\n")
+  BLI_dynstr_appendf(message, "br->overlay_flags &= ~" #_f ";\n")
 
   /* print out any non-default brush state */
   BR_TEST(normal_weight, f);
@@ -1452,17 +1456,19 @@ void BKE_brush_debug_print_state(Brush *br)
   BR_TEST(sub_col[2], f);
   BR_TEST(sub_col[3], f);
 
-  printf("\n");
-
 #undef BR_TEST
 #undef BR_TEST_FLAG
+  char *cstring = BLI_dynstr_get_cstring(message);
+  BLI_dynstr_free(message);
+  return cstring;
 }
 
+static CLG_LogRef BKE_LOG_BRUSH_DEFAULTS = {"bke.brush.defaults"};
+
 void BKE_brush_sculpt_reset(Brush *br)
 {
-  /* enable this to see any non-default
-   * settings used by a brush: */
-  // BKE_brush_debug_print_state(br);
+  /* enable this to see any non-default settings used by a brush: */
+  CLOG_STR_INFO_N(&BKE_LOG_BRUSH_DEFAULTS, 3, BKE_brush_debug_sprintfN_state(br));
 
   brush_defaults(br);
   BKE_brush_curve_preset(br, CURVE_PRESET_SMOOTH);
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 93794eb9709..37f41aa2d16 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -21,6 +21,7 @@
  * \ingroup bke
  */
 
+#include <CLG_log.h>
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -41,6 +42,8 @@
 
 #include "MEM_guardedalloc.h"
 
+static CLG_LogRef LOG = {"bke.bhvutils"};
+
 /* -------------------------------------------------------------------- */
 /** \name BVHCache
  * \{ */
@@ -1563,13 +1566,12 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
   }
 
   if (data->tre

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list