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

#define GBL_LOG_MAKE_PUSH_(domain, level_macro, ...)
 
#define GBL_LOG_MAKE_SCOPE_(domain, level_macro, ...)
 
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)
 
#define GBL_LOG_DEBUG_PUSH(domain, ...)
 
#define GBL_LOG_VERBOSE_PUSH(domain, ...)
 
#define GBL_LOG_INFO_PUSH(domain, ...)
 
#define GBL_LOG_WARN_PUSH(domain, ...)
 
#define GBL_LOG_ERROR_PUSH(domain, ...)
 
#define GBL_LOG_DEBUG_SCOPE(domain, ...)
 
#define GBL_LOG_VERBOSE_SCOPE(domain, ...)
 
#define GBL_LOG_INFO_SCOPE(domain, ...)
 
#define GBL_LOG_WARN_SCOPE(domain, ...)
 
#define GBL_LOG_ERROR_SCOPE(domain, ...)
 

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.

Definition at line 39 of file gimbal_logger.h.

39#define GBL_LOG_WRITE(flags, domain, ...) GblLogger_write(__FILE__, __func__, __LINE__, \
40 domain, flags, __VA_ARGS__) //!< Generalized log write operation

◆ GBL_LOG_DEBUG

#define GBL_LOG_DEBUG ( domain,
... )

Writes to log with GBL_LOG_DEBUG.

Definition at line 41 of file gimbal_logger.h.

◆ GBL_LOG_VERBOSE

#define GBL_LOG_VERBOSE ( domain,
... )

Writes to log with GBL_LOG_VERBOSE.

Definition at line 42 of file gimbal_logger.h.

◆ GBL_LOG_INFO

#define GBL_LOG_INFO ( domain,
... )

Writes to log with GBL_LOG_INFO.

Definition at line 43 of file gimbal_logger.h.

◆ GBL_LOG_WARN

#define GBL_LOG_WARN ( domain,
... )

Writes to log with GBL_LOG_WARN.

Definition at line 44 of file gimbal_logger.h.

◆ GBL_LOG_ERROR

#define GBL_LOG_ERROR ( domain,
... )

Writes to log with GBL_LOG_ERROR.

Definition at line 45 of file gimbal_logger.h.

◆ GBL_LOG_PUSH

#define GBL_LOG_PUSH ( )

Pushes level to log stack.

Definition at line 46 of file gimbal_logger.h.

◆ GBL_LOG_POP

#define GBL_LOG_POP ( n)

Pops N levels from log stack.

Definition at line 47 of file gimbal_logger.h.

◆ GBL_LOG_DEBUG_PUSH

#define GBL_LOG_DEBUG_PUSH ( domain,
... )

Writes to log with GBL_LOG_DEBUG, then pushes level to log stack.

Definition at line 49 of file gimbal_logger.h.

◆ GBL_LOG_VERBOSE_PUSH

#define GBL_LOG_VERBOSE_PUSH ( domain,
... )

Writes to log with GBL_LOG_VERBOSE, then pushes level to log stack.

Definition at line 50 of file gimbal_logger.h.

◆ GBL_LOG_INFO_PUSH

#define GBL_LOG_INFO_PUSH ( domain,
... )

Writes to log with GBL_LOG_INFO, then pushes level to log stack.

Definition at line 51 of file gimbal_logger.h.

◆ GBL_LOG_WARN_PUSH

#define GBL_LOG_WARN_PUSH ( domain,
... )

Writes to log with GBL_LOG_WARN, then pushes level to log stack.

Definition at line 52 of file gimbal_logger.h.

◆ GBL_LOG_ERROR_PUSH

#define GBL_LOG_ERROR_PUSH ( domain,
... )

Writes to log with GBL_LOG_ERROR, then pushes level to log stack.

Definition at line 53 of file gimbal_logger.h.

◆ GBL_LOG_DEBUG_SCOPE

#define GBL_LOG_DEBUG_SCOPE ( domain,
... )

Writes to log with GBL_LOG_DEBUG, then pushes level to log stack.

