Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 1 | /** |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 2 | * @file log.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief libnetconf2 logger |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 5 | * |
Michal Vasko | 95ea9ff | 2021-11-09 12:29:14 +0100 | [diff] [blame] | 6 | * @copyright |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 7 | * Copyright (c) 2015 - 2021 CESNET, z.s.p.o. |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 8 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
Michal Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 12 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 13 | * https://opensource.org/licenses/BSD-3-Clause |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef NC_LOG_H_ |
| 17 | #define NC_LOG_H_ |
| 18 | |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame] | 19 | struct nc_session; |
| 20 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 26 | * @addtogroup misc |
| 27 | * @{ |
| 28 | */ |
| 29 | |
| 30 | /** |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 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. */ |
Michal Vasko | 2733aad | 2020-04-16 09:01:52 +0200 | [diff] [blame] | 37 | NC_VERB_DEBUG = 3, /**< Print almost all messages including some development debug messages. */ |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 38 | NC_VERB_DEBUG_LOWLVL = 4 /**< Print all messages including low level debug messages. */ |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 39 | } NC_VERB_LEVEL; |
| 40 | |
| 41 | /** |
| 42 | * @brief Set libnetconf's verbosity level. |
Michal Vasko | a601f5c | 2015-12-08 14:33:03 +0100 | [diff] [blame] | 43 | * |
| 44 | * This level is set for libnetconf2 and alo libyang that is used internally. libyang |
| 45 | * verbose level can be set explicitly, but must be done so after calling this function. |
Michal Vasko | 37fdad5 | 2017-03-02 11:40:22 +0100 | [diff] [blame] | 46 | * However, if debug verbosity is used, selecting displayed libyang debug message groups |
| 47 | * must be done explicitly. |
Michal Vasko | a601f5c | 2015-12-08 14:33:03 +0100 | [diff] [blame] | 48 | * |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 49 | * @param[in] level Enabled verbosity level (includes all the levels with higher priority). |
| 50 | */ |
| 51 | void nc_verbosity(NC_VERB_LEVEL level); |
| 52 | |
Michal Vasko | b078fee | 2016-09-29 11:30:31 +0200 | [diff] [blame] | 53 | #ifdef NC_ENABLED_SSH |
| 54 | |
| 55 | /** |
| 56 | * @brief Set libssh verbosity level. |
| 57 | * |
| 58 | * libssh verbosity is set separately because it defines more verbose levels than libnetconf2. |
| 59 | * Also, you need to set this for every thread unlike libnetconf verbosity. |
| 60 | * |
| 61 | * Values: |
| 62 | * - 0 - no logging, |
| 63 | * - 1 - rare conditions or warnings, |
| 64 | * - 2 - API-accessible entrypoints, |
| 65 | * - 3 - packet id and size, |
| 66 | * - 4 - functions entering and leaving. |
| 67 | * |
| 68 | * @param[in] level libssh verbosity level. |
| 69 | */ |
| 70 | void nc_libssh_thread_verbosity(int level); |
| 71 | |
| 72 | #endif |
| 73 | |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 74 | /** |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame] | 75 | * @brief Deprecated, use ::nc_set_print_clb_session() instead. |
| 76 | * |
| 77 | * @param[in] clb Callback that is called for every message. |
| 78 | */ |
| 79 | void nc_set_print_clb(void (*clb)(NC_VERB_LEVEL, const char *)); |
| 80 | |
| 81 | /** |
| 82 | * @brief Set libnetconf print callback. |
Michal Vasko | a601f5c | 2015-12-08 14:33:03 +0100 | [diff] [blame] | 83 | * |
| 84 | * This callback is set for libnetconf2 and also libyang that is used internally. libyang |
| 85 | * callback can be set explicitly, but must be done so after calling this function. |
| 86 | * |
| 87 | * @param[in] clb Callback that is called for every message. |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 88 | */ |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame] | 89 | void nc_set_print_clb_session(void (*clb)(const struct nc_session *, NC_VERB_LEVEL, const char *)); |
Michal Vasko | 206d3b1 | 2015-12-04 11:08:42 +0100 | [diff] [blame] | 90 | |
Michal Vasko | 2733aad | 2020-04-16 09:01:52 +0200 | [diff] [blame] | 91 | /** @} */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 92 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 93 | #ifdef __cplusplus |
| 94 | } |
| 95 | #endif |
| 96 | |
| 97 | #endif /* NC_LOG_H_ */ |