|
Blender V4.5
|
#include <assert.h>#include <stdarg.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <inttypes.h>#include "MEM_guardedalloc.h"#include "CLG_log.h"Go to the source code of this file.
Classes | |
| struct | CLG_IDFilter |
| struct | CLogContext |
| struct | CLogStringBuf |
Macros | |
| #define | __STDC_FORMAT_MACROS |
| #define | STREQ(a, b) |
| #define | STREQLEN(a, b, n) |
| #define | PATHSEP_CHAR '/' |
Typedefs | |
Internal Types | |
| typedef struct CLG_IDFilter | CLG_IDFilter |
| typedef struct CLogContext | CLogContext |
Functions | |
Context Type Access | |
| static bool | clg_ctx_filter_check (CLogContext *ctx, const char *identifier) |
| static CLG_LogType * | clg_ctx_type_find_by_name (CLogContext *ctx, const char *identifier) |
| static CLG_LogType * | clg_ctx_type_register (CLogContext *ctx, const char *identifier) |
| static void | clg_ctx_error_action (CLogContext *ctx) |
| static void | clg_ctx_fatal_action (CLogContext *ctx) |
| static void | clg_ctx_backtrace (CLogContext *ctx) |
| static uint64_t | clg_timestamp_ticks_get (void) |
Logging API | |
| static void | write_timestamp (CLogStringBuf *cstr, const uint64_t timestamp_tick_start) |
| static void | write_severity (CLogStringBuf *cstr, enum CLG_Severity severity, bool use_color) |
| static void | write_type (CLogStringBuf *cstr, const CLG_LogType *lg) |
| static void | write_file_line_fn (CLogStringBuf *cstr, const char *file_line, const char *fn, const bool use_basename) |
| void | CLG_log_str (const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *message) |
| void | CLG_logf (const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *format,...) |
Logging Context API | |
| static void | CLG_ctx_output_set (CLogContext *ctx, void *file_handle) |
| static void | CLG_ctx_output_use_basename_set (CLogContext *ctx, int value) |
| static void | CLG_ctx_output_use_timestamp_set (CLogContext *ctx, int value) |
| static void | CLT_ctx_error_fn_set (CLogContext *ctx, void(*error_fn)(void *file_handle)) |
| static void | CLG_ctx_fatal_fn_set (CLogContext *ctx, void(*fatal_fn)(void *file_handle)) |
| static void | CLG_ctx_backtrace_fn_set (CLogContext *ctx, void(*backtrace_fn)(void *file_handle)) |
| static void | clg_ctx_type_filter_append (CLG_IDFilter **flt_list, const char *type_match, int type_match_len) |
| static void | CLG_ctx_type_filter_exclude (CLogContext *ctx, const char *type_match, int type_match_len) |
| static void | CLG_ctx_type_filter_include (CLogContext *ctx, const char *type_match, int type_match_len) |
| static void | CLG_ctx_level_set (CLogContext *ctx, int level) |
| static CLogContext * | CLG_ctx_init (void) |
| static void | CLG_ctx_free (CLogContext *ctx) |
Logging Reference API | |
Use to avoid look-ups each time. | |
| void | CLG_logref_init (CLG_LogRef *clg_ref) |
| int | CLG_color_support_get (CLG_LogRef *clg_ref) |
Mini Buffer Functionality | |
Use so we can do a single call to write. | |
| #define | CLOG_BUF_LEN_INIT 512 |
| typedef struct CLogStringBuf | CLogStringBuf |
| static void | clg_str_init (CLogStringBuf *cstr, char *buf_stack, uint buf_stack_len) |
| static void | clg_str_free (CLogStringBuf *cstr) |
| static void | clg_str_reserve (CLogStringBuf *cstr, const uint len) |
| static void | clg_str_append_with_len (CLogStringBuf *cstr, const char *str, const uint len) |
| static void | clg_str_append (CLogStringBuf *cstr, const char *str) |
| static void | clg_str_vappendf (CLogStringBuf *cstr, const char *format, va_list args) |
Internal Utilities | |
| #define | COLOR_LEN (COLOR_RESET + 1) |
| enum | eCLogColor { COLOR_DEFAULT , COLOR_RED , COLOR_GREEN , COLOR_YELLOW , COLOR_RESET } |
| static const char * | clg_color_table [COLOR_LEN] = {NULL} |
| static const char * | clg_severity_str [CLG_SEVERITY_LEN] |
| static void | clg_color_table_init (bool use_color) |
| static const char * | clg_severity_as_text (enum CLG_Severity severity) |
| static enum eCLogColor | clg_severity_to_color (enum CLG_Severity severity) |
Public Logging API | |
Currently uses global context. | |
| static struct CLogContext * | g_ctx = NULL |
| void | CLG_init (void) |
| void | CLG_exit (void) |
| void | CLG_output_set (void *file_handle) |
| void | CLG_output_use_basename_set (int value) |
| void | CLG_output_use_timestamp_set (int value) |
| void | CLG_error_fn_set (void(*error_fn)(void *file_handle)) |
| void | CLG_fatal_fn_set (void(*fatal_fn)(void *file_handle)) |
| void | CLG_backtrace_fn_set (void(*fatal_fn)(void *file_handle)) |
| void | CLG_type_filter_exclude (const char *type_match, int type_match_len) |
| void | CLG_type_filter_include (const char *type_match, int type_match_len) |
| void | CLG_level_set (int level) |
| #define CLOG_BUF_LEN_INIT 512 |
Definition at line 111 of file clog.c.
Referenced by CLG_log_str(), and CLG_logf().
| #define COLOR_LEN (COLOR_RESET + 1) |
Definition at line 224 of file clog.c.
Referenced by clg_color_table_init().
| #define STREQ | ( | a, | |
| b ) |
Definition at line 50 of file clog.c.
Referenced by clg_ctx_filter_check(), and clg_ctx_type_find_by_name().
| #define STREQLEN | ( | a, | |
| b, | |||
| n ) |
Definition at line 51 of file clog.c.
Referenced by clg_ctx_filter_check().
| typedef struct CLG_IDFilter CLG_IDFilter |
| typedef struct CLogContext CLogContext |
| typedef struct CLogStringBuf CLogStringBuf |
| enum eCLogColor |
| void CLG_backtrace_fn_set | ( | void(* | fatal_fn )(void *file_handle) | ) |
Definition at line 734 of file clog.c.
References CLG_ctx_backtrace_fn_set(), CLogContext::fatal_fn, and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), and arg_handle_log_show_backtrace_set().
| int CLG_color_support_get | ( | CLG_LogRef * | clg_ref | ) |
Definition at line 788 of file clog.c.
References CLG_logref_init(), CLG_LogType::ctx, CLG_LogRef::type, and CLogContext::use_color.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), blender::gpu::debug::debug_callback(), and blender::gpu::Shader::print_log().
|
static |
Definition at line 231 of file clog.c.
References clg_color_table, COLOR_DEFAULT, COLOR_GREEN, COLOR_LEN, COLOR_RED, COLOR_RESET, COLOR_YELLOW, and i.
Referenced by CLG_init().
|
static |
Definition at line 376 of file clog.c.
References CLogContext::backtrace_fn, CLogContext::callbacks, and CLogContext::output_file.
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Definition at line 603 of file clog.c.
References CLogContext::backtrace_fn, and CLogContext::callbacks.
Referenced by CLG_backtrace_fn_set().
|
static |
Definition at line 360 of file clog.c.
References CLogContext::callbacks, CLogContext::error_fn, and CLogContext::output_file.
Referenced by CLG_logf().
|
static |
Definition at line 367 of file clog.c.
References CLogContext::callbacks, CLogContext::fatal_fn, and CLogContext::output_file.
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Action on fatal severity.
Definition at line 598 of file clog.c.
References CLogContext::callbacks, and CLogContext::fatal_fn.
Referenced by CLG_fatal_fn_set().
|
static |
Filter the identifier based on very basic globbing.
Definition at line 298 of file clog.c.
References CLogContext::filters, i, len, CLG_IDFilter::match, MEM_callocN(), MEM_freeN(), CLG_IDFilter::next, STREQ, and STREQLEN.
Referenced by clg_ctx_type_register().
|
static |
Definition at line 656 of file clog.c.
References CLogContext::filters, i, MEM_freeN(), CLG_IDFilter::next, CLG_LogRef::next, CLG_LogType::next, CLogContext::refs, CLG_LogRef::type, and CLogContext::types.
Referenced by CLG_exit().
|
static |
Definition at line 644 of file clog.c.
References CLG_ctx_output_set(), CLogContext::default_type, CLogContext::level, and MEM_callocN().
Referenced by CLG_init().
|
static |
Definition at line 636 of file clog.c.
References CLogContext::default_type, CLogContext::level, CLG_LogType::next, and CLogContext::types.
Referenced by CLG_level_set().
|
static |
Definition at line 552 of file clog.c.
References CLogContext::output, CLogContext::output_file, and CLogContext::use_color.
Referenced by CLG_ctx_init(), and CLG_output_set().
|
static |
Definition at line 578 of file clog.c.
References CLogContext::use_basename.
Referenced by CLG_output_use_basename_set().
|
static |
Definition at line 583 of file clog.c.
References clg_timestamp_ticks_get(), CLogContext::timestamp_tick_start, and CLogContext::use_timestamp.
Referenced by CLG_output_use_timestamp_set().
|
static |
Definition at line 608 of file clog.c.
References CLG_IDFilter::match, MEM_callocN(), and CLG_IDFilter::next.
Referenced by CLG_ctx_type_filter_exclude(), and CLG_ctx_type_filter_include().
|
static |
Definition at line 622 of file clog.c.
References clg_ctx_type_filter_append(), and CLogContext::filters.
Referenced by CLG_type_filter_exclude().
|
static |
Definition at line 629 of file clog.c.
References clg_ctx_type_filter_append(), and CLogContext::filters.
Referenced by CLG_type_filter_include().
|
static |
Definition at line 334 of file clog.c.
References CLG_LogType::next, STREQ, and CLogContext::types.
Referenced by clg_ctx_type_register(), and CLG_logref_init().
|
static |
Definition at line 344 of file clog.c.
References assert, clg_ctx_filter_check(), clg_ctx_type_find_by_name(), CLG_FLAG_USE, CLG_LogType::ctx, CLogContext::default_type, CLG_LogType::flag, CLG_LogType::identifier, CLG_LogType::level, CLogContext::level, MEM_callocN(), CLG_LogType::next, and CLogContext::types.
Referenced by CLG_logref_init().
| void CLG_error_fn_set | ( | void(* | error_fn )(void *file_handle) | ) |
Definition at line 724 of file clog.c.
References CLT_ctx_error_fn_set(), CLogContext::error_fn, and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), and arg_handle_debug_exit_on_error().
| void CLG_exit | ( | void | ) |
Definition at line 704 of file clog.c.
References CLG_ctx_free(), and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), main(), blender::bke::image::partial_update::ImagePartialUpdateTest::TearDown(), blender::io::obj::OBJMTLParserTest::TearDownTestCase(), BlendfileLoadingBaseTest::TearDownTestCase(), blender::animrig::nla::tests::NLASlottedActionTest::TearDownTestSuite(), blender::animrig::tests::ActionFCurveMoveTest::TearDownTestSuite(), blender::animrig::tests::ActionFilterTest::TearDownTestSuite(), blender::animrig::tests::ActionIteratorsTest::TearDownTestSuite(), blender::animrig::tests::ActionLayersTest::TearDownTestSuite(), blender::animrig::tests::ActionLegacyTest::TearDownTestSuite(), blender::animrig::tests::ActionQueryTest::TearDownTestSuite(), blender::animrig::tests::AnimationEvaluationTest::TearDownTestSuite(), blender::animrig::tests::KeyframingTest::TearDownTestSuite(), blender::animrig::tests::PoseTest::TearDownTestSuite(), blender::asset_system::tests::AssetLibraryServiceTest::TearDownTestSuite(), blender::asset_system::tests::AssetLibraryTest::TearDownTestSuite(), blender::asset_system::tests::AssetLibraryTestBase::TearDownTestSuite(), blender::bke::tests::BMainTest::TearDownTestSuite(), blender::bke::tests::BPathTest::TearDownTestSuite(), blender::bke::tests::ImageTest::TearDownTestSuite(), blender::bke::tests::LibQueryTest::TearDownTestSuite(), blender::bke::tests::LibRemapTest::TearDownTestSuite(), blender::editor::animation::tests::KeylistSummaryTest::TearDownTestSuite(), blender::geometry::tests::RealizeInstancesTest::TearDownTestSuite(), blender::gpu::GPUTest::TearDownTestSuite(), blender::interface::tests::CopyDriversToSelected::TearDownTestSuite(), blender::nodes::tests::NodeTest::TearDownTestSuite(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::io::obj::TEST(), and WM_exit_ex().
| void CLG_fatal_fn_set | ( | void(* | fatal_fn )(void *file_handle) | ) |
Definition at line 729 of file clog.c.
References CLG_ctx_fatal_fn_set(), CLogContext::fatal_fn, and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), and main().
| void CLG_init | ( | void | ) |
Definition at line 697 of file clog.c.
References clg_color_table_init(), CLG_ctx_init(), and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), main(), main(), blender::bke::image::partial_update::ImagePartialUpdateTest::SetUp(), blender::io::obj::OBJMTLParserTest::SetUpTestCase(), BlendfileLoadingBaseTest::SetUpTestCase(), blender::animrig::nla::tests::NLASlottedActionTest::SetUpTestSuite(), blender::animrig::tests::ActionFCurveMoveTest::SetUpTestSuite(), blender::animrig::tests::ActionFilterTest::SetUpTestSuite(), blender::animrig::tests::ActionIteratorsTest::SetUpTestSuite(), blender::animrig::tests::ActionLayersTest::SetUpTestSuite(), blender::animrig::tests::ActionLegacyTest::SetUpTestSuite(), blender::animrig::tests::ActionQueryTest::SetUpTestSuite(), blender::animrig::tests::AnimationEvaluationTest::SetUpTestSuite(), blender::animrig::tests::KeyframingTest::SetUpTestSuite(), blender::animrig::tests::PoseTest::SetUpTestSuite(), blender::asset_system::tests::AssetLibraryServiceTest::SetUpTestSuite(), blender::asset_system::tests::AssetLibraryTest::SetUpTestSuite(), blender::asset_system::tests::AssetLibraryTestBase::SetUpTestSuite(), blender::bke::tests::BMainTest::SetUpTestSuite(), blender::bke::tests::BPathTest::SetUpTestSuite(), blender::bke::tests::ImageTest::SetUpTestSuite(), blender::bke::tests::LibQueryTest::SetUpTestSuite(), blender::bke::tests::LibRemapTest::SetUpTestSuite(), blender::editor::animation::tests::KeylistSummaryTest::SetUpTestSuite(), blender::geometry::tests::RealizeInstancesTest::SetUpTestSuite(), blender::gpu::GPUTest::SetUpTestSuite(), blender::interface::tests::CopyDriversToSelected::SetUpTestSuite(), blender::nodes::tests::NodeTest::SetUpTestSuite(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), and blender::io::obj::TEST().
| void CLG_level_set | ( | int | level | ) |
Definition at line 749 of file clog.c.
References CLG_ctx_level_set(), g_ctx, and CLogContext::level.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), arg_handle_log_level_set(), and main().
| void CLG_log_str | ( | const CLG_LogType * | lg, |
| enum CLG_Severity | severity, | ||
| const char * | file_line, | ||
| const char * | fn, | ||
| const char * | message ) |
Definition at line 461 of file clog.c.
References CLogContext::backtrace_fn, CLogContext::callbacks, clg_ctx_backtrace(), clg_ctx_fatal_action(), CLG_SEVERITY_FATAL, clg_str_append(), clg_str_free(), clg_str_init(), CLOG_BUF_LEN_INIT, CLG_LogType::ctx, CLogStringBuf::data, CLogStringBuf::len, CLogContext::output, CLogContext::timestamp_tick_start, CLogContext::use_basename, CLogContext::use_color, CLogContext::use_timestamp, write_file_line_fn(), write_severity(), write_timestamp(), and write_type().
| void CLG_logf | ( | const CLG_LogType * | lg, |
| enum CLG_Severity | severity, | ||
| const char * | file_line, | ||
| const char * | fn, | ||
| const char * | format, | ||
| ... ) |
Definition at line 499 of file clog.c.
References CLogContext::backtrace_fn, CLogContext::callbacks, clg_ctx_backtrace(), clg_ctx_error_action(), clg_ctx_fatal_action(), CLG_SEVERITY_ERROR, CLG_SEVERITY_FATAL, clg_str_append(), clg_str_free(), clg_str_init(), clg_str_vappendf(), CLOG_BUF_LEN_INIT, CLG_LogType::ctx, CLogStringBuf::data, CLogStringBuf::len, CLogContext::output, CLogContext::timestamp_tick_start, CLogContext::use_basename, CLogContext::use_color, CLogContext::use_timestamp, write_file_line_fn(), write_severity(), write_timestamp(), and write_type().
| void CLG_logref_init | ( | CLG_LogRef * | clg_ref | ) |
Definition at line 762 of file clog.c.
References atomic_cas_ptr(), clg_ctx_type_find_by_name(), clg_ctx_type_register(), g_ctx, CLG_LogRef::identifier, CLG_LogRef::next, and CLG_LogRef::type.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), CLG_color_support_get(), blender::gpu::debug::VKDebuggingTools::init(), and blender::gpu::VKBackend::is_supported().
| void CLG_output_set | ( | void * | file_handle | ) |
Definition at line 709 of file clog.c.
References CLG_ctx_output_set(), and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), and arg_handle_log_file_set().
| void CLG_output_use_basename_set | ( | int | value | ) |
Definition at line 714 of file clog.c.
References CLG_ctx_output_use_basename_set(), and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), arg_handle_log_show_basename_set(), and main().
| void CLG_output_use_timestamp_set | ( | int | value | ) |
Definition at line 719 of file clog.c.
References CLG_ctx_output_use_timestamp_set(), and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), and arg_handle_log_show_timestamp_set().
|
static |
Definition at line 252 of file clog.c.
References assert, CLG_SEVERITY_LEN, and clg_severity_str.
Referenced by write_severity().
|
static |
Definition at line 262 of file clog.c.
References assert, CLG_SEVERITY_ERROR, CLG_SEVERITY_FATAL, CLG_SEVERITY_INFO, CLG_SEVERITY_LEN, CLG_SEVERITY_WARN, COLOR_DEFAULT, COLOR_RED, and COLOR_YELLOW.
Referenced by write_severity().
|
static |
Definition at line 168 of file clog.c.
References clg_str_append_with_len(), and str.
Referenced by CLG_log_str(), CLG_logf(), write_file_line_fn(), write_severity(), and write_type().
|
static |
Definition at line 156 of file clog.c.
References clg_str_reserve(), CLogStringBuf::data, CLogStringBuf::len, len, and str.
Referenced by clg_str_append(), write_file_line_fn(), and write_timestamp().
|
static |
Definition at line 128 of file clog.c.
References CLogStringBuf::data, CLogStringBuf::is_alloc, and MEM_freeN().
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Definition at line 120 of file clog.c.
References CLogStringBuf::data, CLogStringBuf::is_alloc, CLogStringBuf::len, and CLogStringBuf::len_alloc.
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Definition at line 135 of file clog.c.
References CLogStringBuf::data, data, CLogStringBuf::is_alloc, CLogStringBuf::len, len, CLogStringBuf::len_alloc, MEM_mallocN(), and MEM_reallocN.
Referenced by clg_str_append_with_len(), and clg_str_vappendf().
|
static |
Definition at line 174 of file clog.c.
References clg_str_reserve(), clg_str_vappendf(), and len_alloc.
Referenced by CLG_logf(), and clg_str_vappendf().
|
static |
Definition at line 385 of file clog.c.
Referenced by CLG_ctx_output_use_timestamp_set(), and write_timestamp().
| void CLG_type_filter_exclude | ( | const char * | type_match, |
| int | type_match_len ) |
Definition at line 739 of file clog.c.
References CLG_ctx_type_filter_exclude(), and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), and arg_handle_log_set().
| void CLG_type_filter_include | ( | const char * | type_match, |
| int | type_match_len ) |
Definition at line 744 of file clog.c.
References CLG_ctx_type_filter_include(), and g_ctx.
Referenced by _CLOG_ATTR_PRINTF_FORMAT(), arg_handle_debug_gpu_set(), and arg_handle_log_set().
|
static |
Action on error severity.
Definition at line 592 of file clog.c.
References CLogContext::callbacks, and CLogContext::error_fn.
Referenced by CLG_error_fn_set().
|
static |
Definition at line 437 of file clog.c.
References clg_str_append(), clg_str_append_with_len(), and PATHSEP_CHAR.
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Definition at line 416 of file clog.c.
References assert, clg_color_table, clg_severity_as_text(), CLG_SEVERITY_LEN, clg_severity_to_color(), clg_str_append(), and COLOR_RESET.
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Definition at line 404 of file clog.c.
References clg_str_append_with_len(), clg_timestamp_ticks_get(), and PRIu64.
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Definition at line 430 of file clog.c.
References clg_str_append(), and CLG_LogType::identifier.
Referenced by CLG_log_str(), and CLG_logf().
|
static |
Definition at line 226 of file clog.c.
Referenced by clg_color_table_init(), and write_severity().
|
static |
Definition at line 245 of file clog.c.
Referenced by clg_severity_as_text().
|
static |
Definition at line 695 of file clog.c.
Referenced by CLG_backtrace_fn_set(), CLG_error_fn_set(), CLG_exit(), CLG_fatal_fn_set(), CLG_init(), CLG_level_set(), CLG_logref_init(), CLG_output_set(), CLG_output_use_basename_set(), CLG_output_use_timestamp_set(), CLG_type_filter_exclude(), and CLG_type_filter_include().