libpynq (release 5EWC0-2023 version 0.2.2 of 2023-09-24 22:22)
Loading...
Searching...
No Matches
Logging library

Macros

#define pynq_info(...)    pynq_log(LOG_LEVEL_INFO, LOG_DOMAIN, __FUNCTION__, __LINE__, __VA_ARGS__)
 
#define pynq_warning(...)    pynq_log(LOG_LEVEL_WARNING, LOG_DOMAIN, __FUNCTION__, __LINE__, __VA_ARGS__)
 
#define pynq_error(...)
 

Typedefs

typedef enum LogLevel LogLevel
 

Enumerations

enum  LogLevel { LOG_LEVEL_INFO , LOG_LEVEL_WARNING , LOG_LEVEL_ERROR , NUM_LOG_LEVELS }
 

Functions

void pynq_log (const LogLevel level, char const *domain, char const *location, unsigned int lineno, char const *fmt,...)
 

Detailed Description

Functions for error handling and logging.

#include <log.h>
int main (void)
{
pynq_log("Print my information message");
pynq_warning("Print my warning message");
pynq_error("Failed on error");
return EXIT_SUCCESS;
}
void pynq_log(const LogLevel level, char const *domain, char const *location, unsigned int lineno, char const *fmt,...)
Definition log.c:52
#define pynq_error(...)
Definition log.h:118
#define pynq_warning(...)
Definition log.h:109

Or with a custom log domain

#include <log.h>
#undef LOG_DOMAIN
#define LOG_DOMAIN "MyApp"
int main ( int argc, char **argv)
{
pynq_log("Print my information message");
pynq_warning("Print my warning message");
pynq_error("Failed on error");
return EXIT_SUCCESS;
}

Macro Definition Documentation

◆ pynq_error

#define pynq_error (   ...)
Value:
do { \
pynq_log(LOG_LEVEL_ERROR, LOG_DOMAIN, __FUNCTION__, __LINE__, \
__VA_ARGS__); \
for (;;) \
; \
} while (0)
@ LOG_LEVEL_ERROR
Definition log.h:71
#define LOG_DOMAIN
Definition log.h:25
Parameters
...

Wrapper around pynq_log to print error messages. This expects LOG_DOMAIN to be set.

Definition at line 118 of file log.h.

◆ pynq_info

#define pynq_info (   ...)     pynq_log(LOG_LEVEL_INFO, LOG_DOMAIN, __FUNCTION__, __LINE__, __VA_ARGS__)
Parameters
...

Wrapper around pynq_log to print info messages. This expects LOG_DOMAIN to be set.

Definition at line 100 of file log.h.

◆ pynq_warning

#define pynq_warning (   ...)     pynq_log(LOG_LEVEL_WARNING, LOG_DOMAIN, __FUNCTION__, __LINE__, __VA_ARGS__)
Parameters
...

Wrapper around pynq_log to print warning messages. This expects LOG_DOMAIN to be set.

Definition at line 109 of file log.h.

Typedef Documentation

◆ LogLevel

typedef enum LogLevel LogLevel

Enumeration Type Documentation

◆ LogLevel

enum LogLevel
Enumerator
LOG_LEVEL_INFO 

Informational messages.

LOG_LEVEL_WARNING 

Warning messages

LOG_LEVEL_ERROR 

Error messages

NUM_LOG_LEVELS 

Number of log levels

Definition at line 65 of file log.h.

Function Documentation

◆ pynq_log()

void pynq_log ( const LogLevel  level,
char const *  domain,
char const *  location,
unsigned int  lineno,
char const *  fmt,
  ... 
)
Parameters
levelThe LogLevel of this mssage.
domainThe log domain.
fmtThe format string.
locationThe location string of the message origin.
linenoThe line number of the message origin.
...The arguments to the format string.

Print log messages with loglevel WARNING and higher. Messages of level ERROR will result in an abort().

Environment DEBUG will print out level LOG_LEVEL_INFO Environment FATAL_WARNING will abort after a warning.

Definition at line 52 of file log.c.