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