18#ifdef WITH_CLOG_PTHREADS
24#if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
32# include <VersionHelpers.h>
34# if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
35# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
40#define __STDC_FORMAT_MACROS
50#define STREQ(a, b) (strcmp(a, b) == 0)
51#define STREQLEN(a, b, n) (strncmp(a, b, n) == 0)
54# define PATHSEP_CHAR '\\'
56# define PATHSEP_CHAR '/'
74#ifdef WITH_CLOG_PTHREADS
75 pthread_mutex_t types_lock;
111#define CLOG_BUF_LEN_INIT 512
122 cstr->
data = buf_stack;
149 memcpy(data, cstr->
data, cstr->
len);
160 char *str_dst = cstr->
data + cstr->
len;
161 memcpy(str_dst,
str,
len);
165 cstr->
len = len_next;
177 const uint len_max = 65535;
178 uint len_avail = cstr->len_alloc - cstr->len;
181 va_copy(args_cpy, args);
182 int retval = vsnprintf(cstr->data + cstr->len, len_avail,
format, args_cpy);
191 if ((
uint)retval <= len_avail) {
193 cstr->len += (
uint)retval;
206 len_avail = cstr->len_alloc - cstr->len;
224#define COLOR_LEN (COLOR_RESET + 1)
228static DWORD clg_previous_console_mode = 0;
260 return "INVALID_SEVERITY";
302 const size_t identifier_len = strlen(identifier);
303 for (
uint i = 0; i < 2; i++) {
305 while (flt !=
NULL) {
306 const size_t len = strlen(flt->
match);
312 memcpy(match, flt->
match + 1,
len - 2);
313 const bool success = (strstr(identifier, match) !=
NULL);
339 if (
STREQ(identifier, ty->identifier)) {
391 tick = GetTickCount64();
394 gettimeofday(&tv,
NULL);
395 tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
408 char timestamp_str[64];
410 const uint timestamp_len = snprintf(timestamp_str,
411 sizeof(timestamp_str),
414 (
uint)(timestamp % 1000));
440 const char *file_line,
442 const bool use_basename)
444 uint file_line_len = strlen(file_line);
446 uint file_line_offset = file_line_len;
447 while (file_line_offset-- > 0) {
453 file_line += file_line_offset;
454 file_line_len -= file_line_offset;
465 const char *file_line,
471 clg_str_init(&cstr, cstr_stack_buf,
sizeof(cstr_stack_buf));
503 const char *file_line,
510 clg_str_init(&cstr, cstr_stack_buf,
sizeof(cstr_stack_buf));
558#if defined(__unix__) || defined(__APPLE__)
568 GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &clg_previous_console_mode);
571 if (IsWindows10OrGreater() && isatty(ctx->
output)) {
572 DWORD mode = clg_previous_console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
573 if (SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), mode)) {
611 const char *type_match,
614 if (type_match_len == 0) {
618 flt->
next = *flt_list;
620 memcpy(flt->
match, type_match, type_match_len);
625 const char *type_match,
632 const char *type_match,
649#ifdef WITH_CLOG_PTHREADS
650 pthread_mutex_init(&ctx->types_lock,
NULL);
661 SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), clg_previous_console_mode);
675 for (
uint i = 0; i < 2; i++) {
682#ifdef WITH_CLOG_PTHREADS
683 pthread_mutex_destroy(&ctx->types_lock);
766#ifdef WITH_CLOG_PTHREADS
768 pthread_mutex_lock(&
g_ctx->types_lock);
776 if (clg_ty ==
NULL) {
779#ifdef WITH_CLOG_PTHREADS
782 clg_ref->
type = clg_ty;
785#ifdef WITH_CLOG_PTHREADS
786 pthread_mutex_unlock(&
g_ctx->types_lock);
#define ATTR_PRINTF_FORMAT(format_param, dots_param)
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
ATOMIC_INLINE void * atomic_cas_ptr(void **v, void *old, void *_new)
static void CLG_ctx_output_set(CLogContext *ctx, void *file_handle)
static void write_type(CLogStringBuf *cstr, const CLG_LogType *lg)
void CLG_logf(const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *format,...)
void CLG_type_filter_exclude(const char *type_match, int type_match_len)
static void clg_str_vappendf(CLogStringBuf *cstr, const char *format, va_list args)
static void clg_ctx_fatal_action(CLogContext *ctx)
void CLG_output_set(void *file_handle)
static void CLG_ctx_free(CLogContext *ctx)
void CLG_output_use_basename_set(int value)
void CLG_log_str(const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *message)
void CLG_error_fn_set(void(*error_fn)(void *file_handle))
struct CLG_IDFilter CLG_IDFilter
static void clg_ctx_error_action(CLogContext *ctx)
static CLG_LogType * clg_ctx_type_find_by_name(CLogContext *ctx, const char *identifier)
void CLG_backtrace_fn_set(void(*fatal_fn)(void *file_handle))
static void CLG_ctx_output_use_timestamp_set(CLogContext *ctx, int value)
static uint64_t clg_timestamp_ticks_get(void)
static void clg_str_append_with_len(CLogStringBuf *cstr, const char *str, const uint len)
struct CLogContext CLogContext
static void write_timestamp(CLogStringBuf *cstr, const uint64_t timestamp_tick_start)
#define CLOG_BUF_LEN_INIT
#define STREQLEN(a, b, n)
void CLG_fatal_fn_set(void(*fatal_fn)(void *file_handle))
static void clg_str_append(CLogStringBuf *cstr, const char *str)
static const char * clg_color_table[COLOR_LEN]
static void CLG_ctx_fatal_fn_set(CLogContext *ctx, void(*fatal_fn)(void *file_handle))
void CLG_type_filter_include(const char *type_match, int type_match_len)
void CLG_logref_init(CLG_LogRef *clg_ref)
static void clg_ctx_type_filter_append(CLG_IDFilter **flt_list, const char *type_match, int type_match_len)
void CLG_level_set(int level)
static struct CLogContext * g_ctx
static CLogContext * CLG_ctx_init(void)
struct CLogStringBuf CLogStringBuf
static void clg_str_free(CLogStringBuf *cstr)
void CLG_output_use_timestamp_set(int value)
static void CLG_ctx_output_use_basename_set(CLogContext *ctx, int value)
static CLG_LogType * clg_ctx_type_register(CLogContext *ctx, const char *identifier)
static void clg_str_init(CLogStringBuf *cstr, char *buf_stack, uint buf_stack_len)
static void clg_ctx_backtrace(CLogContext *ctx)
static void CLG_ctx_backtrace_fn_set(CLogContext *ctx, void(*backtrace_fn)(void *file_handle))
static const char * clg_severity_str[CLG_SEVERITY_LEN]
static void clg_str_reserve(CLogStringBuf *cstr, const uint len)
static void CLG_ctx_type_filter_exclude(CLogContext *ctx, const char *type_match, int type_match_len)
static const char * clg_severity_as_text(enum CLG_Severity severity)
static void clg_color_table_init(bool use_color)
static void CLG_ctx_level_set(CLogContext *ctx, int level)
int CLG_color_support_get(CLG_LogRef *clg_ref)
static bool clg_ctx_filter_check(CLogContext *ctx, const char *identifier)
static void CLG_ctx_type_filter_include(CLogContext *ctx, const char *type_match, int type_match_len)
static enum eCLogColor clg_severity_to_color(enum CLG_Severity severity)
static void write_severity(CLogStringBuf *cstr, enum CLG_Severity severity, bool use_color)
static void CLT_ctx_error_fn_set(CLogContext *ctx, void(*error_fn)(void *file_handle))
static void write_file_line_fn(CLogStringBuf *cstr, const char *file_line, const char *fn, const bool use_basename)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
unsigned __int64 uint64_t
struct CLG_IDFilter * next
struct CLG_LogType * next
void(* fatal_fn)(void *file_handle)
void(* error_fn)(void *file_handle)
uint64_t timestamp_tick_start
struct CLogContext::@1410 callbacks
void(* backtrace_fn)(void *file_handle)
struct CLogContext::@1409 default_type
CLG_IDFilter * filters[2]