libPeConv
A library to load, manipulate, dump PE files.
Loading...
Searching...
No Matches
Macros
logger.h File Reference

Compile-time configurable logging macros for peconv. More...

#include <stdio.h>

Go to the source code of this file.

Macros

#define LOG_LEVEL_NONE   0
 
#define LOG_LEVEL_ERROR   1
 
#define LOG_LEVEL_WARNING   2
 
#define LOG_LEVEL_INFO   3
 
#define LOG_LEVEL_DEBUG   4
 
#define LOG_VERBOSITY   LOG_LEVEL_ERROR
 
#define _LOG(tag, fmt, ...)
 
#define LOG_ERROR(fmt, ...)   _LOG("ERROR", fmt, ##__VA_ARGS__)
 
#define LOG_WARNING(fmt, ...)   do {} while(0)
 
#define LOG_INFO(fmt, ...)   do {} while(0)
 
#define LOG_DEBUG(fmt, ...)   do {} while(0)
 

Detailed Description

Compile-time configurable logging macros for peconv.

Verbosity is controlled at compile time via the LOG_VERBOSITY preprocessor symbol. Any message whose level exceeds LOG_VERBOSITY is compiled out entirely — no runtime overhead, no branch, no string literal in the binary.

By default messages are written to stderr. Define LOG_USE_DEBUGOUT before including this header (or via the build system) to redirect output to the Windows debugger via OutputDebugStringA instead.

Typical build-system usage:

// Errors only (default):
#define LOG_VERBOSITY LOG_LEVEL_ERROR
// Full tracing:
#define LOG_VERBOSITY LOG_LEVEL_DEBUG
// Redirect to debugger output:
#define LOG_USE_DEBUGOUT

Definition in file logger.h.

Macro Definition Documentation

◆ _LOG

#define _LOG (   tag,
  fmt,
  ... 
)
Value:
fprintf(stderr, "[" tag "] %s:%d: " fmt "\n", \
__FILE__, __LINE__, ##__VA_ARGS__)

Definition at line 53 of file logger.h.

◆ LOG_DEBUG

#define LOG_DEBUG (   fmt,
  ... 
)    do {} while(0)

Definition at line 80 of file logger.h.

◆ LOG_ERROR

#define LOG_ERROR (   fmt,
  ... 
)    _LOG("ERROR", fmt, ##__VA_ARGS__)

Definition at line 60 of file logger.h.

◆ LOG_INFO

#define LOG_INFO (   fmt,
  ... 
)    do {} while(0)

Definition at line 74 of file logger.h.

◆ LOG_LEVEL_DEBUG

#define LOG_LEVEL_DEBUG   4

Definition at line 33 of file logger.h.

◆ LOG_LEVEL_ERROR

#define LOG_LEVEL_ERROR   1

Definition at line 30 of file logger.h.

◆ LOG_LEVEL_INFO

#define LOG_LEVEL_INFO   3

Definition at line 32 of file logger.h.

◆ LOG_LEVEL_NONE

#define LOG_LEVEL_NONE   0

Definition at line 29 of file logger.h.

◆ LOG_LEVEL_WARNING

#define LOG_LEVEL_WARNING   2

Definition at line 31 of file logger.h.

◆ LOG_VERBOSITY

#define LOG_VERBOSITY   LOG_LEVEL_ERROR

Definition at line 36 of file logger.h.

◆ LOG_WARNING

#define LOG_WARNING (   fmt,
  ... 
)    do {} while(0)

Definition at line 68 of file logger.h.