1 /**
2  * Copyright (C) Mellanox Technologies Ltd. 2001-2015.  ALL RIGHTS RESERVED.
3  *
4  * See file LICENSE for terms.
5  */
6 
7 #ifndef UCM_LOG_H_
8 #define UCM_LOG_H_
9 
10 #ifdef HAVE_CONFIG_H
11 #  include "config.h"
12 #endif
13 
14 #include <ucm/api/ucm.h>
15 #include <ucs/config/types.h>
16 
17 
18 #define ucm_log(_level, _message, ...) \
19     if (((_level) <= UCS_MAX_LOG_LEVEL) && \
20         ((_level) <= (int)ucm_global_opts.log_level)) { \
21         __ucm_log(__FILE__, __LINE__, __FUNCTION__, (_level), _message, \
22                   ## __VA_ARGS__); \
23     }
24 
25 #define ucm_fatal(_message, ...) ucm_log(UCS_LOG_LEVEL_FATAL, _message, ## __VA_ARGS__)
26 #define ucm_error(_message, ...) ucm_log(UCS_LOG_LEVEL_ERROR, _message, ## __VA_ARGS__)
27 #define ucm_warn(_message, ...)  ucm_log(UCS_LOG_LEVEL_WARN,  _message, ## __VA_ARGS__)
28 #define ucm_diag(_message, ...)  ucm_log(UCS_LOG_LEVEL_DIAG,  _message, ## __VA_ARGS__)
29 #define ucm_info(_message, ...)  ucm_log(UCS_LOG_LEVEL_INFO,  _message, ## __VA_ARGS__)
30 #define ucm_debug(_message, ...) ucm_log(UCS_LOG_LEVEL_DEBUG, _message, ## __VA_ARGS__)
31 #define ucm_trace(_message, ...) ucm_log(UCS_LOG_LEVEL_TRACE, _message, ## __VA_ARGS__)
32 
33 extern const char *ucm_log_level_names[];
34 
35 void __ucm_log(const char *file, unsigned line, const char *function,
36                ucs_log_level_t level, const char *message, ...)
37     UCS_F_PRINTF(5, 6);
38 
39 #endif
40