Blender  V2.93
Classes | Macros | Typedefs | Enumerations | Functions
CLG_log.h File Reference

Go to the source code of this file.

Classes

struct  CLG_LogType
 
struct  CLG_LogRef
 

Macros

#define _CLOG_ATTR_NONNULL(...)
 
#define _CLOG_ATTR_PRINTF_FORMAT(format_param, dots_param)
 
#define STRINGIFY_ARG(x)   "" #x
 
#define STRINGIFY_APPEND(a, b)   "" a #b
 
#define STRINGIFY(x)   STRINGIFY_APPEND("", x)
 
#define CLG_SEVERITY_LEN   (CLG_SEVERITY_FATAL + 1)
 
#define CLG_LOGREF_DECLARE_GLOBAL(var, id)
 
#define CLOG_ENSURE(clg_ref)    ((clg_ref)->type ? (clg_ref)->type : (CLG_logref_init(clg_ref), (clg_ref)->type))
 
#define CLOG_CHECK(clg_ref, verbose_level, ...)
 
#define CLOG_AT_SEVERITY(clg_ref, severity, verbose_level, ...)
 
#define CLOG_STR_AT_SEVERITY(clg_ref, severity, verbose_level, str)
 
#define CLOG_STR_AT_SEVERITY_N(clg_ref, severity, verbose_level, str)
 
#define CLOG_INFO(clg_ref, level, ...)    CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_INFO, level, __VA_ARGS__)
 
#define CLOG_WARN(clg_ref, ...)   CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_WARN, 0, __VA_ARGS__)
 
#define CLOG_ERROR(clg_ref, ...)   CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_ERROR, 0, __VA_ARGS__)
 
#define CLOG_FATAL(clg_ref, ...)   CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_FATAL, 0, __VA_ARGS__)
 
#define CLOG_STR_INFO(clg_ref, level, str)    CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_INFO, level, str)
 
#define CLOG_STR_WARN(clg_ref, str)   CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_WARN, 0, str)
 
#define CLOG_STR_ERROR(clg_ref, str)   CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_ERROR, 0, str)
 
#define CLOG_STR_FATAL(clg_ref, str)   CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_FATAL, 0, str)
 
#define CLOG_STR_INFO_N(clg_ref, level, str)    CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_INFO, level, str)
 
#define CLOG_STR_WARN_N(clg_ref, str)   CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_WARN, 0, str)
 
#define CLOG_STR_ERROR_N(clg_ref, str)   CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_ERROR, 0, str)
 
#define CLOG_STR_FATAL_N(clg_ref, str)   CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_FATAL, 0, str)
 

Typedefs

typedef struct CLG_LogType CLG_LogType
 
typedef struct CLG_LogRef CLG_LogRef
 

Enumerations

enum  CLG_LogFlag { CLG_FLAG_USE = (1 << 0) }
 
enum  CLG_Severity { CLG_SEVERITY_INFO = 0 , CLG_SEVERITY_WARN , CLG_SEVERITY_ERROR , CLG_SEVERITY_FATAL }
 

Functions

void CLG_log_str (CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *message) _CLOG_ATTR_NONNULL(1
 
void void CLG_logf (CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *format,...) _CLOG_ATTR_NONNULL(1
 
void void _CLOG_ATTR_PRINTF_FORMAT (5, 6)
 
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_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_logref_init (CLG_LogRef *clg_ref)
 
int CLG_color_support_get (CLG_LogRef *clg_ref)
 

Detailed Description

C Logging Library (clog)

Usage

Identifiers

CLG_LogRef holds an identifier which defines the category of the logger.

You can define and use identifiers as needed, logging will lazily initialize them.

By convention lower case dot separated identifiers are used, eg: module.sub_module, this allows filtering by module.*, see CLG_type_filter_include, CLG_type_filter_exclude

There is currently no functionality to remove a category once it's created.

Severity

Usage:

Definition in file CLG_log.h.

Macro Definition Documentation

◆ _CLOG_ATTR_NONNULL

#define _CLOG_ATTR_NONNULL (   ...)

Definition at line 78 of file CLG_log.h.

◆ _CLOG_ATTR_PRINTF_FORMAT

#define _CLOG_ATTR_PRINTF_FORMAT (   format_param,
  dots_param 
)

Definition at line 85 of file CLG_log.h.

◆ CLG_LOGREF_DECLARE_GLOBAL

#define CLG_LOGREF_DECLARE_GLOBAL (   var,
  id 
)
Value:
static CLG_LogRef _static_##var = {id}; \
CLG_LogRef *var = &_static_##var

