File: logger.h

package info (click to toggle)
ceccomp 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,648 kB
  • sloc: ansic: 6,531; python: 1,078; makefile: 248; sh: 145
file content (22 lines) | stat: -rw-r--r-- 982 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef LOGGER_H
#define LOGGER_H

#include <sys/cdefs.h>
// clang-format off
__attribute__ ((noinline)) void debug_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
__attribute__ ((noinline)) void info_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
__attribute__ ((noinline)) void warn_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
__attribute__ ((noinline)) __attribute__ ((noreturn)) void error_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
// clang-format on

#ifdef DEBUG
#define debug(fmt, ...) debug_print (__func__, fmt, __VA_ARGS__)
#else
#define debug(fmt, ...) ;
#endif // !DEBUG

#define info(fmt, ...) info_print (__func__, fmt, __VA_ARGS__)
#define warn(fmt, ...) warn_print (__func__, fmt, __VA_ARGS__)
#define error(fmt, ...) error_print (__func__, fmt, __VA_ARGS__)

#endif