blob: 8564db13244ba0974d52f8019cd85f59720f3120 [file] [log] [blame]
Radek Krejci5fe60cc2015-09-01 17:14:39 +02001/**
Michal Vaskoc446a382021-06-18 08:54:05 +02002 * @file log.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief libnetconf2 logger
Radek Krejci5fe60cc2015-09-01 17:14:39 +02005 *
Michal Vasko95ea9ff2021-11-09 12:29:14 +01006 * @copyright
Michal Vaskoc446a382021-06-18 08:54:05 +02007 * Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
Radek Krejci5fe60cc2015-09-01 17:14:39 +02008 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01009 * 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 Vaskoafd416b2016-02-25 14:51:46 +010012 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010013 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejci5fe60cc2015-09-01 17:14:39 +020014 */
15
16#ifndef NC_LOG_H_
17#define NC_LOG_H_
18
Michal Vasko05532772021-06-03 12:12:38 +020019struct nc_session;
20
Radek Krejci5fe60cc2015-09-01 17:14:39 +020021#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
Radek Krejci6799a052017-05-19 14:23:23 +020026 * @addtogroup misc
27 * @{
28 */
29
30/**
Radek Krejci5fe60cc2015-09-01 17:14:39 +020031 * @brief Verbosity levels.
32 */
33typedef enum NC_VERB_LEVEL {
Michal Vasko086311b2016-01-08 09:53:11 +010034 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 Vasko2733aad2020-04-16 09:01:52 +020037 NC_VERB_DEBUG = 3, /**< Print almost all messages including some development debug messages. */
Michal Vaskob83a3fa2021-05-26 09:53:42 +020038 NC_VERB_DEBUG_LOWLVL = 4 /**< Print all messages including low level debug messages. */
Radek Krejci5fe60cc2015-09-01 17:14:39 +020039} NC_VERB_LEVEL;
40
41/**
42 * @brief Set libnetconf's verbosity level.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010043 *
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 Vasko37fdad52017-03-02 11:40:22 +010046 * However, if debug verbosity is used, selecting displayed libyang debug message groups
47 * must be done explicitly.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010048 *
Radek Krejci5fe60cc2015-09-01 17:14:39 +020049 * @param[in] level Enabled verbosity level (includes all the levels with higher priority).
50 */
51void nc_verbosity(NC_VERB_LEVEL level);
52
roman2eab4742023-06-06 10:00:26 +020053#ifdef NC_ENABLED_SSH_TLS
Michal Vaskob078fee2016-09-29 11:30:31 +020054
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 */
70void nc_libssh_thread_verbosity(int level);
71
roman2eab4742023-06-06 10:00:26 +020072#endif /* NC_ENABLED_SSH_TLS */
Michal Vaskob078fee2016-09-29 11:30:31 +020073
Michal Vasko206d3b12015-12-04 11:08:42 +010074/**
Michal Vasko05532772021-06-03 12:12:38 +020075 * @brief Set libnetconf print callback.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010076 *
77 * This callback is set for libnetconf2 and also libyang that is used internally. libyang
78 * callback can be set explicitly, but must be done so after calling this function.
79 *
80 * @param[in] clb Callback that is called for every message.
Michal Vasko206d3b12015-12-04 11:08:42 +010081 */
Michal Vasko05532772021-06-03 12:12:38 +020082void nc_set_print_clb_session(void (*clb)(const struct nc_session *, NC_VERB_LEVEL, const char *));
Michal Vasko206d3b12015-12-04 11:08:42 +010083
Michal Vasko2733aad2020-04-16 09:01:52 +020084/** @} */
Radek Krejci6799a052017-05-19 14:23:23 +020085
Radek Krejci5fe60cc2015-09-01 17:14:39 +020086#ifdef __cplusplus
87}
88#endif
89
90#endif /* NC_LOG_H_ */