[Bf-blender-cvs] [9e396a3555f] soc-2020-info-editor: Command line arguments: separate log level into severity and verbosity
Mateusz GrzeliÅski
noreply at git.blender.org
Wed Jul 8 15:14:48 CEST 2020
Commit: 9e396a3555fd29b3a44f498ac8e0173a9d74625a
Author: Mateusz Grzeliński
Date: Wed Jul 8 13:46:42 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB9e396a3555fd29b3a44f498ac8e0173a9d74625a
Command line arguments: separate log level into severity and verbosity
===================================================================
M intern/clog/CLG_log.h
M intern/clog/clog.c
M source/blender/blenkernel/BKE_global.h
M source/blender/editors/space_info/info_report.c
M source/creator/creator_args.c
===================================================================
diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h
index cb4eec9f2d1..618e7524b3d 100644
--- a/intern/clog/CLG_log.h
+++ b/intern/clog/CLG_log.h
@@ -115,8 +115,8 @@ typedef struct CLG_LogType {
char identifier[64];
/** FILE output. */
struct CLogContext *ctx;
- /** Control behavior. */
- int level;
+ unsigned short verbosity_level;
+ unsigned short severity_level;
enum CLG_LogFlag flag;
} CLG_LogType;
@@ -131,6 +131,7 @@ typedef struct CLG_LogRecord {
/** track where does the log comes from */
CLG_LogType *type;
enum CLG_Severity severity;
+ unsigned short verbosity;
uint64_t timestamp;
const char *file_line;
const char *function;
@@ -144,19 +145,22 @@ typedef struct LogRecordList {
void CLG_log_str(CLG_LogType *lg,
enum CLG_Severity severity,
+ unsigned short verbosity,
const char *file_line,
const char *fn,
- const char *message) _CLOG_ATTR_NONNULL(1, 3, 4, 5);
+ const char *message) _CLOG_ATTR_NONNULL(1, 4, 5, 6);
void CLG_logf(CLG_LogType *lg,
enum CLG_Severity severity,
+ unsigned short verbosity,
const char *file_line,
const char *fn,
const char *format,
- ...) _CLOG_ATTR_NONNULL(1, 3, 4, 5) _CLOG_ATTR_PRINTF_FORMAT(5, 6);
+ ...) _CLOG_ATTR_NONNULL(1, 4, 5, 6) _CLOG_ATTR_PRINTF_FORMAT(6, 7);
const char *clg_severity_as_text(enum CLG_Severity severity);
CLG_LogRecord *clog_log_record_init(CLG_LogType *type,
enum CLG_Severity severity,
+ unsigned short verbosity,
const char *file_line,
const char *function,
char *message);
@@ -175,7 +179,8 @@ void CLG_backtrace_fn_set(void (*fatal_fn)(void *file_handle));
void CLG_type_filter_include(const char *type_filter, int type_filter_len);
void CLG_type_filter_exclude(const char *type_filter, int type_filter_len);
-void CLG_level_set(int level);
+void CLG_severity_level_set(enum CLG_Severity level);
+void CLG_verbosity_level_set(unsigned short level);
struct LogRecordList *CLG_log_record_get(void);
void CLG_logref_init(CLG_LogRef *clg_ref);
@@ -194,14 +199,19 @@ void CLG_logref_init(CLG_LogRef *clg_ref);
#define CLOG_CHECK_VERBOSITY(clg_ref, verbose_level, ...) \
((void)CLOG_ENSURE(clg_ref), \
- ((clg_ref)->type->flag & CLG_FLAG_USE) && ((clg_ref)->type->level >= verbose_level))
+ ((clg_ref)->type->flag & CLG_FLAG_USE) && ((clg_ref)->type->verbosity_level >= verbose_level))
#define CLOG_AT_SEVERITY(clg_ref, severity, verbose_level, ...) \
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
- if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
+ if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->verbosity_level >= verbose_level)) || \
(severity >= CLG_SEVERITY_WARN)) { \
- CLG_logf(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
+ CLG_logf(_lg_ty, \
+ severity, \
+ verbose_level, \
+ __FILE__ ":" STRINGIFY(__LINE__), \
+ __func__, \
+ __VA_ARGS__); \
} \
} \
((void)0)
@@ -209,9 +219,10 @@ void CLG_logref_init(CLG_LogRef *clg_ref);
#define CLOG_STR_AT_SEVERITY(clg_ref, severity, verbose_level, str) \
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
- if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
+ if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->verbosity_level >= verbose_level)) || \
(severity >= CLG_SEVERITY_WARN)) { \
- CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, str); \
+ CLG_log_str( \
+ _lg_ty, severity, verbose_level, __FILE__ ":" STRINGIFY(__LINE__), __func__, str); \
} \
} \
((void)0)
@@ -219,10 +230,11 @@ void CLG_logref_init(CLG_LogRef *clg_ref);
#define CLOG_STR_AT_SEVERITY_N(clg_ref, severity, verbose_level, str) \
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
- if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
+ if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->verbosity_level >= verbose_level)) || \
(severity >= CLG_SEVERITY_WARN)) { \
const char *_str = str; \
- CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, _str); \
+ CLG_log_str( \
+ _lg_ty, severity, verbose_level, __FILE__ ":" STRINGIFY(__LINE__), __func__, _str); \
MEM_freeN((void *)_str); \
} \
} \
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index 78393da5b3a..fd98f104e79 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -96,7 +96,8 @@ typedef struct CLogContext {
/** For new types. */
struct {
- int level;
+ short verbosity_level;
+ short severity_level;
} default_type;
struct {
@@ -345,7 +346,8 @@ static CLG_LogType *clg_ctx_type_register(CLogContext *ctx, const char *identifi
ctx->types = ty;
strncpy(ty->identifier, identifier, sizeof(ty->identifier) - 1);
ty->ctx = ctx;
- ty->level = ctx->default_type.level;
+ ty->verbosity_level = ctx->default_type.verbosity_level;
+ ty->severity_level = ctx->default_type.severity_level;
if (clg_ctx_filter_check(ctx, ty->identifier)) {
ty->flag |= CLG_FLAG_USE;
@@ -386,6 +388,7 @@ static uint64_t clg_timestamp_ticks_get(void)
CLG_LogRecord *clog_log_record_init(CLG_LogType *type,
enum CLG_Severity severity,
+ unsigned short verbosity,
const char *file_line,
const char *function,
char *message)
@@ -393,6 +396,8 @@ CLG_LogRecord *clog_log_record_init(CLG_LogType *type,
CLG_LogRecord *log_record = MEM_callocN(sizeof(*log_record), "ClogRecord");
log_record->type = type;
log_record->severity = severity;
+ log_record->severity = severity;
+ log_record->verbosity = verbosity;
log_record->timestamp = clg_timestamp_ticks_get() - type->ctx->timestamp_tick_start;
log_record->file_line = file_line;
log_record->function = function;
@@ -471,6 +476,7 @@ static void write_file_line_fn(CLogStringBuf *cstr,
void CLG_log_str(CLG_LogType *lg,
enum CLG_Severity severity,
+ unsigned short verbosity,
const char *file_line,
const char *fn,
const char *message)
@@ -484,6 +490,11 @@ void CLG_log_str(CLG_LogType *lg,
}
write_severity(&cstr, severity, lg->ctx->use_color);
+ if (severity == CLG_SEVERITY_VERBOSE) {
+ char verbosity_str[8];
+ sprintf(verbosity_str, ":%u", verbosity);
+ clg_str_append(&cstr, verbosity_str);
+ }
write_type(&cstr, lg);
{
@@ -530,6 +541,7 @@ static void CLG_report_append(LogRecordList *listbase, CLG_LogRecord *link)
/* TODO (grzelins) there is problem with handling big messages (example is report from duplicating object) */
void CLG_logf(CLG_LogType *lg,
enum CLG_Severity severity,
+ unsigned short verbosity,
const char *file_line,
const char *fn,
const char *fmt,
@@ -544,6 +556,11 @@ void CLG_logf(CLG_LogType *lg,
}
write_severity(&cstr, severity, lg->ctx->use_color);
+ if (severity == CLG_SEVERITY_VERBOSE) {
+ char verbosity_str[8];
+ sprintf(verbosity_str, ":%u", verbosity);
+ clg_str_append(&cstr, verbosity_str);
+ }
write_type(&cstr, lg);
write_file_line_fn(&cstr, file_line, fn, lg->ctx->use_basename);
@@ -560,7 +577,8 @@ void CLG_logf(CLG_LogType *lg,
char *message = MEM_callocN(mem_size, "LogMessage");
strcpy(message, cstr.data + cstr_size_before_va);
- CLG_LogRecord *log_record = clog_log_record_init(lg, severity, file_line, fn, message);
+ CLG_LogRecord *log_record = clog_log_record_init(
+ lg, severity, verbosity, file_line, fn, message);
CLG_report_append(&(lg->ctx->log_records), log_record);
clg_str_append(&cstr, "\n");
@@ -647,11 +665,19 @@ static void CLG_ctx_type_filter_include(CLogContext *ctx,
clg_ctx_type_filter_append(&ctx->filters[1], type_match, type_match_len);
}
-static void CLG_ctx_level_set(CLogContext *ctx, int level)
+static void CLG_ctx_severity_level_set(CLogContext *ctx, enum CLG_Severity level)
{
- ctx->default_type.level = level;
+ ctx->default_type.severity_level = level;
for (CLG_LogType *ty = ctx->types; ty; ty = ty->next) {
- ty->level = level;
+ ty->severity_level = level;
+ }
+}
+
+static void CLG_ctx_verbosity_level_set(CLogContext *ctx, unsigned short level)
+{
+ ctx->default_type.verbosity_level = level;
+ for (CLG_LogType *ty = ctx->types; ty; ty = ty->next) {
+ ty->verbosity_level = level;
}
}
@@ -667,7 +693,8 @@ static CLogContext *CLG_ctx_init(void)
pthread_mutex_init(&ctx->types_lock, NULL);
#endif
ctx->use_color = true;
- ctx->default_type.level = 1;
+ ctx->default_type.severity_level = CLG_SEVERITY_INFO;
+ ctx->default_type.verbosity_level = 0;
CLG_ctx_output_set(ctx, stdout);
return ctx;
@@ -681,8 +708,8 @@ static void CLG_ctx_free(CLogContext *ctx)
clog_log_record_free(log);
log = log_next;
}
- ctx->log_records.first= NULL;
- ctx->log_records.last= NULL;
+ ctx->log_records.first = NULL;
+ ctx->log_records.last = NULL;
while (ctx->types != NULL) {
CLG_LogType *item = ctx->types;
@@ -761,9 +788,14 @@ void CLG_type_filter_include(const char *type_match, int type_match_len)
CLG_ctx_type_filter_include(g_ctx, type_match, type_match_len);
}
-void CLG_level_set(int level)
+void CLG_severity_level_set(enum CLG_Severity level)
+{
+ CLG_ctx_severity_level_set(g_ctx, level);
+}
+
+void CLG_verbosity_level_set(unsigned short level)
{
- CLG_ctx_level_set(g_ctx, level);
+ CLG_ctx_verbosity_level_set(g_ctx, level);
}
LogRecordList *CLG_log_record_get()
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenker
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list