Logging: use for Python API
[blender.git] / source / blender / python / intern / bpy_interface.c
index ae8e35ae3fce2c6508815bee30c988ae511a95fe..99f87c61c5a2d7ef8b6394bf1d440702301058dc 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "CLG_log.h"
+
 #include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
@@ -75,6 +77,9 @@
 #include "../bmesh/bmesh_py_api.h"
 #include "../mathutils/mathutils.h"
 
+/* Logging types to use anywhere in the Python modules. */
+CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_CONTEXT, "bpy.context");
+CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
 
 /* for internal use, when starting and ending python scripts */
 
@@ -800,8 +805,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
                                        CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data);
                                }
                                else {
-                                       printf("PyContext: '%s' list item not a valid type in sequece type '%s'\n",
-                                              member, Py_TYPE(item)->tp_name);
+                                       CLOG_INFO(BPY_LOG_CONTEXT, 1,
+                                                 "'%s' list item not a valid type in sequence type '%s'",
+                                                 member, Py_TYPE(item)->tp_name);
                                }
 
                        }
@@ -813,16 +819,14 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
 
        if (done == false) {
                if (item) {
-                       printf("PyContext '%s' not a valid type\n", member);
+                       CLOG_INFO(BPY_LOG_CONTEXT, 1, "'%s' not a valid type", member);
                }
                else {
-                       printf("PyContext '%s' not found\n", member);
+                       CLOG_INFO(BPY_LOG_CONTEXT, 1, "'%s' not found\n", member);
                }
        }
        else {
-               if (G.debug & G_DEBUG_PYTHON) {
-                       printf("PyContext '%s' found\n", member);
-               }
+               CLOG_INFO(BPY_LOG_CONTEXT, 2, "'%s' found", member);
        }
 
        if (use_gil)