libpynq (release 5EWC0-2023 version 0.2.0 of 2023-08-28 20:33)
Loading...
Searching...
No Matches
log.c
Go to the documentation of this file.
1#include <log.h>
2#include <stdarg.h>
3#include <stdbool.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7
8static LogLevel critical_level = LOG_LEVEL_ERROR;
9static LogLevel min_log_level = LOG_LEVEL_WARNING;
10
11void pynq_log(const LogLevel level, char const *domain, char const *location,
12 unsigned int lineno, char const *fmt, ...){
13 va_list arg_list;
14 if (level < min_log_level) {
15 return;
16 }
17 va_start(arg_list, fmt);
18 vfprintf(stderr, fmt, arg_list);
19 va_end(arg_list);
20 if (fmt[strlen(fmt) - 1] != '\n') {
21 fputs("\n", stderr);
22 }
23 if (level >= critical_level) {
24 abort();
25 }
26}
void pynq_log(const LogLevel level, char const *domain, char const *location, unsigned int lineno, char const *fmt,...)
Definition log.c:11
LogLevel
Definition log.h:65
@ LOG_LEVEL_ERROR
Definition log.h:71
@ LOG_LEVEL_WARNING
Definition log.h:69