blob: d0f81827abc9b581889d155ec5c93674a0dc19cc [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 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of the Company nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 */
22
23#ifndef NC_LOG_H_
24#define NC_LOG_H_
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @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. */
37 NC_VERB_DEBUG = 3 /**< Print all messages including some development 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.
45 *
Radek Krejci5fe60cc2015-09-01 17:14:39 +020046 * @param[in] level Enabled verbosity level (includes all the levels with higher priority).
47 */
48void nc_verbosity(NC_VERB_LEVEL level);
49
Michal Vasko206d3b12015-12-04 11:08:42 +010050/**
51 * @brief Set libnetconf's print callback.
Michal Vaskoa601f5c2015-12-08 14:33:03 +010052 *
53 * This callback is set for libnetconf2 and also libyang that is used internally. libyang
54 * callback can be set explicitly, but must be done so after calling this function.
55 *
56 * @param[in] clb Callback that is called for every message.
Michal Vasko206d3b12015-12-04 11:08:42 +010057 */
58void nc_set_print_clb(void (*clb)(NC_VERB_LEVEL, const char *));
59
Radek Krejci5fe60cc2015-09-01 17:14:39 +020060#ifdef NC_TRANSAPI_H_
61/* Allow the following functions only in transAPI modules (via #include <transapi.h> */
62
63/**
64 * @brief Function for logging error messages.
65 * @param[in] format printf's format string
66 * @param[in] ... list of arguments specified in format
67 */
Michal Vasko206d3b12015-12-04 11:08:42 +010068void nc_verb_error(const char *format, ...);
Radek Krejci5fe60cc2015-09-01 17:14:39 +020069
70/**
71 * @brief Function for logging warning messages.
72 * @param[in] format printf's format string
73 * @param[in] ... list of arguments specified in format
74 */
Michal Vasko206d3b12015-12-04 11:08:42 +010075void nc_verb_warning(const char *format, ...);
Radek Krejci5fe60cc2015-09-01 17:14:39 +020076
77/**
78 * @brief Function for logging verbose messages.
79 * @param[in] format printf's format string
80 * @param[in] ... list of arguments specified in format
81 */
Michal Vasko206d3b12015-12-04 11:08:42 +010082void nc_verb_verbose(const char *format, ...);
Radek Krejci5fe60cc2015-09-01 17:14:39 +020083
84#endif
85
86#ifdef __cplusplus
87}
88#endif
89
90#endif /* NC_LOG_H_ */