Commit: 495ecd3d4835b8f009bf6a927e4a03186e147834
Author: Mateusz Grzeliński
Date: Wed Aug 5 10:36:12 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB495ecd3d4835b8f009bf6a927e4a03186e147834
Feature: always log error and warnings
===================================================================
M intern/clog/CLG_log.h
M intern/clog/clog.c
M release/scripts/startup/bl_ui/space_userpref.py
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h
index e79a6fdbb01..b8cfe2e6e53 100644
--- a/intern/clog/CLG_log.h
+++ b/intern/clog/CLG_log.h
@@ -182,6 +182,8 @@ char *CLG_file_output_path_get(void);
void CLG_file_output_path_set(const char *value);
bool CLG_output_use_basename_get(void);
void CLG_output_use_basename_set(int value);
+bool CLG_always_show_warnings_get(void);
+void CLG_always_show_warnings_set(bool value);
bool CLG_output_use_timestamp_get(void);
void CLG_output_use_timestamp_set(int value);
void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle));
@@ -216,7 +218,9 @@ void CLG_logref_init(CLG_LogRef *clg_ref);
((clg_ref)->type ? (clg_ref)->type : (CLG_logref_init(clg_ref),
(clg_ref)->type))
#define CLOG_CHECK_IN_USE(clg_ref) \
- ((void)CLOG_ENSURE(clg_ref), ((clg_ref)->force_enable ||
(clg_ref)->type->flag & CLG_FLAG_USE))
+ ((void)CLOG_ENSURE(clg_ref), \
+ ((clg_ref)->force_enable || CLG_always_show_warnings_get() || \
+ (clg_ref)->type->flag & CLG_FLAG_USE))
#ifdef DEBUG
/** same as CLOG_CHECK_IN_USE, but will be automatically disable in release
build */
@@ -241,7 +245,11 @@ void CLG_logref_init(CLG_LogRef *clg_ref);
#define CLOG_AT_SEVERITY(clg_ref, severity, log_level, ...) \
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
- if ((clg_ref)->force_enable) { \
+ if (CLG_always_show_warnings_get() && severity >= CLG_SEVERITY_WARN) { \
+ CLG_logf( \
+ _lg_ty, severity, log_level, __FILE__ ":" STRINGIFY(__LINE__),
__func__, __VA_ARGS__); \
+ } \
+ else if ((clg_ref)->force_enable) { \
CLG_logf( \
_lg_ty, severity, log_level, __FILE__ ":" STRINGIFY(__LINE__),
__func__, __VA_ARGS__); \
} \
@@ -268,7 +276,10 @@ void CLG_logref_init(CLG_LogRef *clg_ref);
#define CLOG_STR_AT_SEVERITY(clg_ref, severity, log_level, str) \
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
- if ((clg_ref)->force_enable) { \
+ if (CLG_always_show_warnings_get() && severity >= CLG_SEVERITY_WARN) { \
+ CLG_log_str(_lg_ty, severity, log_level, __FILE__ ":"
STRINGIFY(__LINE__), __func__, str); \
+ } \
+ else if ((clg_ref)->force_enable) { \
CLG_log_str(_lg_ty, severity, log_level, __FILE__ ":"
STRINGIFY(__LINE__), __func__, str); \
} \
else if ((_lg_ty->flag & CLG_FLAG_USE) && severity >=
_lg_ty->severity_level) { \
@@ -290,7 +301,12 @@ void CLG_logref_init(CLG_LogRef *clg_ref);
#define CLOG_STR_AT_SEVERITY_N(clg_ref, severity, log_level, str) \
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
- if ((clg_ref)->force_enable) { \
+ if (CLG_always_show_warnings_get() && severity >= CLG_SEVERITY_WARN) { \
+ const char *_str = str; \
+ CLG_log_str(_lg_ty, severity, log_level, __FILE__ ":"
STRINGIFY(__LINE__), __func__, _str); \
+ MEM_freeN((void *)_str); \
+ } \
+ else if ((clg_ref)->force_enable) { \
const char *_str = str; \
CLG_log_str(_lg_ty, severity, log_level, __FILE__ ":"
STRINGIFY(__LINE__), __func__, _str); \
MEM_freeN((void *)_str); \
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index 157b6119dda..8937d533a0f 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -107,6 +107,7 @@ typedef struct CLogContext {
} callbacks;
bool use_stdout;
+ bool always_show_warnings;
/** used only is use_stdout is false */
char output_file_path[256];
} CLogContext;
@@ -692,6 +693,17 @@ static void CLG_ctx_output_use_basename_set(CLogContext
*ctx, int value)
ctx->use_basename = (bool)value;
}
+/** always show Fatals, Errors and Warnings, regardless if log is in use */
+static bool CLG_ctx_always_show_warnings_get(CLogContext *ctx)
+{
+ return ctx->always_show_warnings;
+}
+
+static void CLG_ctx_always_show_warnings_set(CLogContext *ctx, bool value)
+{
+ ctx->always_show_warnings = value;
+}
+
static bool CLG_ctx_output_use_timestamp_get(CLogContext *ctx)
{
return ctx->use_timestamp;
@@ -835,6 +847,7 @@ static CLogContext *CLG_ctx_init(void)
ctx->default_type.severity_level = CLG_SEVERITY_WARN;
ctx->default_type.level = 0;
ctx->use_stdout = true;
+ ctx->always_show_warnings = true;
/* enable all loggers by default */
CLG_ctx_type_filter_include(ctx, "*", strlen("*"));
@@ -926,6 +939,16 @@ void CLG_output_use_basename_set(int value)
CLG_ctx_output_use_basename_set(g_ctx, value);
}
+bool CLG_always_show_warnings_get()
+{
+ return CLG_ctx_always_show_warnings_get(g_ctx);
+}
+
+void CLG_always_show_warnings_set(bool value)
+{
+ CLG_ctx_always_show_warnings_set(g_ctx, value);
+}
+
bool CLG_output_use_timestamp_get()
{
return CLG_ctx_output_use_timestamp_get(g_ctx);
diff --git a/release/scripts/startup/bl_ui/space_userpref.py
b/release/scripts/startup/bl_ui/space_userpref.py
index d2ae3144fe3..4aee07592e8 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -659,6 +659,7 @@ class USERPREF_PT_system_logging(SystemPanel,
CenterAlignMixIn, Panel):
col.active = system.log_severity in {'LOG_VERBOSE', 'LOG_DEBUG'}
col.prop(system, "log_level")
+ layout.prop(system, "log_always_show_warnings")
layout.prop(system, "log_use_basename")
layout.prop(system, "log_use_timestamp")
diff --git a/source/blender/makesrna/intern/rna_userdef.c
b/source/blender/makesrna/intern/rna_userdef.c
index ae8ce31625d..3618327275e 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -1150,6 +1150,15 @@ static void rna_clog_log_use_basename_set(PointerRNA
*UNUSED(ptr), int value)
CLG_output_use_basename_set(value);
}
+static bool rna_clog_log_always_show_warnings_get(PointerRNA *UNUSED(ptr))
+{
+ return CLG_always_show_warnings_get();
+}
+
+static void rna_clog_log_always_show_warnings_set(PointerRNA *UNUSED(ptr), int
value)
+{
+ CLG_always_show_warnings_set(value);
+}
static bool rna_clog_log_use_timestamp_get(PointerRNA *UNUSED(ptr))
{
return CLG_output_use_timestamp_get();
@@ -5812,6 +5821,14 @@ static void rna_def_userdef_system(BlenderRNA *brna)
prop, "rna_clog_log_use_basename_get", "rna_clog_log_use_basename_set");
RNA_def_property_ui_text(prop, "Use Basename", "Show only filename instead
of full filepath");
+ prop = RNA_def_property(srna, "log_always_show_warnings", PROP_BOOLEAN,
PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_clog_log_always_show_warnings_get",
"rna_clog_log_always_show_warnings_set");
+ RNA_def_property_ui_text(
+ prop,
+ "Always Show Errors and Warnings",
+ "Show messages with severity Fatal, Error and Warning regardless if log
is enabled");
+
prop = RNA_def_property(srna, "log_use_timestamp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(
prop, "rna_clog_log_use_timestamp_get",
"rna_clog_log_use_timestamp_set");
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs