USRP Hardware Driver and USRP Manual: log.h Source File

| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Ettus Research (National Instruments Corp.)
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7#pragma once
8
9#include <uhd/config.h>
10
11 typedef enum {
12 UHD_LOG_LEVEL_TRACE,
13 UHD_LOG_LEVEL_DEBUG,
14 UHD_LOG_LEVEL_INFO,
15 UHD_LOG_LEVEL_WARNING,
16 UHD_LOG_LEVEL_ERROR,
17 UHD_LOG_LEVEL_FATAL
18} uhd_log_severity_level_t;
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24 void UHD_API _uhd_log(const uhd_log_severity_level_t log_level,
25 const char* filename,
26 const int lineno,
27 const char* comp,
28 const char* format,
29 ...);
30
31#ifdef __cplusplus
32};
33#endif
34
35
36#ifndef __cplusplus
37// macro-style logging (compile-time determined)
38# if UHD_LOG_MIN_LEVEL < 1
39# define UHD_LOG_TRACE(component, ...) \
40 _uhd_log(UHD_LOG_LEVEL_TRACE, __FILE__, __LINE__, component, __VA_ARGS__);
41# else
42# define UHD_LOG_TRACE(component, ...)
43# endif
44
45# if UHD_LOG_MIN_LEVEL < 2
46# define UHD_LOG_DEBUG(component, ...) \
47 _uhd_log(UHD_LOG_LEVEL_DEBUG, __FILE__, __LINE__, component, __VA_ARGS__);
48# else
49# define UHD_LOG_DEBUG(component, ...)
50# endif
51
52# if UHD_LOG_MIN_LEVEL < 3
53# define UHD_LOG_INFO(component, ...) \
54 _uhd_log(UHD_LOG_LEVEL_INFO, __FILE__, __LINE__, component, __VA_ARGS__);
55# else
56# define UHD_LOG_INFO(component, ...)
57# endif
58
59# if UHD_LOG_MIN_LEVEL < 4
60# define UHD_LOG_WARNING(component, ...) \
61 _uhd_log(UHD_LOG_LEVEL_WARNING, __FILE__, __LINE__, component, __VA_ARGS__);
62# else
63# define UHD_LOG_WARNING(component, ...)
64# endif
65
66# if UHD_LOG_MIN_LEVEL < 5
67# define UHD_LOG_ERROR(component, ...) \
68 _uhd_log(UHD_LOG_LEVEL_ERROR, __FILE__, __LINE__, component, __VA_ARGS__);
69# else
70# define UHD_LOG_ERROR(component, ...)
71# endif
72
73# if UHD_LOG_MIN_LEVEL < 6
74# define UHD_LOG_FATAL(component, ...) \
75 _uhd_log(UHD_LOG_LEVEL_FATAL, __FILE__, __LINE__, component, __VA_ARGS__);
76# else
77# define UHD_LOG_FATAL(component, ...)
78# endif
79
80#endif /* #ifndef __cplusplus */
config.h
UHD_API
#define UHD_API
Definition config.h:87
uhd_log_severity_level_t
uhd_log_severity_level_t
Definition log.h:11
UHD_LOG_LEVEL_TRACE
@ UHD_LOG_LEVEL_TRACE
Definition log.h:12
UHD_LOG_LEVEL_ERROR
@ UHD_LOG_LEVEL_ERROR
Definition log.h:16
UHD_LOG_LEVEL_INFO
@ UHD_LOG_LEVEL_INFO
Definition log.h:14
UHD_LOG_LEVEL_DEBUG
@ UHD_LOG_LEVEL_DEBUG
Definition log.h:13
UHD_LOG_LEVEL_FATAL
@ UHD_LOG_LEVEL_FATAL
Definition log.h:17
UHD_LOG_LEVEL_WARNING
@ UHD_LOG_LEVEL_WARNING
Definition log.h:15
_uhd_log
void UHD_API _uhd_log(const uhd_log_severity_level_t log_level, const char *filename, const int lineno, const char *comp, const char *format,...)