blob: cc3c9a804a67313eff01c5c3679bdd9c7c95a05d [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
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/**
23 * @brief Verbosity levels.
24 */
25typedef enum NC_VERB_LEVEL {
Michal Vasko086311b2016-01-08 09:53:11 +010026 NC_VERB_ERROR = 0, /**< Print only error messages. */
27 NC_VERB_WARNING = 1, /**< Print error and warning messages. */
28 NC_VERB_VERBOSE = 2, /**< Besides errors and warnings, print some other verbose messages. */
29 NC_VERB_DEBUG = 3 /**< Print all messages including some development debug messages. */
Radek Krejci5fe60cc2015-09-01 17:14:39 +020030} NC_VERB_LEVEL;
31
32/**
33 * @brief Set libnetconf's verbosity level.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010034 *
35 * This level is set for libnetconf2 and alo libyang that is used internally. libyang
36 * verbose level can be set explicitly, but must be done so after calling this function.
37 *
Radek Krejci5fe60cc2015-09-01 17:14:39 +020038 * @param[in] level Enabled verbosity level (includes all the levels with higher priority).
39 */
40void nc_verbosity(NC_VERB_LEVEL level);
41
Michal Vaskob078fee2016-09-29 11:30:31 +020042#ifdef NC_ENABLED_SSH
43
44/**
45 * @brief Set libssh verbosity level.
46 *
47 * libssh verbosity is set separately because it defines more verbose levels than libnetconf2.
48 * Also, you need to set this for every thread unlike libnetconf verbosity.
49 *
50 * Values:
51 * - 0 - no logging,
52 * - 1 - rare conditions or warnings,
53 * - 2 - API-accessible entrypoints,
54 * - 3 - packet id and size,
55 * - 4 - functions entering and leaving.
56 *
57 * @param[in] level libssh verbosity level.
58 */
59void nc_libssh_thread_verbosity(int level);
60
61#endif
62
Michal Vasko206d3b12015-12-04 11:08:42 +010063/**
64 * @brief Set libnetconf's print callback.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010065 *
66 * This callback is set for libnetconf2 and also libyang that is used internally. libyang
67 * callback can be set explicitly, but must be done so after calling this function.
68 *
69 * @param[in] clb Callback that is called for every message.
Michal Vasko206d3b12015-12-04 11:08:42 +010070 */
71void nc_set_print_clb(void (*clb)(NC_VERB_LEVEL, const char *));
72
Radek Krejci5fe60cc2015-09-01 17:14:39 +020073#ifdef __cplusplus
74}
75#endif
76
77#endif /* NC_LOG_H_ */