libmemalloc  v3.5.00
Modern Memory Allocator
Loading...
Searching...
No Matches
logs.h File Reference

Logging macros and configuration for libmemalloc. More...

#include <errno.h>
#include <pthread.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
Include dependency graph for logs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOG_LEVEL   LOG_LEVEL_DEBUG
 Logging verbosity threshold for this module.
 
#define LOG_PRINTF(...)   fprintf(__VA_ARGS__)
 Compiler-specific printf abstraction (variadic).
 
#define LOG_VPRINTF(...)   vfprintf(__VA_ARGS__)
 Compiler-specific vprintf abstraction.
 
#define PREFIX_ERROR   "[ERROR]"
 
#define PREFIX_WARNING   "[WARNING]"
 
#define PREFIX_INFO   "[INFO]"
 
#define PREFIX_DEBUG   "[DEBUG]"
 
#define COLOR_RED   "\033[0;31m"
 
#define COLOR_YELLOW   "\033[0;33m"
 
#define COLOR_BLUE   "\033[0;34m"
 
#define COLOR_GREEN   "\033[0;32m"
 
#define COLOR_RESET   "\033[0m"
 
#define ATTR_PRINTF(fmt_idx, var_idx)
 Macro to apply printf-style format checking on custom functions when supported by the compiler.
 
#define LOG_ERROR(...)
 Logs an error message (red).
 
#define LOG_WARNING(...)
 Logs a warning message (yellow).
 
#define LOG_INFO(...)
 Logs an info message (blue).
 
#define LOG_DEBUG(...)
 Logs a debug message (green).
 

Enumerations

enum  log_level_t {
  LOG_LEVEL_NONE = (uint8_t)(0u) , LOG_LEVEL_ERROR = (uint8_t)(1u) , LOG_LEVEL_WARNING = (uint8_t)(2u) , LOG_LEVEL_INFO = (uint8_t)(3u) ,
  LOG_LEVEL_DEBUG = (uint8_t)(4u)
}
 Defines log levels for the logging system. More...
 

Functions

static int LOG_output (log_level_t level, const char *color, const char *prefix, const char *file, const char *func, int line, const char *fmt,...)
 Internal logging implementation: thread‐safe, prints timestamp, optional ANSI color, severity prefix, formatted message, and source location.
 

Detailed Description

Logging macros and configuration for libmemalloc.

Provides logging utilities for libmemalloc, including log level control (ERROR, WARNING, INFO, DEBUG), ANSI color output, and automatic file, function, and line reporting for each log entry. Supports GCC-specific built-in printing as well as standard printf for other compilers.

Version
v3.5.00
Date
11.01.2026
Author
Rafael V. Volkmer rafae.nosp@m.l.v..nosp@m.volkm.nosp@m.er@g.nosp@m.mail..nosp@m.com