Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-03-31 13:52:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-03-31 13:52:47 +0300
commitac4513a5b84017e5e95fc4b84e3e8444fd2c8494 (patch)
treedd1f668cedbffba0ae019446fffe4239a4df13cf /intern/clog/clog.c
parent5f59c22bf1ab5387f23fc9f4b5cf53b85f2582b8 (diff)
Logging: add ability to exclude categories.
Diffstat (limited to 'intern/clog/clog.c')
-rw-r--r--intern/clog/clog.c69
1 files changed, 47 insertions, 22 deletions
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index 486b596e0cc..f82e6b3b4a1 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -56,7 +56,8 @@ typedef struct CLG_IDFilter {
typedef struct CLogContext {
/** Single linked list of types. */
CLG_LogType *types;
- CLG_IDFilter *filters;
+ /* exclude, include filters. */
+ CLG_IDFilter *filters[2];
bool use_color;
/** Borrowed, not owned. */
@@ -263,21 +264,24 @@ static enum eCLogColor clg_severity_to_color(enum CLG_Severity severity)
*/
static bool clg_ctx_filter_check(CLogContext *ctx, const char *identifier)
{
- const CLG_IDFilter *flt = ctx->filters;
const int identifier_len = strlen(identifier);
- while (flt != NULL) {
- const int len = strlen(flt->match);
- if (STREQ(flt->match, "*") ||
- ((len == identifier_len) && (STREQ(identifier, flt->match))))
- {
- return true;
- }
- if ((len >= 2) && (STREQLEN(".*", &flt->match[len - 2], 2))) {
- if (((identifier_len == len - 2) && STREQLEN(identifier, flt->match, len - 2)) ||
- ((identifier_len >= len - 1) && STREQLEN(identifier, flt->match, len - 1)))
+ for (uint i = 0; i < 2; i++) {
+ const CLG_IDFilter *flt = ctx->filters[i];
+ while (flt != NULL) {
+ const int len = strlen(flt->match);
+ if (STREQ(flt->match, "*") ||
+ ((len == identifier_len) && (STREQ(identifier, flt->match))))
{
- return true;
+ return (bool)i;
+ }
+ if ((len >= 2) && (STREQLEN(".*", &flt->match[len - 2], 2))) {
+ if (((identifier_len == len - 2) && STREQLEN(identifier, flt->match, len - 2)) ||
+ ((identifier_len >= len - 1) && STREQLEN(identifier, flt->match, len - 1)))
+ {
+ return (bool)i;
+ }
}
+ flt = flt->next;
}
}
return false;
@@ -438,15 +442,28 @@ static void CLG_ctx_fatal_fn_set(CLogContext *ctx, void (*fatal_fn)(void *file_h
ctx->callbacks.fatal_fn = fatal_fn;
}
-static void CLG_ctx_type_filter(CLogContext *ctx, const char *type_match, int type_match_len)
+static void clg_ctx_type_filter_append(CLG_IDFilter **flt_list, const char *type_match, int type_match_len)
{
+ if (type_match_len == 0) {
+ return;
+ }
CLG_IDFilter *flt = MEM_callocN(sizeof(*flt) + (type_match_len + 1), __func__);
- flt->next = ctx->filters;
- ctx->filters = flt;
+ flt->next = *flt_list;
+ *flt_list = flt;
memcpy(flt->match, type_match, type_match_len);
/* no need to null terminate since we calloc'd */
}
+static void CLG_ctx_type_filter_exclude(CLogContext *ctx, const char *type_match, int type_match_len)
+{
+ clg_ctx_type_filter_append(&ctx->filters[0], type_match, type_match_len);
+}
+
+static void CLG_ctx_type_filter_include(CLogContext *ctx, const char *type_match, int type_match_len)
+{
+ clg_ctx_type_filter_append(&ctx->filters[1], type_match, type_match_len);
+}
+
static CLogContext *CLG_ctx_init(void)
{
CLogContext *ctx = MEM_callocN(sizeof(*ctx), __func__);
@@ -464,10 +481,13 @@ static void CLG_ctx_free(CLogContext *ctx)
ctx->types = item->next;
MEM_freeN(item);
}
- while (ctx->filters != NULL) {
- CLG_IDFilter *item = ctx->filters;
- ctx->filters = item->next;
- MEM_freeN(item);
+
+ for (uint i = 0; i < 2; i++) {
+ while (ctx->filters[i] != NULL) {
+ CLG_IDFilter *item = ctx->filters[i];
+ ctx->filters[i] = item->next;
+ MEM_freeN(item);
+ }
}
MEM_freeN(ctx);
}
@@ -505,9 +525,14 @@ void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle))
CLG_ctx_fatal_fn_set(g_ctx, fatal_fn);
}
-void CLG_type_filter(const char *type_match, int type_match_len)
+void CLG_type_filter_exclude(const char *type_match, int type_match_len)
+{
+ CLG_ctx_type_filter_exclude(g_ctx, type_match, type_match_len);
+}
+
+void CLG_type_filter_include(const char *type_match, int type_match_len)
{
- CLG_ctx_type_filter(g_ctx, type_match, type_match_len);
+ CLG_ctx_type_filter_include(g_ctx, type_match, type_match_len);
}
/** \} */