Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
ca821x_log.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, Cascoda Ltd.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the copyright holder nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
41#ifndef DOXYGEN
42// Force doxygen to document static inline
43#define STATIC static
44#endif
45
46#ifndef CA821X_API_INCLUDE_CA821X_LOG_H_
47#define CA821X_API_INCLUDE_CA821X_LOG_H_
48
49#include <stdarg.h>
50
51#include "ca821x_config.h"
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
66
77void ca_log(ca_loglevel loglevel, const char *format, va_list argp);
78
83STATIC inline void ca_log_crit(const char *format, ...)
84{
85 if (CASCODA_LOG_LEVEL >= CA_LOGLEVEL_CRIT)
86 {
87 va_list va_args;
88 va_start(va_args, format);
89 ca_log(CA_LOGLEVEL_CRIT, format, va_args);
90 va_end(va_args);
91 }
92}
93
98STATIC inline void ca_log_warn(const char *format, ...)
99{
100 if (CASCODA_LOG_LEVEL >= CA_LOGLEVEL_WARN)
101 {
102 va_list va_args;
103 va_start(va_args, format);
104 ca_log(CA_LOGLEVEL_WARN, format, va_args);
105 va_end(va_args);
106 }
107}
108
113STATIC inline void ca_log_note(const char *format, ...)
114{
115 if (CASCODA_LOG_LEVEL >= CA_LOGLEVEL_NOTE)
116 {
117 va_list va_args;
118 va_start(va_args, format);
119 ca_log(CA_LOGLEVEL_NOTE, format, va_args);
120 va_end(va_args);
121 }
122}
123
128STATIC inline void ca_log_info(const char *format, ...)
129{
130 if (CASCODA_LOG_LEVEL >= CA_LOGLEVEL_INFO)
131 {
132 va_list va_args;
133 va_start(va_args, format);
134 ca_log(CA_LOGLEVEL_INFO, format, va_args);
135 va_end(va_args);
136 }
137}
138
143STATIC inline void ca_log_debg(const char *format, ...)
144{
145 if (CASCODA_LOG_LEVEL >= CA_LOGLEVEL_DEBG)
146 {
147 va_list va_args;
148 va_start(va_args, format);
149 ca_log(CA_LOGLEVEL_DEBG, format, va_args);
150 va_end(va_args);
151 }
152}
153
154#ifdef __cplusplus
155}
156#endif
157
162#endif /* CA821X_API_INCLUDE_CA821X_LOG_H_ */
ca_loglevel
Cascoda loglevel type.
Definition ca821x_log.h:59
STATIC void ca_log_crit(const char *format,...)
Print a log message with log level CRIT (Will always be displayed)
Definition ca821x_log.h:83
STATIC void ca_log_debg(const char *format,...)
Print a log message with log level DEBG (Will be displayed if log level is equal or higher,...
Definition ca821x_log.h:143
STATIC void ca_log_warn(const char *format,...)
Print a log message with log level WARN (Will be displayed if log level is equal or higher,...
Definition ca821x_log.h:98
STATIC void ca_log_info(const char *format,...)
Print a log message with log level INFO (Will be displayed if log level is equal or higher,...
Definition ca821x_log.h:128
STATIC void ca_log_note(const char *format,...)
Print a log message with log level NOTE (Will be displayed if log level is equal or higher,...
Definition ca821x_log.h:113
void ca_log(ca_loglevel loglevel, const char *format, va_list argp)
Function to process logs depending on platform.
Definition cascoda_log.c:42
@ CA_LOGLEVEL_INFO
Semi-Regular information that may be more frequent.
Definition ca821x_log.h:63
@ CA_LOGLEVEL_DEBG
High Frequency debug logs, data dumps, or unimportant information.
Definition ca821x_log.h:64
@ CA_LOGLEVEL_NOTE
Low-frequency notes that may be of interest.
Definition ca821x_log.h:62
@ CA_LOGLEVEL_WARN
Warnings that something has gone wrong.
Definition ca821x_log.h:61
@ CA_LOGLEVEL_CRIT
Critical warnings that should always be displayed.
Definition ca821x_log.h:60