libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_logger.h File Reference

Go to the source code of this file.

Data Structures

struct  GblLoggerClass
 
struct  GblLogger
 

Macros

Type System

Type UUID and cast operators

#define GBL_LOGGER_TYPE
 
#define GBL_LOGGER(self)
 
#define GBL_LOGGER_CLASS(klass)
 
#define GBL_LOGGER_GET_CLASS(self)
 
Logging Macros

Top-level macros used with logging system

#define GBL_LOG_WRITE(flags, domain, ...)
 
#define GBL_LOG_DEBUG(domain, ...)
 
#define GBL_LOG_VERBOSE(domain, ...)
 
#define GBL_LOG_INFO(domain, ...)
 
#define GBL_LOG_WARN(domain, ...)
 
#define GBL_LOG_ERROR(domain, ...)
 
#define GBL_LOG_PUSH()
 
#define GBL_LOG_POP(n)
 

Typedefs

typedef GblBool(* GblLoggerIterFn) (GblLogger *pLogger, void *pClosure)
 
typedef GblFlags GBL_LOG_FLAGS
 

Enumerations

enum  GBL_LOG_FLAGS
 

Functions

GblType GblLogger_type (void)
 
GBL_RESULT GblLogger_register (GblLogger *pLogger)
 
GBL_RESULT GblLogger_unregister (GblLogger *pLogger)
 
GblBool GblLogger_foreach (GblLoggerIterFn pIt, void *pClosure)
 
GBL_RESULT GblLogger_push (void)
 
GBL_RESULT GblLogger_pop (size_t count)
 
size_t GblLogger_depth (void)
 
GBL_RESULT GblLogger_write (const char *pFile, const char *pFunction, size_t line, const char *pDomain, GBL_LOG_FLAGS flags, const char *pFmt,...)
 
GBL_RESULT GblLogger_writeVa (const char *pFile, const char *pFunction, size_t line, const char *pDomain, GBL_LOG_FLAGS flags, const char *pFmt, va_list varArgs)
 
GblLoggerGblLogger_create (GblType derived, size_t allocSize, GblLoggerClass *pClass)
 
GBL_RESULT GblLogger_construct (GblLogger *pSelf, GblType derived, GblLoggerClass *pClass)
 
GblRefCount GblLogger_unref (GblLogger *pSelf)
 
GblBool GblLogger_hasFilter (const GblLogger *pSelf, const GblThd *pThread, const char *pDomain, GBL_LOG_FLAGS flags)
 
GBL_RESULT GblLogger_setDomainFilters (GblLogger *pSelf, const char *domains[])
 
const char ** GblLogger_domainFilters (const GblLogger *pSelf)
 
GblBool GblLogger_hasDomainFilter (const GblLogger *pSelf, const char *pDomain)
 
GBL_RESULT GblLogger_setThreadFilters (GblLogger *pSelf, const GblThd *pThrs[])
 
const GblThd ** GblLogger_threadFilters (const GblLogger *pSelf)
 
GblBool GblLogger_hasThreadFilter (const GblLogger *pSelf, const GblThd *pThr)
 

Detailed Description

GblLogger filterable log and logging macros.

This file provides the public API for creating and managing custom logger types as well as the utility macros for actually using the log system.

Todo:
  • migrate away from GblThd and towards GblThread
  • Spam filter: deduplicate messages within a certain interval
  • Default constructor values
Author
2023 Falco Girgis

Definition in file gimbal_logger.h.

Macro Definition Documentation

◆ GBL_LOGGER_TYPE

#define GBL_LOGGER_TYPE

Type UUID for GblLogger.

Definition at line 29 of file gimbal_logger.h.

◆ GBL_LOGGER

#define GBL_LOGGER (   self)

Function-style cast to GblLogger.

Definition at line 30 of file gimbal_logger.h.

◆ GBL_LOGGER_CLASS

#define GBL_LOGGER_CLASS (   klass)

Function-style cast to GblLoggerClass.

