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 | /** |
| 27 | * @brief internal printing function |
| 28 | * @param[in] level Verbose level |
| 29 | * @param[in] format Formatting string |
| 30 | */ |
| 31 | void prv_printf(NC_VERB_LEVEL level, const char *format, ...); |
| 32 | |
| 33 | /** |
| 34 | * @brief Verbose level variable |
| 35 | */ |
| 36 | extern volatile uint8_t verbose_level; |
| 37 | |
| 38 | /* |
| 39 | * Verbose printing macros |
| 40 | */ |
| 41 | #define ERR(format,args...) prv_printf(NC_VERB_ERROR,format,##args) |
| 42 | #define WRN(format,args...) if(verbose_level>=NC_VERB_WARNING){prv_printf(NC_VERB_WARNING,format,##args);} |
| 43 | #define VRB(format,args...) if(verbose_level>=NC_VERB_VERBOSE){prv_printf(NC_VERB_VERBOSE,format,##args);} |
| 44 | #define DBG(format,args...) if(verbose_level>=NC_VERB_DEBUG){prv_printf(NC_VERB_DEBUG,format,##args);} |
| 45 | |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 46 | #define ERRMEM ERR("%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__) |
Michal Vasko | 45e53ae | 2016-04-07 11:46:03 +0200 | [diff] [blame] | 47 | #define ERRARG(arg) ERR("%s: invalid argument (%s).", __func__, arg) |
| 48 | #define ERRINIT ERR("%s: libnetconf2 not initialized.", __func__) |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 49 | #define ERRINT ERR("%s: internal error (%s:%d).", __func__, __FILE__, __LINE__) |
Radek Krejci | 52b3702 | 2015-10-06 16:11:48 +0200 | [diff] [blame] | 50 | |
Radek Krejci | 5fe60cc | 2015-09-01 17:14:39 +0200 | [diff] [blame] | 51 | #endif /* NC_LOG_PRIVATE_H_ */ |