Declare outside function, declare as extern in header.

Definition at line 157 of file CLG_log.h.

◆ CLG_SEVERITY_LEN

#define CLG_SEVERITY_LEN   (CLG_SEVERITY_FATAL + 1)

Definition at line 105 of file CLG_log.h.

◆ CLOG_AT_SEVERITY

#define CLOG_AT_SEVERITY (   clg_ref,
  severity,
  verbose_level,
  ... 
)
Value:
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
(severity >= CLG_SEVERITY_WARN)) { \
CLG_logf(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
} \
} \
((void)0)
@ CLG_SEVERITY_WARN
Definition: CLG_log.h:101
@ CLG_FLAG_USE
Definition: CLG_log.h:96
#define STRINGIFY(x)
Definition: CLG_log.h:90
#define CLOG_ENSURE(clg_ref)
Definition: CLG_log.h:162

Definition at line 169 of file CLG_log.h.

◆ CLOG_CHECK

#define CLOG_CHECK (   clg_ref,
  verbose_level,
  ... 
)
Value:
((void)CLOG_ENSURE(clg_ref), \
((clg_ref)->type->flag & CLG_FLAG_USE) && ((clg_ref)->type->level >= verbose_level))
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type

Definition at line 165 of file CLG_log.h.

◆ CLOG_ENSURE

#define CLOG_ENSURE (   clg_ref)     ((clg_ref)->type ? (clg_ref)->type : (CLG_logref_init(clg_ref), (clg_ref)->type))

Initialize struct once.

Definition at line 162 of file CLG_log.h.

◆ CLOG_ERROR

#define CLOG_ERROR (   clg_ref,
  ... 
)    CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_ERROR, 0, __VA_ARGS__)

Definition at line 204 of file CLG_log.h.

◆ CLOG_FATAL

#define CLOG_FATAL (   clg_ref,
  ... 
)    CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_FATAL, 0, __VA_ARGS__)

Definition at line 205 of file CLG_log.h.

◆ CLOG_INFO

#define CLOG_INFO (   clg_ref,
  level,
  ... 
)     CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_INFO, level, __VA_ARGS__)

Definition at line 201 of file CLG_log.h.

◆ CLOG_STR_AT_SEVERITY

#define CLOG_STR_AT_SEVERITY (   clg_ref,
  severity,
  verbose_level,
  str 
)
Value:
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
(severity >= CLG_SEVERITY_WARN)) { \
CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, str); \
} \
} \
((void)0)
#define str(s)

Definition at line 179 of file CLG_log.h.

◆ CLOG_STR_AT_SEVERITY_N

#define CLOG_STR_AT_SEVERITY_N (   clg_ref,
  severity,
  verbose_level,
  str 
)
Value:
{ \
CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
(severity >= CLG_SEVERITY_WARN)) { \
const char *_str = str; \
CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, _str); \
MEM_freeN((void *)_str); \
} \
} \
((void)0)

Definition at line 189 of file CLG_log.h.

◆ CLOG_STR_ERROR

#define CLOG_STR_ERROR (   clg_ref,
  str 
)    CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_ERROR, 0, str)

Definition at line 210 of file CLG_log.h.

◆ CLOG_STR_ERROR_N

#define CLOG_STR_ERROR_N (   clg_ref,
  str 
)    CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_ERROR, 0, str)

Definition at line 217 of file CLG_log.h.

◆ CLOG_STR_FATAL

#define CLOG_STR_FATAL (   clg_ref,
  str 
)    CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_FATAL, 0, str)

Definition at line 211 of file CLG_log.h.

◆ CLOG_STR_FATAL_N

#define CLOG_STR_FATAL_N (   clg_ref,
  str 
)    CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_FATAL, 0, str)

Definition at line 218 of file CLG_log.h.

◆ CLOG_STR_INFO

#define CLOG_STR_INFO (   clg_ref,
  level,
  str 
)     CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_INFO, level, str)

Definition at line 207 of file CLG_log.h.

◆ CLOG_STR_INFO_N

#define CLOG_STR_INFO_N (   clg_ref,
  level,
  str 
)     CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_INFO, level, str)

Definition at line 214 of file CLG_log.h.

◆ CLOG_STR_WARN

#define CLOG_STR_WARN (   clg_ref,
  str 
)    CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_WARN, 0, str)

Definition at line 209 of file CLG_log.h.

◆ CLOG_STR_WARN_N

#define CLOG_STR_WARN_N (   clg_ref,
  str 
)    CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_WARN, 0, str)

Definition at line 216 of file CLG_log.h.

◆ CLOG_WARN

