[Bf-blender-cvs] [8ac6bac444e] soc-2020-info-editor: Convert print to CLOGs

Mateusz Grzeliński noreply at git.blender.org
Wed Jul 1 23:44:13 CEST 2020


Commit: 8ac6bac444ed34cac3e9e3d66f2eacb672d13842
Author: Mateusz Grzeliński
Date:   Wed Jul 1 23:01:27 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB8ac6bac444ed34cac3e9e3d66f2eacb672d13842

Convert print to CLOGs

remove debug check (G.debug) and custom macros (PATH_DEBUG) where possible.
- there is no performance improvement for checking G.debug - info log must be manually activated anyways
- imo info with verbosity level set is nicer solution than macros, although there will be performance hit

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

M	source/blender/blenkernel/intern/anim_data.c
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/appdir.c

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

diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c
index 841fdaa3b2c..a95d2490cf2 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -951,13 +951,9 @@ char *BKE_animsys_fix_rna_path_rename(ID *owner_id,
   }
 
   /* fix given path */
-  if (G.debug & G_DEBUG) {
-    printf("%s | %s  | oldpath = %p ", oldN, newN, old_path);
-  }
+  CLOG_INFO(&LOG, 3, "%s | %s  | oldpath = %p ", oldN, newN, old_path);
   result = rna_path_rename_fix(owner_id, prefix, oldN, newN, old_path, verify_paths);
-  if (G.debug & G_DEBUG) {
-    printf("path rename result = %p\n", result);
-  }
+  CLOG_INFO(&LOG, 3, "path rename result = %p\n", result);
 
   /* free the temp names */
   MEM_freeN(oldN);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 5e4b280d0d0..fb5bce97b75 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -633,15 +633,12 @@ static void action_idcode_patch_check(ID *id, bAction *act)
     act->idroot = idcode;
   }
   else if (act->idroot != idcode) {
-    /* only report this error if debug mode is enabled (to save performance everywhere else) */
-    if (G.debug & G_DEBUG) {
-      printf(
-          "AnimSys Safety Check Failed: Action '%s' is not meant to be used from ID-Blocks of "
-          "type %d such as '%s'\n",
-          act->id.name + 2,
-          idcode,
-          id->name);
-    }
+    CLOG_WARN(&LOG,
+              "AnimSys Safety Check Failed: Action '%s' is not meant to be used from ID-Blocks of "
+              "type %d such as '%s'",
+              act->id.name + 2,
+              idcode,
+              id->name);
   }
 }
 
@@ -1294,12 +1291,10 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, NlaEvalData *nlaeval,
 
   if (!RNA_path_resolve_property(ptr, path, &key.ptr, &key.prop)) {
     /* Report failure to resolve the path. */
-    if (G.debug & G_DEBUG) {
-      CLOG_WARN(&LOG,
-                "Animato: Invalid path. ID = '%s',  '%s'",
-                (ptr->owner_id) ? (ptr->owner_id->name + 2) : "<No ID>",
-                path);
-    }
+    CLOG_WARN(&LOG,
+              "Animato: Invalid path. ID = '%s',  '%s'",
+              (ptr->owner_id) ? (ptr->owner_id->name + 2) : "<No ID>",
+              path);
 
     return NULL;
   }
