Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 1 | /** |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 2 | * @file log.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief libnetconf2 logger |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 5 | * |
Michal Vasko | 4848ac8 | 2021-11-09 12:29:14 +0100 | [diff] [blame] | 6 | * @copyright |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 7 | * Copyright (c) 2015 - 2021 CESNET, z.s.p.o. |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 8 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 9 | * 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 Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 12 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 13 | * https://opensource.org/licenses/BSD-3-Clause |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef NC_LOG_PRIVATE_H_ |
| 17 | #define NC_LOG_PRIVATE_H_ |
| 18 | |
Radek Krejci | a352802 | 2015-09-02 13:46:38 +0200 | [diff] [blame] | 19 | #include <stdint.h> |
| 20 | |
| 21 | #include "log.h" |
| 22 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 23 | /* |
| 24 | * libnetconf's message printing |
| 25 | */ |
| 26 | |
| 27 | /** |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame] | 28 | * @brief Internal printing function |
| 29 | * |
| 30 | * @param[in] session Optional NETCONF session that generated the message |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 31 | * @param[in] level Verbose level |
| 32 | * @param[in] format Formatting string |
| 33 | */ |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame] | 34 | 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] | 35 | |
| 36 | /** |
| 37 | * @brief Verbose level variable |
| 38 | */ |
| 39 | extern volatile uint8_t verbose_level; |
| 40 | |
| 41 | /* |
| 42 | * Verbose printing macros |
| 43 | */ |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame] | 44 | #define ERR(session, format, args ...) prv_printf(session,NC_VERB_ERROR,format,##args) |
| 45 | #define WRN(session, format, args ...) if(verbose_level>=NC_VERB_WARNING){prv_printf(session,NC_VERB_WARNING,format,##args);} |
| 46 | #define VRB(session, format, args ...) if(verbose_level>=NC_VERB_VERBOSE){prv_printf(session,NC_VERB_VERBOSE,format,##args);} |
| 47 | #define DBG(session, format, args ...) if(verbose_level>=NC_VERB_DEBUG){prv_printf(session,NC_VERB_DEBUG,format,##args);} |
| 48 | #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] | 49 | |
Michal Vasko | 0553277 | 2021-06-03 12:12:38 +0200 | [diff] [blame] | 50 | #define ERRMEM ERR(NULL, "%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__) |
| 51 | #define ERRARG(arg) ERR(NULL, "%s: invalid argument (%s).", __func__, arg) |
| 52 | #define ERRINIT ERR(NULL, "%s: libnetconf2 not initialized.", __func__) |
| 53 | #define ERRINT ERR(NULL, "%s: internal error (%s:%d).", __func__, __FILE__, __LINE__) |
Radek Krejci | 52b3702 | 2015-10-06 16:11:48 +0200 | [diff] [blame] | 54 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 55 | #endif /* NC_LOG_PRIVATE_H_ */ |