Embedded Multicore Building Blocks V1.0.0
log.h
1 /*
2  * Copyright (c) 2014-2017, Siemens AG. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24  * POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef EMBB_BASE_C_LOG_H_
28 #define EMBB_BASE_C_LOG_H_
29 
30 #include <embb/base/c/internal/config.h>
31 #include <stdarg.h>
32 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
47 typedef enum {
54 
65 typedef void(*embb_log_function_t)(void * context, char const * message);
66 
75  void * context,
77  char const * message
78  );
79 
88  embb_log_level_t log_level
90  );
91 
104  void * context,
107  embb_log_function_t func
108  );
109 
118 void embb_log_write(
119  char const * channel,
123  embb_log_level_t log_level,
124  char const * message,
126  ...
129  );
130 
131 #if defined(EMBB_DEBUG) || defined(DOXYGEN)
132 
140 void embb_log_trace(
141  char const * channel,
142  char const * message,
144  ...
147  );
148 
157 void embb_log_info(
158  char const * channel,
159  char const * message,
161  ...
164  );
165 #else
166 #define embb_log_trace(...)
167 #define embb_log_info(...)
168 #endif
169 
177 void embb_log_warning(
178  char const * channel,
179  char const * message,
181  ...
184  );
185 
193 void embb_log_error(
194  char const * channel,
195  char const * message,
197  ...
200  );
201 
202 /* function for internal use only */
203 void embb_log_write_internal(
204  char const * channel,
205  embb_log_level_t log_level,
206  char const * message,
207  va_list argp);
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* EMBB_BASE_C_LOG_H_ */
void embb_log_set_log_function(void *context, embb_log_function_t func)
Sets the global logging function.
void embb_log_error(char const *channel, char const *message,...)
Logs a message to the given channel with EMBB_LOG_LEVEL_ERROR using embb_log_write().
show everything
Definition: log.h:52
show no log messages
Definition: log.h:48
void(* embb_log_function_t)(void *context, char const *message)
Logging function type.
Definition: log.h:65
void embb_log_write(char const *channel, embb_log_level_t log_level, char const *message,...)
Logs a message to the given channel with the specified log level.
void embb_log_warning(char const *channel, char const *message,...)
Logs a message to the given channel with EMBB_LOG_LEVEL_WARNING using embb_log_write().
show info, warnings, and errors
Definition: log.h:51
show warnings and errors
Definition: log.h:50
void embb_log_info(char const *channel, char const *message,...)
Logs a message to the given channel with EMBB_LOG_LEVEL_INFO using embb_log_write().
void embb_log_set_log_level(embb_log_level_t log_level)
Sets the global log level.
void embb_log_trace(char const *channel, char const *message,...)
Logs a message to the given channel with EMBB_LOG_LEVEL_TRACE using embb_log_write().
show errors only
Definition: log.h:49
void embb_log_write_file(void *context, char const *message)
Default logging function.
embb_log_level_t
Log levels available for filtering the log.
Definition: log.h:47