@@ -1537,15 +1532,13 @@ static bool nlaeval_blend_value(NlaBlendData *blend,
   int index = nlaevalchan_validate_index(nec, array_index);
 
   if (index < 0) {
-    if (G.debug & G_DEBUG) {
-      ID *id = nec->key.ptr.owner_id;
-      CLOG_WARN(&LOG,
-                "Animato: Invalid array index. ID = '%s',  '%s[%d]', array length is %d",
-                id ? (id->name + 2) : "<No ID>",
-                nec->rna_path,
-                array_index,
-                nec->base_snapshot.length);
-    }
+    ID *id = nec->key.ptr.owner_id;
+    CLOG_WARN(&LOG,
+              "Animato: Invalid array index. ID = '%s',  '%s[%d]', array length is %d",
+              id ? (id->name + 2) : "<No ID>",
+              nec->rna_path,
+              array_index,
+              nec->base_snapshot.length);
 
     return false;
   }
@@ -2260,9 +2253,7 @@ static void animsys_calculate_nla(PointerRNA *ptr,
   else {
     /* special case - evaluate as if there isn't any NLA data */
     /* TODO: this is really just a stop-gap measure... */
-    if (G.debug & G_DEBUG) {
-      CLOG_WARN(&LOG, "NLA Eval: Stopgap for active action on NLA Stack - no strips case");
-    }
+    CLOG_WARN(&LOG, "NLA Eval: Stopgap for active action on NLA Stack - no strips case");
 
     animsys_evaluate_action(ptr, adt->action, ctime, flush_to_original);
   }
@@ -2560,9 +2551,7 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, float
 {
   ID *id;
 
-  if (G.debug & G_DEBUG) {
-    printf("Evaluate all animation - %f\n", ctime);
-  }
+  CLOG_INFO(&LOG, 3, "Evaluate all animation - %f", ctime);
 
   const bool flush_to_original = DEG_is_active(depsgraph);
 
@@ -2610,9 +2599,7 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, float
    * set correctly, so this optimization must be skipped in that case...
    */
   if (BLI_listbase_is_empty(&main->actions) && BLI_listbase_is_empty(&main->curves)) {
-    if (G.debug & G_DEBUG) {
-      printf("\tNo Actions, so no animation needs to be evaluated...\n");
-    }
+    CLOG_INFO(&LOG, 3, "\tNo Actions, so no animation needs to be evaluated...");
 
     return;
   }
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 8189385a69d..c2b94f89b42 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -108,8 +108,6 @@ const char *BKE_appdir_folder_default(void)
 #endif /* WIN32 */
 }
 
-// #define PATH_DEBUG
-
 /* returns a formatted representation of the specified version number. Non-re-entrant! */
 static char *blender_version_decimal(const int ver)
 {
@@ -149,15 +147,11 @@ static bool test_path(char *targetpath,
    * if folder_name is specified but not otherwise? */
 
   if (BLI_is_dir(targetpath)) {
-#ifdef PATH_DEBUG
-    printf("\t%s found: %s\n", __func__, targetpath);
-#endif
+    CLOG_INFO(&LOG, 1, "\tfound: %s", targetpath);
     return true;
   }
   else {
-#ifdef PATH_DEBUG
-    printf("\t%s missing: %s\n", __func__, targetpath);
-#endif
+    CLOG_INFO(&LOG, 1, "\tmissing: %s", targetpath);
     // targetpath[0] = '\0';
     return false;
   }
@@ -176,16 +170,12 @@ static bool test_env_path(char *path, const char *envvar)
 
   if (BLI_is_dir(env)) {
     BLI_strncpy(path, env, FILE_MAX);
-#ifdef PATH_DEBUG
-    printf("\t%s env %s found: %s\n", __func__, envvar, env);
-#endif
+    CLOG_INFO(&LOG, 1, "\tenv %s found: %s", envvar, env);
     return true;
   }
   else {
     path[0] = '\0';
-#ifdef PATH_DEBUG
-    printf("\t%s env %s missing: %s\n", __func__, envvar, env);
-#endif
+    CLOG_INFO(&LOG, 1, "\tenv %s missing: %s", envvar, env);
     return false;
   }
 }
@@ -208,10 +198,6 @@ static bool get_path_local(char *targetpath,
 {
   char relfolder[FILE_MAX];
 
-#ifdef PATH_DEBUG
-  printf("%s...\n", __func__);
-#endif
-
   if (folder_name) {
     if (subfolder_name) {
       BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name);
@@ -340,9 +326,7 @@ static bool get_path_user(char *targetpath,
     return false;
   }
 
-#ifdef PATH_DEBUG
-  printf("%s: %s\n", __func__, user_path);
-#endif
+  CLOG_INFO(&LOG, 4, "user_path: %s", user_path);
 
   if (subfolder_name) {
     return test_path(targetpath, targetpath_len, user_path, folder_name, subfolder_name);
@@ -393,9 +377,7 @@ static bool get_path_system(char *targetpath,
     return false;
   }
 
-#ifdef PATH_DEBUG
-  printf("%s: %s\n", __func__, system_path);
-#endif
+  CLOG_INFO(&LOG, 3, "%s", system_path);
 
   if (subfolder_name) {
     /* try $BLENDERPATH/folder_name/subfolder_name */
@@ -630,10 +612,6 @@ const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, con
   return path;
 }
 
-#ifdef PATH_DEBUG
-#  undef PATH_DEBUG
-#endif
-
 /* -------------------------------------------------------------------- */
 /* Preset paths */
 
@@ -705,11 +683,9 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name)
     /* Remove "/./" and "/../" so string comparisons can be used on the path. */
     BLI_path_normalize(NULL, fullname);
 
-#if defined(DEBUG)
     if (!STREQ(name, fullname)) {
       CLOG_INFO(&LOG, 2, "guessing '%s' == '%s'", name, fullname);
     }
-#endif
   }
 }



More information about the Bf-blender-cvs mailing list