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_PRIVATE_H_ |
| 16 | #define NC_LOG_PRIVATE_H_ |
| 17 | |
Radek Krejci | a352802 | 2015-09-02 13:46:38 +0200 | [diff] [blame] | 18 | #include <stdint.h> |
| 19 | |
| 20 | #include "log.h" |
| 21 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 22 | /* |
| 23 | * libnetconf's message printing |
| 24 | */ |
| 25 | |
| 26 | /** |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame^] | 27 | * @brief Internal printing function |
| 28 | * |
| 29 | * @param[in] session Optional NETCONF session that generated the message |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 30 | * @param[in] level Verbose level |
| 31 | * @param[in] format Formatting string |
| 32 | */ |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame^] | 33 | void prv_printf(const struct nc_session *session, NC_VERB_LEVEL level, const char *format, ...); |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * @brief Verbose level variable |
| 37 | */ |
| 38 | extern volatile uint8_t verbose_level; |
| 39 | |
| 40 | /* |
| 41 | * Verbose printing macros |
| 42 | */ |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame^] | 43 | #define ERR(session, format, args ...) prv_printf(session,NC_VERB_ERROR,format,##args) |
| 44 | #define WRN(session, format, args ...) if(verbose_level>=NC_VERB_WARNING){prv_printf(session,NC_VERB_WARNING,format,##args);} |
| 45 | #define VRB(session, format, args ...) if(verbose_level>=NC_VERB_VERBOSE){prv_printf(session,NC_VERB_VERBOSE,format,##args);} |
| 46 | #define DBG(session, format, args ...) if(verbose_level>=NC_VERB_DEBUG){prv_printf(session,NC_VERB_DEBUG,format,##args);} |
| 47 | #define DBL(session, format, args ...) if(verbose_level>=NC_VERB_DEBUG_LOWLVL){prv_printf(session,NC_VERB_DEBUG_LOWLVL,format,##args);} |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 48 | |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame^] | 49 | #define ERRMEM ERR(NULL, "%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__) |
| 50 | #define ERRARG(arg) ERR(NULL, "%s: invalid argument (%s).", __func__, arg) |
| 51 | #define ERRINIT ERR(NULL, "%s: libnetconf2 not initialized.", __func__) |
| 52 | #define ERRINT ERR(NULL, "%s: internal error (%s:%d).", __func__, __FILE__, __LINE__) |
Radek Krejci | 52b3702 | 2015-10-06 16:11:48 +0200 | [diff] [blame] | 53 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 54 | #endif /* NC_LOG_PRIVATE_H_ */ |