Pops level when scope ends

Definition at line 55 of file gimbal_logger.h.

◆ GBL_LOG_VERBOSE_SCOPE

#define GBL_LOG_VERBOSE_SCOPE ( domain,
... )

Writes to log with GBL_LOG_VERBOSE, then pushes level to log stack.

Pops level when scope ends

Definition at line 56 of file gimbal_logger.h.

◆ GBL_LOG_INFO_SCOPE

#define GBL_LOG_INFO_SCOPE ( domain,
... )

Writes to log with GBL_LOG_INFO, then pushes level to log stack.

Pops level when scope ends

Definition at line 57 of file gimbal_logger.h.

◆ GBL_LOG_WARN_SCOPE

#define GBL_LOG_WARN_SCOPE ( domain,
... )

Writes to log with GBL_LOG_WARN, then pushes level to log stack.

Pops level when scope ends

Definition at line 58 of file gimbal_logger.h.

◆ GBL_LOG_ERROR_SCOPE

#define GBL_LOG_ERROR_SCOPE ( domain,
... )

Writes to log with GBL_LOG_ERROR, then pushes level to log stack.

Pops level when scope ends

Definition at line 59 of file gimbal_logger.h.

◆ GBL_LOG_MAKE_PUSH_

#define GBL_LOG_MAKE_PUSH_ ( domain,
level_macro,
... )

Definition at line 209 of file gimbal_logger.h.

209#define GBL_LOG_MAKE_PUSH_(domain, level_macro, ...) \
210 GBL_STMT_START { \
211 level_macro(domain, __VA_ARGS__); \
212 GBL_LOG_PUSH(); \
213 } GBL_STMT_END

◆ GBL_LOG_MAKE_SCOPE_

#define GBL_LOG_MAKE_SCOPE_ ( domain,
level_macro,
... )

Definition at line 216 of file gimbal_logger.h.

216#define GBL_LOG_MAKE_SCOPE_(domain, level_macro, ...) \
217 GBL_STMT_START { \
218 level_macro(domain, __VA_ARGS__); \
219 } GBL_STMT_END; \
220 GBL_SCOPE(GBL_LOG_PUSH(), GBL_LOG_POP(1))

Typedef Documentation

◆ GblLoggerIterFn

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

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

Definition at line 69 of file gimbal_logger.h.

◆ GBL_LOG_FLAGS

Flags used to tag a message or message filter.

Definition at line 72 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 72 of file gimbal_logger.h.

72 {
73 GBL_LOG_REENTRANT = 0x1, //!< Denotes a GblLogger's virtual methods are reentrant
74 GBL_LOG_DEBUG = 0x2, //!< Denotes a "debug" level message, which is typically disabled
75 GBL_LOG_VERBOSE = 0x4, //!< Denotes a "verbose" level message, which is regular-level
76 GBL_LOG_INFO = 0x8, //!< Denotes an "info" message, which is typically used for noteworthy events
77 GBL_LOG_WARN = 0x10, //!< Denotes a "warning" message, which means a potential issue has arisen
78 GBL_LOG_ERROR = 0x20, //!< Denotes an "error" message, which means something has failed
79 GBL_LOG_USER = 0x40 //!< Denotess the first flag which can be used for arbitrary userdata
80};
#define GBL_LOG_ERROR(domain,...)
Writes to log with GBL_LOG_ERROR.
#define GBL_LOG_INFO(domain,...)
Writes to log with GBL_LOG_INFO.
#define GBL_LOG_DEBUG(domain,...)
Writes to log with GBL_LOG_DEBUG.
#define GBL_LOG_VERBOSE(domain,...)
Writes to log with GBL_LOG_VERBOSE.
#define GBL_LOG_WARN(domain,...)
Writes to log with GBL_LOG_WARN.
@ GBL_LOG_REENTRANT
Denotes a GblLogger's virtual methods are reentrant.
@ GBL_LOG_USER
Denotess the first flag which can be used for arbitrary userdata.