diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-02 12:05:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-02 14:13:57 +0300 |
commit | 017c731cf38b01e6ffd2d57932c3a268678e51eb (patch) | |
tree | 0536e9d5f911c23828de6179d1f3bf0d5cd76789 /source/blender/python/intern/bpy_rna.c | |
parent | 21fcc723e98b81f77c46edb18c5092d8878c6ccb (diff) |
Logging: use for Python API
Adds categories "bpy.context" & "bpy.rna"
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 87260d6e786..27eb1431295 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -45,6 +45,7 @@ #include "BLI_utildefines.h" #include "BPY_extern.h" +#include "BPY_extern_clog.h" #include "bpy_rna.h" #include "bpy_rna_anim.h" @@ -61,6 +62,8 @@ #include "RNA_define.h" /* RNA_def_property_free_identifier */ #include "RNA_access.h" +#include "CLG_log.h" + #include "MEM_guardedalloc.h" #include "BKE_main.h" @@ -1418,10 +1421,11 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); /* prefer not fail silently in case of api errors, maybe disable it later */ - printf("RNA Warning: Current value \"%d\" " - "matches no enum in '%s', '%s', '%s'\n", - val, RNA_struct_identifier(ptr->type), - ptr_name, RNA_property_identifier(prop)); + CLOG_WARN(BPY_LOG_RNA, + "Current value \"%d\" " + "matches no enum in '%s', '%s', '%s'\n", + val, RNA_struct_identifier(ptr->type), + ptr_name, RNA_property_identifier(prop)); #if 0 /* gives python decoding errors while generating docs :( */ char error_str[256]; @@ -6596,7 +6600,7 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) if (bpy_types == NULL) { PyErr_Print(); PyErr_Clear(); - fprintf(stderr, "%s: failed to find 'bpy_types' module\n", __func__); + CLOG_ERROR(BPY_LOG_RNA, "failed to find 'bpy_types' module\n"); return NULL; } bpy_types_dict = PyModule_GetDict(bpy_types); /* borrow */ @@ -6614,20 +6618,22 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict, bpy_intern_str___slots__); if (tp_slots == NULL) { - fprintf(stderr, "%s: expected class '%s' to have __slots__ defined\n\nSee bpy_types.py\n", __func__, idname); + CLOG_ERROR(BPY_LOG_RNA, "expected class '%s' to have __slots__ defined, see bpy_types.py\n", idname); newclass = NULL; } else if (PyTuple_GET_SIZE(tp_bases)) { PyObject *base = PyTuple_GET_ITEM(tp_bases, 0); if (base_compare != base) { - fprintf(stderr, "%s: incorrect subclassing of SRNA '%s'\nSee bpy_types.py\n", __func__, idname); - PyC_ObSpit("Expected! ", base_compare); + char pyob_info[256]; + PyC_ObSpitStr(pyob_info, sizeof(pyob_info), base_compare); + CLOG_ERROR(BPY_LOG_RNA, + "incorrect subclassing of SRNA '%s', expected '%s', see bpy_types.py\n", + idname, pyob_info); newclass = NULL; } else { - if (G.debug & G_DEBUG_PYTHON) - fprintf(stderr, "SRNA Subclassed: '%s'\n", idname); + CLOG_INFO(BPY_LOG_RNA, 2, "SRNA sub-classed: '%s'\n", idname); } } } @@ -6725,7 +6731,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) } else { /* this should not happen */ - printf("%s: error registering '%s'\n", __func__, idname); + CLOG_ERROR(BPY_LOG_RNA, "error registering '%s'", idname); PyErr_Print(); PyErr_Clear(); } @@ -6791,7 +6797,7 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) Py_DECREF(tp); /* srna owns, cant hold a ref */ } else { - fprintf(stderr, "%s: could not make type\n", __func__); + CLOG_WARN(BPY_LOG_RNA, "could not make type '%s'", RNA_struct_identifier(ptr->type)); pyrna = (BPy_StructRNA *) PyObject_GC_New(BPy_StructRNA, &pyrna_struct_Type); #ifdef USE_WEAKREFS pyrna->in_weakreflist = NULL; @@ -7597,8 +7603,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param py_class = RNA_struct_py_type_get(ptr->type); /* rare case. can happen when registering subclasses */ if (py_class == NULL) { - fprintf(stderr, "%s: unable to get python class for rna struct '%.200s'\n", - __func__, RNA_struct_identifier(ptr->type)); + CLOG_WARN(BPY_LOG_RNA, "unable to get Python class for rna struct '%.200s'\n", RNA_struct_identifier(ptr->type)); return -1; } |