diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 07:10:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 07:10:00 +0000 |
commit | 4ba2b326284765e942044db13a7f0dae702bec93 (patch) | |
tree | cbdfaec33eed4f3a970c54cd10e8ddfe3003b3b1 /lib/util/logging.h | |
parent | Initial commit. (diff) | |
download | xdp-tools-4ba2b326284765e942044db13a7f0dae702bec93.tar.xz xdp-tools-4ba2b326284765e942044db13a7f0dae702bec93.zip |
Adding upstream version 1.3.1.upstream/1.3.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/util/logging.h')
-rw-r--r-- | lib/util/logging.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/util/logging.h b/lib/util/logging.h new file mode 100644 index 0000000..16c4e74 --- /dev/null +++ b/lib/util/logging.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __LOGGING_H +#define __LOGGING_H + +/* This matches the libbpf logging levels, but with an additional VERBOSE level; + * we demote all libbpf messages by one level so debug messages only show up on + * VERBOSE. + */ +enum logging_print_level { + LOG_WARN, + LOG_INFO, + LOG_DEBUG, + LOG_VERBOSE, +}; + +extern void logging_print(enum logging_print_level level, const char *format, + ...) __attribute__((format(printf, 2, 3))); + +#define __pr(level, fmt, ...) \ + do { \ + logging_print(level, fmt, ##__VA_ARGS__); \ + } while (0) + +#define pr_warn(fmt, ...) __pr(LOG_WARN, fmt, ##__VA_ARGS__) +#define pr_info(fmt, ...) __pr(LOG_INFO, fmt, ##__VA_ARGS__) +#define pr_debug(fmt, ...) __pr(LOG_DEBUG, fmt, ##__VA_ARGS__) + +void init_lib_logging(void); +void silence_libbpf_logging(void); +void silence_libxdp_logging(void); +enum logging_print_level set_log_level(enum logging_print_level level); +enum logging_print_level increase_log_level(); + +#endif |