#define CLOG_WARN (   clg_ref,
  ... 
)    CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_WARN, 0, __VA_ARGS__)

Definition at line 203 of file CLG_log.h.

◆ STRINGIFY

#define STRINGIFY (   x)    STRINGIFY_APPEND("", x)

Definition at line 90 of file CLG_log.h.

◆ STRINGIFY_APPEND

#define STRINGIFY_APPEND (   a,
 
)    "" a #b

Definition at line 89 of file CLG_log.h.

◆ STRINGIFY_ARG

#define STRINGIFY_ARG (   x)    "" #x

Definition at line 88 of file CLG_log.h.

Typedef Documentation

◆ CLG_LogRef

typedef struct CLG_LogRef CLG_LogRef

◆ CLG_LogType

typedef struct CLG_LogType CLG_LogType

Enumeration Type Documentation

◆ CLG_LogFlag

Enumerator
CLG_FLAG_USE 

Definition at line 95 of file CLG_log.h.

◆ CLG_Severity

Enumerator
CLG_SEVERITY_INFO 
CLG_SEVERITY_WARN 
CLG_SEVERITY_ERROR 
CLG_SEVERITY_FATAL 

Definition at line 99 of file CLG_log.h.

Function Documentation

◆ _CLOG_ATTR_PRINTF_FORMAT()

void void _CLOG_ATTR_PRINTF_FORMAT ( ,
 
)

◆ CLG_backtrace_fn_set()

void CLG_backtrace_fn_set ( void(*)(void *file_handle)  fatal_fn)

Definition at line 745 of file clog.c.

References CLG_ctx_backtrace_fn_set(), CLogContext::fatal_fn, and g_ctx.

Referenced by arg_handle_log_show_backtrace_set().

◆ CLG_color_support_get()

int CLG_color_support_get ( CLG_LogRef clg_ref)

◆ CLG_error_fn_set()

void CLG_error_fn_set ( void(*)(void *file_handle)  error_fn)

Definition at line 735 of file clog.c.

References CLT_ctx_error_fn_set(), CLogContext::error_fn, and g_ctx.

Referenced by arg_handle_debug_exit_on_error().

◆ CLG_exit()

void CLG_exit ( void  )

◆ CLG_fatal_fn_set()

void CLG_fatal_fn_set ( void(*)(void *file_handle)  fatal_fn)

Definition at line 740 of file clog.c.

References CLG_ctx_fatal_fn_set(), CLogContext::fatal_fn, and g_ctx.

Referenced by main().

◆ CLG_init()

void CLG_init ( void  )

◆ CLG_level_set()

void CLG_level_set ( int  level)

Definition at line 760 of file clog.c.

References CLG_ctx_level_set(), g_ctx, and CLogContext::level.

Referenced by arg_handle_log_level_set(), and main().

◆ CLG_log_str()

void CLG_log_str ( CLG_LogType lg,
enum CLG_Severity  severity,
const char *  file_line,
const char *  fn,
const char *  message 
)

◆ CLG_logf()

void void CLG_logf ( CLG_LogType lg,
enum CLG_Severity  severity,
const char *  file_line,
const char *  fn,
const char *  format,
  ... 
)

◆ CLG_logref_init()

void CLG_logref_init ( CLG_LogRef clg_ref)

◆ CLG_output_set()

void CLG_output_set ( void *  file_handle)

Definition at line 720 of file clog.c.

References CLG_ctx_output_set(), and g_ctx.

Referenced by arg_handle_log_file_set().

◆ CLG_output_use_basename_set()

void CLG_output_use_basename_set ( int  value)

Definition at line 725 of file clog.c.

References CLG_ctx_output_use_basename_set(), and g_ctx.

Referenced by arg_handle_log_show_basename_set(), and main().

◆ CLG_output_use_timestamp_set()

void CLG_output_use_timestamp_set ( int  value)

Definition at line 730 of file clog.c.

References CLG_ctx_output_use_timestamp_set(), and g_ctx.

Referenced by arg_handle_log_show_timestamp_set().

◆ CLG_type_filter_exclude()

void CLG_type_filter_exclude ( const char *  type_filter,
int  type_filter_len 
)

Definition at line 750 of file clog.c.

References CLG_ctx_type_filter_exclude(), and g_ctx.

Referenced by arg_handle_log_set().

◆ CLG_type_filter_include()

void CLG_type_filter_include ( const char *  type_filter,
int  type_filter_len 
)

Definition at line 755 of file clog.c.

References CLG_ctx_type_filter_include(), and g_ctx.

Referenced by arg_handle_log_set().