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