4 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <dev/isci/isci.h>
36 #include <dev/isci/scil/scif_user_callback.h>
37 #include <dev/isci/scil/scic_user_callback.h>
38 #include <dev/isci/scil/sci_logger.h>
40 #include <machine/stdarg.h>
44 #define WARNING_LEVEL 1
49 isci_log_message(uint32_t verbosity, char *log_message_prefix,
50 char *log_message, ...)
56 if (verbosity > g_isci_debug_level)
59 va_start (argp, log_message);
60 vsnprintf(buffer, sizeof(buffer)-1, log_message, argp);
64 printf("isci: %d:%06d %s %s", (int)tv.tv_sec, (int)tv.tv_usec,
65 log_message_prefix, buffer);
70 #define SCI_ENABLE_LOGGING_ERROR 1
71 #define SCI_ENABLE_LOGGING_WARNING 1
72 #define SCI_ENABLE_LOGGING_INFO 1
73 #define SCI_ENABLE_LOGGING_TRACE 1
74 #define SCI_ENABLE_LOGGING_STATES 1
76 #define ISCI_LOG_MESSAGE( \
87 if (!sci_logger_is_enabled(logger_object, log_object_mask, verbosity)) \
90 va_start (argp, log_message); \
91 vsnprintf(buffer, sizeof(buffer)-1, log_message, argp); \
94 /* prepend the "object:verbosity_level:" */ \
95 isci_log_message(verbosity, log_message_prefix, buffer); \
97 #endif /* SCI_LOGGING */
100 #ifdef SCI_ENABLE_LOGGING_ERROR
102 * @brief In this method the user is expected to log the supplied
103 * error information. The user must be capable of handling variable
104 * length argument lists and should consider prepending the fact
105 * that this is an error from the framework.
107 * @param[in] logger_object This parameter specifies the logger object
108 * associated with this message.
109 * @param[in] log_object_mask This parameter specifies the log objects
110 * for which this message is being generated.
111 * @param[in] log_message This parameter specifies the message to be logged.
115 void scif_cb_logger_log_error(SCI_LOGGER_HANDLE_T logger_object,
116 uint32_t log_object_mask, char *log_message, ...)
119 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
120 SCI_LOG_VERBOSITY_ERROR, "FRAMEWORK: ERROR: ");
124 #ifdef SCI_ENABLE_LOGGING_WARNING
126 * @brief In this method the user is expected to log the supplied warning
127 * information. The user must be capable of handling variable
128 * length argument lists and should consider prepending the fact
129 * that this is a warning from the framework.
131 * @param[in] logger_object This parameter specifies the logger object
132 * associated with this message.
133 * @param[in] log_object_mask This parameter specifies the log objects
134 * for which this message is being generated.
135 * @param[in] log_message This parameter specifies the message to be logged.
140 scif_cb_logger_log_warning(SCI_LOGGER_HANDLE_T logger_object,
141 uint32_t log_object_mask, char *log_message, ...)
144 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
145 SCI_LOG_VERBOSITY_WARNING, "FRAMEWORK: WARNING: ");
149 #ifdef SCI_ENABLE_LOGGING_INFO
151 * @brief In this method the user is expected to log the supplied debug
152 * information. The user must be capable of handling variable
153 * length argument lists and should consider prepending the fact
154 * that this is a debug message from the framework.
156 * @param[in] logger_object This parameter specifies the logger object
157 * associated with this message.
158 * @param[in] log_object_mask This parameter specifies the log objects
159 * for which this message is being generated.
160 * @param[in] log_message This parameter specifies the message to be logged.
165 scif_cb_logger_log_info(SCI_LOGGER_HANDLE_T logger_object,
166 uint32_t log_object_mask, char *log_message, ...)
169 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
170 SCI_LOG_VERBOSITY_INFO, "FRAMEWORK: INFO: ");
174 #ifdef SCI_ENABLE_LOGGING_TRACE
176 * @brief In this method the user is expected to log the supplied function
177 * trace information. The user must be capable of handling variable
178 * length argument lists and should consider prepending the fact
179 * that this is a function trace (i.e. entry/exit) message from the
182 * @param[in] logger_object This parameter specifies the logger object
183 * associated with this message.
184 * @param[in] log_object_mask This parameter specifies the log objects
185 * for which this message is being generated.
186 * @param[in] log_message This parameter specifies the message to be logged.
191 scif_cb_logger_log_trace(SCI_LOGGER_HANDLE_T logger_object,
192 uint32_t log_object_mask, char *log_message, ...)
195 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
196 SCI_LOG_VERBOSITY_TRACE, "FRAMEWORK: TRACE: ");
200 #ifdef SCI_ENABLE_LOGGING_STATES
202 * @brief In this method the user is expected to log the supplied function
203 * state transition information. The user must be capable of handling
204 * variable length argument lists and should consider prepending the
205 * fact that this is a function trace (i.e. entry/exit) message from
208 * @param[in] logger_object This parameter specifies the logger object
209 * associated with this message.
210 * @param[in] log_object_mask This parameter specifies the log objects
211 * for which this message is being generated.
212 * @param[in] log_message This parameter specifies the message to be logged.
217 scif_cb_logger_log_states(SCI_LOGGER_HANDLE_T logger_object,
218 uint32_t log_object_mask, char *log_message, ...)
221 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
222 SCI_LOG_VERBOSITY_STATES, "FRAMEWORK: STATE TRANSITION: ");
226 #ifdef SCI_ENABLE_LOGGING_ERROR
228 * @brief In this method the user is expected to log the supplied
229 * error information. The user must be capable of handling variable
230 * length argument lists and should consider prepending the fact
231 * that this is an error from the core.
233 * @param[in] logger_object This parameter specifies the logger object
234 * associated with this message.
235 * @param[in] log_object_mask This parameter specifies the log objects
236 * for which this message is being generated.
237 * @param[in] log_message This parameter specifies the message to be logged.
242 scic_cb_logger_log_error(SCI_LOGGER_HANDLE_T logger_object,
243 uint32_t log_object_mask, char *log_message, ...)
246 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
247 SCI_LOG_VERBOSITY_ERROR, "CORE: ERROR: ");
251 #ifdef SCI_ENABLE_LOGGING_WARNING
253 * @brief In this method the user is expected to log the supplied warning
254 * information. The user must be capable of handling variable
255 * length argument lists and should consider prepending the fact
256 * that this is a warning from the core.
258 * @param[in] logger_object This parameter specifies the logger object
259 * associated with this message.
260 * @param[in] log_object_mask This parameter specifies the log objects
261 * for which this message is being generated.
262 * @param[in] log_message This parameter specifies the message to be logged.
267 scic_cb_logger_log_warning(SCI_LOGGER_HANDLE_T logger_object,
268 uint32_t log_object_mask, char *log_message, ...)
271 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
272 SCI_LOG_VERBOSITY_WARNING, "CORE: WARNING: ");
276 #ifdef SCI_ENABLE_LOGGING_INFO
278 * @brief In this method the user is expected to log the supplied debug
279 * information. The user must be capable of handling variable
280 * length argument lists and should consider prepending the fact
281 * that this is a debug message from the core.
283 * @param[in] logger_object This parameter specifies the logger object
284 * associated with this message.
285 * @param[in] log_object_mask This parameter specifies the log objects
286 * for which this message is being generated.
287 * @param[in] log_message This parameter specifies the message to be logged.
292 scic_cb_logger_log_info(SCI_LOGGER_HANDLE_T logger_object,
293 uint32_t log_object_mask, char *log_message, ...)
296 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
297 SCI_LOG_VERBOSITY_INFO, "CORE: INFO: ");
301 #ifdef SCI_ENABLE_LOGGING_TRACE
303 * @brief In this method the user is expected to log the supplied function
304 * trace information. The user must be capable of handling variable
305 * length argument lists and should consider prepending the fact
306 * that this is a function trace (i.e. entry/exit) message from the
309 * @param[in] logger_object This parameter specifies the logger object
310 * associated with this message.
311 * @param[in] log_object_mask This parameter specifies the log objects
312 * for which this message is being generated.
313 * @param[in] log_message This parameter specifies the message to be logged.
318 scic_cb_logger_log_trace(SCI_LOGGER_HANDLE_T logger_object,
319 uint32_t log_object_mask, char *log_message, ...)
322 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
323 SCI_LOG_VERBOSITY_TRACE, "CORE: TRACE: ");
327 #ifdef SCI_ENABLE_LOGGING_STATES
329 * @brief In this method the user is expected to log the supplied function
330 * state transition information. The user must be capable of handling
331 * variable length argument lists and should consider prepending the
332 * fact that this is a function trace (i.e. entry/exit) message from
335 * @param[in] logger_object This parameter specifies the logger object
336 * associated with this message.
337 * @param[in] log_object_mask This parameter specifies the log objects
338 * for which this message is being generated.
339 * @param[in] log_message This parameter specifies the message to be logged.
344 scic_cb_logger_log_states(SCI_LOGGER_HANDLE_T logger_object,
345 uint32_t log_object_mask, char *log_message, ...)
348 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
349 SCI_LOG_VERBOSITY_STATES, "CORE: STATE TRANSITION: ");