Definition at line 31 of file gimbal_logger.h.

◆ GBL_LOGGER_GET_CLASS

#define GBL_LOGGER_GET_CLASS (   self)

Get GblLoggerClass from GblLogger.

Definition at line 32 of file gimbal_logger.h.

◆ GBL_LOG_WRITE

#define GBL_LOG_WRITE (   flags,
  domain,
  ... 
)

Generalized log write operation/*#end#*‍/.

Definition at line 41 of file gimbal_logger.h.

◆ GBL_LOG_DEBUG

#define GBL_LOG_DEBUG (   domain,
  ... 
)

Writes to log with GBL_LOG_DEBUG.

Definition at line 42 of file gimbal_logger.h.

◆ GBL_LOG_VERBOSE

#define GBL_LOG_VERBOSE (   domain,
  ... 
)

Writes to log with GBL_LOG_VERBOSE.

Definition at line 43 of file gimbal_logger.h.

◆ GBL_LOG_INFO

#define GBL_LOG_INFO (   domain,
  ... 
)

Writes to log with GBL_LOG_INFO.

Definition at line 44 of file gimbal_logger.h.

◆ GBL_LOG_WARN

#define GBL_LOG_WARN (   domain,
  ... 
)

Writes to log with GBL_LOG_WARN.

Definition at line 45 of file gimbal_logger.h.

◆ GBL_LOG_ERROR

#define GBL_LOG_ERROR (   domain,
  ... 
)

Writes to log with GBL_LOG_ERROR.

Definition at line 46 of file gimbal_logger.h.

◆ GBL_LOG_PUSH

#define GBL_LOG_PUSH ( )

Pushes level to log stack.

Definition at line 47 of file gimbal_logger.h.

◆ GBL_LOG_POP

#define GBL_LOG_POP (   n)

Pops N levels from log stack.

Definition at line 48 of file gimbal_logger.h.

Typedef Documentation

◆ GblLoggerIterFn

typedef GblBool(* GblLoggerIterFn) (GblLogger *pLogger, void *pClosure)

Function signature for iterating over all loggers (see GblLogger_foreach())

Definition at line 58 of file gimbal_logger.h.

◆ GBL_LOG_FLAGS

Flags used to tag a message or message filter.

Definition at line 61 of file gimbal_logger.h.

Enumeration Type Documentation

◆ GBL_LOG_FLAGS

Enumerator
GBL_LOG_REENTRANT 

Denotes a GblLogger's virtual methods are reentrant.

GBL_LOG_DEBUG 

Denotes a "debug" level message, which is typically disabled.

GBL_LOG_VERBOSE 

Denotes a "verbose" level message, which is regular-level.

GBL_LOG_INFO 

Denotes an "info" message, which is typically used for noteworthy events.

GBL_LOG_WARN 

Denotes a "warning" message, which means a potential issue has arisen.

GBL_LOG_ERROR 

Denotes an "error" message, which means something has failed.

GBL_LOG_USER 

Denotess the first flag which can be used for arbitrary userdata.

Definition at line 61 of file gimbal_logger.h.

115 {
116 GblLinkedListNode listNode; //!< Internal generic list node
117 GblLogger* pNext; //!< Internal pointer to next logger in list
118 };
119 GblBool reentrant; //!< Whether the logger is already handling a messaage
121 GblFlags flagsFilter; //!< Combination of GBL_LOG_FLAGS to filter messages for
122GBL_INSTANCE_END
123
124//! \cond
126 (flagsFilter, GBL_GENERIC, (READ, WRITE), GBL_FLAGS_TYPE),
127 (threadFilters, GBL_GENERIC, (READ, WRITE), GBL_POINTER_TYPE),
128 (domainFilters, GBL_GENERIC, (READ, WRITE), GBL_POINTER_TYPE)
129)
130//! \endcond
131
132// ===== Static Methods =====
133GBL_EXPORT GblType GblLogger_type (void) GBL_NOEXCEPT;
134GBL_EXPORT GBL_RESULT GblLogger_register (GblLogger* pLogger) GBL_NOEXCEPT;
135GBL_EXPORT GBL_RESULT GblLogger_unregister (GblLogger* pLogger) GBL_NOEXCEPT;
136
137GBL_EXPORT GblBool GblLogger_foreach (GblLoggerIterFn pIt,
138 void* pClosure) GBL_NOEXCEPT;
139
140GBL_EXPORT GBL_RESULT GblLogger_push (void) GBL_NOEXCEPT;
141GBL_EXPORT GBL_RESULT GblLogger_pop (size_t count) GBL_NOEXCEPT;
142GBL_EXPORT size_t GblLogger_depth (void) GBL_NOEXCEPT;
143
144GBL_EXPORT GBL_RESULT GblLogger_write (const char* pFile,
145 const char* pFunction,
146 size_t line,
147 const char* pDomain,
148 GBL_LOG_FLAGS flags,
149 const char* pFmt,
150 ...) GBL_NOEXCEPT;
151
152GBL_EXPORT GBL_RESULT GblLogger_writeVa (const char* pFile,
153 const char* pFunction,
154 size_t line,
155 const char* pDomain,
156 GBL_LOG_FLAGS flags,
157 const char* pFmt,
158 va_list varArgs) GBL_NOEXCEPT;
159// ===== Instance Methods =====
160GBL_EXPORT GblLogger* GblLogger_create (GblType derived,
161 size_t allocSize,
162 GblLoggerClass* pClass) GBL_NOEXCEPT;
163
164GBL_EXPORT GBL_RESULT GblLogger_construct (GBL_SELF,
165 GblType derived,
166 GblLoggerClass* pClass) GBL_NOEXCEPT;
167
168GBL_EXPORT GblRefCount GblLogger_unref (GBL_SELF) GBL_NOEXCEPT;
169
170GBL_EXPORT GblBool GblLogger_hasFilter (GBL_CSELF,
171 const GblThd* pThread,
172 const char* pDomain,
173 GBL_LOG_FLAGS flags) GBL_NOEXCEPT;
174
175GBL_EXPORT GBL_RESULT GblLogger_setDomainFilters (GBL_SELF,
176 const char* domains[]) GBL_NOEXCEPT;
177
178GBL_EXPORT const char** GblLogger_domainFilters (GBL_CSELF) GBL_NOEXCEPT;
179
180GBL_EXPORT GblBool GblLogger_hasDomainFilter (GBL_CSELF,
181 const char* pDomain) GBL_NOEXCEPT;
182
183GBL_EXPORT GBL_RESULT GblLogger_setThreadFilters (GBL_SELF,
184 const GblThd* pThrs[]) GBL_NOEXCEPT;
185
186GBL_EXPORT const GblThd**
187 GblLogger_threadFilters (GBL_CSELF) GBL_NOEXCEPT;
188
189GBL_EXPORT GblBool GblLogger_hasThreadFilter (GBL_CSELF,
190 const GblThd* pThr) GBL_NOEXCEPT;
191
192GBL_DECLS_END
193
194#undef GBL_SELF_TYPE
195
196#endif // GIMBAL_LOGGER_H
#define GBL_PRIVATE_END
Private data structure.
#define GBL_FLAGS_TYPE
GblType UUID for flags.
GblBool(* GblLoggerIterFn)(GblLogger *pLogger, void *pClosure)
Function signature for iterating over all loggers (see GblLogger_foreach())
GBL_LOG_FLAGS
#define GBL_PROPERTIES(object,...)
Declares a list of properties for the given object/instance structure.
GBL_RESULT
uint32_t GblFlags
Standard-sized flags type, 32-bits across platforms.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
uintptr_t GblType
Meta Type UUID.
Definition gimbal_type.h:51
Intrustive singly linked list structure with vector-style API.
GblClass vtable for GblLogger.
Object used for implementing a custom logger.
Deprecated legacy structure for thread-local storage and context.
Definition gimbal_thd.h:22