Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file log.h |
| 3 | * \author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * \brief libnetconf2 logger |
| 5 | * |
| 6 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. 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 |
| 16 | * distribution. |
| 17 | * 3. Neither the name of the Company nor the names of its contributors |
| 18 | * may be used to endorse or promote products derived from this |
| 19 | * software without specific prior written permission. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #ifndef NC_LOG_H_ |
| 24 | #define NC_LOG_H_ |
| 25 | |
| 26 | #ifdef __cplusplus |
| 27 | extern "C" { |
| 28 | #endif |
| 29 | |
| 30 | /** |
| 31 | * @brief Verbosity levels. |
| 32 | */ |
| 33 | typedef enum NC_VERB_LEVEL { |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 34 | NC_VERB_ERROR = 0, /**< Print only error messages. */ |
| 35 | NC_VERB_WARNING = 1, /**< Print error and warning messages. */ |
| 36 | NC_VERB_VERBOSE = 2, /**< Besides errors and warnings, print some other verbose messages. */ |
| 37 | NC_VERB_DEBUG = 3 /**< Print all messages including some development debug messages. */ |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 38 | } NC_VERB_LEVEL; |
| 39 | |
| 40 | /** |
| 41 | * @brief Set libnetconf's verbosity level. |
Michal Vasko | a601f5c | 2015-12-08 14:33:03 +0100 | [diff] [blame] | 42 | * |
| 43 | * This level is set for libnetconf2 and alo libyang that is used internally. libyang |
| 44 | * verbose level can be set explicitly, but must be done so after calling this function. |
| 45 | * |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 46 | * @param[in] level Enabled verbosity level (includes all the levels with higher priority). |
| 47 | */ |
| 48 | void nc_verbosity(NC_VERB_LEVEL level); |
| 49 | |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 50 | /** |
| 51 | * @brief Set libnetconf's print callback. |
Michal Vasko | a601f5c | 2015-12-08 14:33:03 +0100 | [diff] [blame] | 52 | * |
| 53 | * This callback is set for libnetconf2 and also libyang that is used internally. libyang |
| 54 | * callback can be set explicitly, but must be done so after calling this function. |
| 55 | * |
| 56 | * @param[in] clb Callback that is called for every message. |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 57 | */ |
| 58 | void nc_set_print_clb(void (*clb)(NC_VERB_LEVEL, const char *)); |
| 59 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 60 | #ifdef NC_TRANSAPI_H_ |
| 61 | /* Allow the following functions only in transAPI modules (via #include <transapi.h> */ |
| 62 | |
| 63 | /** |
| 64 | * @brief Function for logging error messages. |
| 65 | * @param[in] format printf's format string |
| 66 | * @param[in] ... list of arguments specified in format |
| 67 | */ |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 68 | void nc_verb_error(const char *format, ...); |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * @brief Function for logging warning messages. |
| 72 | * @param[in] format printf's format string |
| 73 | * @param[in] ... list of arguments specified in format |
| 74 | */ |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 75 | void nc_verb_warning(const char *format, ...); |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * @brief Function for logging verbose messages. |
| 79 | * @param[in] format printf's format string |
| 80 | * @param[in] ... list of arguments specified in format |
| 81 | */ |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 82 | void nc_verb_verbose(const char *format, ...); |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 83 | |
| 84 | #endif |
| 85 | |
| 86 | #ifdef __cplusplus |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | #endif /* NC_LOG_H_ */ |