blob: 06eefef411ce47eb94e340a17fac5fc4fc103daa [file] [log] [blame]
Radek Krejci5fe60cc2015-09-01 17:14:39 +02001/**
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 Krejci9b81f5b2016-02-24 13:14:49 +01008 * 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 Vaskoafd416b2016-02-25 14:51:46 +010011 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010012 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejci5fe60cc2015-09-01 17:14:39 +020013 */
14
15#ifndef NC_LOG_H_
16#define NC_LOG_H_
17
Michal Vasko05532772021-06-03 12:12:38 +020018struct nc_session;
19
Radek Krejci5fe60cc2015-09-01 17:14:39 +020020#ifdef __cplusplus
21extern "C" {
22#endif
23
24/**
Radek Krejci6799a052017-05-19 14:23:23 +020025 * @addtogroup misc
26 * @{
27 */
28
29/**
Radek Krejci5fe60cc2015-09-01 17:14:39 +020030 * @brief Verbosity levels.
31 */
32typedef enum NC_VERB_LEVEL {
Michal Vasko086311b2016-01-08 09:53:11 +010033 NC_VERB_ERROR = 0, /**< Print only error messages. */
34 NC_VERB_WARNING = 1, /**< Print error and warning messages. */
35 NC_VERB_VERBOSE = 2, /**< Besides errors and warnings, print some other verbose messages. */
Michal Vasko2733aad2020-04-16 09:01:52 +020036 NC_VERB_DEBUG = 3, /**< Print almost all messages including some development debug messages. */
Michal Vaskob83a3fa2021-05-26 09:53:42 +020037 NC_VERB_DEBUG_LOWLVL = 4 /**< Print all messages including low level debug messages. */
Radek Krejci5fe60cc2015-09-01 17:14:39 +020038} NC_VERB_LEVEL;
39
40/**
41 * @brief Set libnetconf's verbosity level.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010042 *
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.
Michal Vasko37fdad52017-03-02 11:40:22 +010045 * However, if debug verbosity is used, selecting displayed libyang debug message groups
46 * must be done explicitly.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010047 *
Radek Krejci5fe60cc2015-09-01 17:14:39 +020048 * @param[in] level Enabled verbosity level (includes all the levels with higher priority).
49 */
50void nc_verbosity(NC_VERB_LEVEL level);
51
Michal Vaskob078fee2016-09-29 11:30:31 +020052#ifdef NC_ENABLED_SSH
53
54/**
55 * @brief Set libssh verbosity level.
56 *
57 * libssh verbosity is set separately because it defines more verbose levels than libnetconf2.
58 * Also, you need to set this for every thread unlike libnetconf verbosity.
59 *
60 * Values:
61 * - 0 - no logging,
62 * - 1 - rare conditions or warnings,
63 * - 2 - API-accessible entrypoints,
64 * - 3 - packet id and size,
65 * - 4 - functions entering and leaving.
66 *
67 * @param[in] level libssh verbosity level.
68 */
69void nc_libssh_thread_verbosity(int level);
70
71#endif
72
Michal Vasko206d3b12015-12-04 11:08:42 +010073/**
Michal Vasko05532772021-06-03 12:12:38 +020074 * @brief Deprecated, use ::nc_set_print_clb_session() instead.
75 *
76 * @param[in] clb Callback that is called for every message.
77 */
78void nc_set_print_clb(void (*clb)(NC_VERB_LEVEL, const char *));
79
80/**
81 * @brief Set libnetconf print callback.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010082 *
83 * This callback is set for libnetconf2 and also libyang that is used internally. libyang
84 * callback can be set explicitly, but must be done so after calling this function.
85 *
86 * @param[in] clb Callback that is called for every message.
Michal Vasko206d3b12015-12-04 11:08:42 +010087 */
Michal Vasko05532772021-06-03 12:12:38 +020088void nc_set_print_clb_session(void (*clb)(const struct nc_session *, NC_VERB_LEVEL, const char *));
Michal Vasko206d3b12015-12-04 11:08:42 +010089
Michal Vasko2733aad2020-04-16 09:01:52 +020090/** @} */
Radek Krejci6799a052017-05-19 14:23:23 +020091
Radek Krejci5fe60cc2015-09-01 17:14:39 +020092#ifdef __cplusplus
93}
94#endif
95
96#endif /* NC_LOG_H_ */