[Bf-blender-cvs] [abf67a9278d] soc-2020-info-editor: Convert printf to clog
Mateusz GrzeliÅski
noreply at git.blender.org
Tue Aug 4 14:14:08 CEST 2020
Commit: abf67a9278dce2f777e3ce27e4a784027fe62e96
Author: Mateusz Grzeliński
Date: Mon Aug 3 17:10:57 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rBabf67a9278dce2f777e3ce27e4a784027fe62e96
Convert printf to clog
===================================================================
M source/blender/blenloader/intern/undofile.c
M source/blender/bmesh/intern/bmesh_operators.c
M source/blender/bmesh/intern/bmesh_polygon_edgenet.c
M source/blender/bmesh/tools/bmesh_beautify.c
===================================================================
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index 62ffbcc874b..7fea06ed479 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -36,6 +36,7 @@
# include <io.h>
#endif
+#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
@@ -52,6 +53,8 @@
/* keep last */
#include "BLI_strict_flags.h"
+static CLG_LogRef LOG = {"blenloader.undofile"};
+
/* **************** support for memory-write, for undo buffers *************** */
/* not memfile itself */
@@ -244,10 +247,10 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename)
file = BLI_open(filename, oflags, 0666);
if (file == -1) {
- fprintf(stderr,
- "Unable to save '%s': %s\n",
- filename,
- errno ? strerror(errno) : "Unknown error opening file");
+ CLOG_ERROR(&LOG,
+ "Unable to save '%s': %s",
+ filename,
+ errno ? strerror(errno) : "Unknown error opening file");
return false;
}
@@ -260,10 +263,10 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename)
close(file);
if (chunk) {
- fprintf(stderr,
- "Unable to save '%s': %s\n",
- filename,
- errno ? strerror(errno) : "Unknown error writing file");
+ CLOG_ERROR(&LOG,
+ "Unable to save '%s': %s",
+ filename,
+ errno ? strerror(errno) : "Unknown error writing file");
return false;
}
return true;
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 19e42b33c80..59c3ee93bf4 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -20,6 +20,7 @@
* BMesh operator access.
*/
+#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
@@ -34,6 +35,8 @@
#include "bmesh.h"
#include "intern/bmesh_private.h"
+static CLG_LogRef LOG = {"bmesh.bmesh_operators"};
+
/* forward declarations */
static void bmo_flag_layer_alloc(BMesh *bm);
static void bmo_flag_layer_free(BMesh *bm);
@@ -427,7 +430,7 @@ void BMO_slot_mat_set(BMOperator *op,
copy_m4_m3(slot->data.p, (float(*)[3])mat);
}
else {
- fprintf(stderr, "%s: invalid size argument %d (bmesh internal error)\n", __func__, size);
+ CLOG_ERROR(&LOG, "%s: invalid size argument %d (bmesh internal error)\n", __func__, size);
zero_m4(slot->data.p);
}
@@ -1646,7 +1649,7 @@ static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], cons
{
int i = bmo_name_to_slotcode(slot_args, identifier);
if (i < 0) {
- fprintf(stderr,
+ CLOG_ERROR(&LOG,
"%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n",
__func__,
identifier);
@@ -1672,7 +1675,7 @@ static int BMO_opcode_from_opname_check(const char *opname)
{
int i = BMO_opcode_from_opname(opname);
if (i == -1) {
- fprintf(stderr,
+ CLOG_ERROR(&LOG,
"%s: could not find bmesh slot for name %s! (bmesh internal error)\n",
__func__,
opname);
@@ -1953,7 +1956,7 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
state = true;
break;
default:
- fprintf(stderr,
+ CLOG_ERROR(&LOG,
"%s: unrecognized bmop format char: '%c', %d in '%s'\n",
__func__,
*fmt,
@@ -1970,21 +1973,21 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
error:
/* non urgent todo - explain exactly what is failing */
- fprintf(stderr, "%s: error parsing formatting string\n", __func__);
+ CLOG_ERROR(&LOG, "%s: error parsing formatting string\n", __func__);
- fprintf(stderr, "string: '%s', position %d\n", _fmt, (int)(fmt - ofmt));
- fprintf(stderr, " ");
+ CLOG_ERROR(&LOG, "string: '%s', position %d\n", _fmt, (int)(fmt - ofmt));
+ CLOG_ERROR(&LOG, " ");
{
int pos = (int)(fmt - ofmt);
for (i = 0; i < pos; i++) {
- fprintf(stderr, " ");
+ CLOG_ERROR(&LOG, " ");
}
- fprintf(stderr, "^\n");
+ CLOG_ERROR(&LOG, "^\n");
}
- fprintf(stderr, "source code: %s:%d\n", __FILE__, lineno);
+ CLOG_ERROR(&LOG, "source code: %s:%d\n", __FILE__, lineno);
- fprintf(stderr, "reason: %s\n", err_reason);
+ CLOG_ERROR(&LOG, "reason: %s\n", err_reason);
MEM_freeN(ofmt);
@@ -2000,7 +2003,7 @@ bool BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ..
va_start(list, fmt);
if (!BMO_op_vinitf(bm, op, flag, fmt, list)) {
- printf("%s: failed\n", __func__);
+ CLOG_STR_ERROR(&LOG, "Function failed");
va_end(list);
return false;
}
@@ -2016,7 +2019,7 @@ bool BMO_op_callf(BMesh *bm, const int flag, const char *fmt, ...)
va_start(list, fmt);
if (!BMO_op_vinitf(bm, &op, flag, fmt, list)) {
- printf("%s: failed, format is:\n \"%s\"\n", __func__, fmt);
+ CLOG_ERROR(&LOG, "format is:\n \"%s\"", fmt);
va_end(list);
return false;
}
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index 39395cb9222..b60305d028f 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
@@ -20,9 +20,9 @@
* This file contains functions for splitting faces into isolated regions,
* defined by connected edges.
*/
-// #define DEBUG_PRINT
#include "MEM_guardedalloc.h"
+#include <CLG_log.h>
#include "BLI_alloca.h"
#include "BLI_array.h"
@@ -38,6 +38,7 @@
#include "bmesh.h"
#include "intern/bmesh_private.h"
+static CLG_LogRef LOG = {"bmesh.bmesh_polygon_edgenet"};
/* -------------------------------------------------------------------- */
/* Face Split Edge-Net */
@@ -304,9 +305,7 @@ static bool bm_face_split_edgenet_find_loop_walk(BMVert *v_init,
v_dst = BM_edge_other_vert(e_pair[1], v_init);
-#ifdef DEBUG_PRINT
- printf("%s: vert (search) %d\n", __func__, BM_elem_index_get(v_init));
-#endif
+ CLOG_DEBUG(&LOG, 0, "%s: vert (search) %d\n", __func__, BM_elem_index_get(v_init));
/* This loop will keep stepping over the best possible edge,
* in most cases it finds the direct route to close the face.
@@ -344,19 +343,21 @@ static bool bm_face_split_edgenet_find_loop_walk(BMVert *v_init,
v_next = BM_edge_other_vert(e_next, v);
BLI_assert(v->e != e_next);
-#ifdef DEBUG_PRINT
/* indent and print */
- {
+ if (CLOG_CHECK_IN_USE(&LOG)) {
BMVert *_v = v;
+ char indentation[32] = "";
do {
- printf(" ");
+ sprintf(indentation, " ");
} while ((_v = BM_edge_other_vert(_v->e, _v)) != v_init);
- printf("vert %d -> %d (add=%d)\n",
- BM_elem_index_get(v),
- BM_elem_index_get(v_next),
- BM_ELEM_API_FLAG_TEST(v_next, VERT_VISIT) == 0);
+ CLOG_DEBUG(&LOG,
+ 4,
+ "%svert %d -> %d (add=%d)",
+ indentation,
+ BM_elem_index_get(v),
+ BM_elem_index_get(v_next),
+ BM_ELEM_API_FLAG_TEST(v_next, VERT_VISIT) == 0);
}
-#endif
if (!BM_ELEM_API_FLAG_TEST(v_next, VERT_VISIT)) {
eo = STACK_PUSH_RET_PTR(edge_order);
@@ -1042,7 +1043,7 @@ static int bm_face_split_edgenet_find_connection(const struct EdgeGroup_FindConn
(e_hit = test_edges_isect_2d_vert(args, v_origin, v_other)));
if (v_other == NULL) {
- printf("Using fallback\n");
+ CLOG_VERBOSE(&LOG, 0, "Using fallback");
v_other = v_other_fallback;
}
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index c877c534376..d0b174af4d4 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -32,6 +32,7 @@
#include "BLI_heap.h"
#include "BLI_math.h"
#include "BLI_polyfill_2d_beautify.h"
+#include <CLG_log.h>
#include "MEM_guardedalloc.h"
@@ -45,6 +46,8 @@
# include "PIL_time_utildefines.h"
#endif
+static CLG_LogRef LOG = {"bmesh.bmesh_beautify"};
+
/* -------------------------------------------------------------------- */
/* GSet for edge rotation */
@@ -157,7 +160,7 @@ static float bm_edge_calc_rotate_beauty__area(const float v1[3],
cross_tri_v3(no_a, v2, v3, v4);
cross_tri_v3(no_b, v2, v4, v1);
- // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f);
+ CLOG_DEBUG(&LOG, 20, "%p %p %p %p", v1, v2, v3, v4);
BLI_assert((ELEM(v1, v2, v3, v4) == false) && (ELEM(v2, v1, v3, v4) == false) &&
(ELEM(v3, v1, v2, v4) == false) && (ELEM(v4, v1, v2, v3) == false));
@@ -256,7 +259,7 @@ float BM_verts_calc_rotate_beauty(const BMVert *v1,
}
if (UNLIKELY(v1 == v3)) {
- // printf("This should never happen, but does sometimes!\n");
+ CLOG_ERROR(&LOG, "This should never happen, but does sometimes!");
break;
}
@@ -320,7 +323,7 @@ static void bm_edge_update_beauty_cost_single(BMEdge *e,
EdRotState e_state_alt;
erot_state_alternate(e, &e_state_alt);
if (BLI_gset_haskey(e_state_set, (void *)&e_state_alt)) {
- // printf(" skipping, we already have this state\n");
+ CLOG_VERBOSE(&LOG, 0, " skipping, we already have this state");
return;
}
}
@@ -436,7 +439,7 @@ void BM_mesh_beautify_fill(BMesh *bm,
BLI_assert(BLI_gset_haskey(e_state_set, (void *)e_state) == false);
BLI_gset_insert(e_state_set, e_state);
- // printf(" %d -> %d, %d\n", i, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2));
+ CLOG_DEBUG(&LOG, 0, " %d -> %d, %d", i, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2));
/* maintain the index array */
edge_array[i] = e;
More information about the Bf-blender-cvs
mailing list