blob: d14213148b5e1c2db2b3196b63515704d2090ab4 [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 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01008 * 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 Vaskoafd416b2016-02-25 14:51:46 +010011 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010012 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejci5fe60cc2015-09-01 17:14:39 +020013 */
14
15#ifndef NC_LOG_PRIVATE_H_
16#define NC_LOG_PRIVATE_H_
17
Radek Krejcia3528022015-09-02 13:46:38 +020018#include <stdint.h>
19
20#include "log.h"
21
Radek Krejci5fe60cc2015-09-01 17:14:39 +020022/*
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 */
31void prv_printf(NC_VERB_LEVEL level, const char *format, ...);
32
33/**
34 * @brief Verbose level variable
35 */
36extern 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);}
Michal Vasko2733aad2020-04-16 09:01:52 +020045#define DBL(format,args...) if(verbose_level>=NC_VERB_DEBUG_LOWLVL){prv_printf(NC_VERB_DEBUG_LOWLVL,format,##args);}
Radek Krejci5fe60cc2015-09-01 17:14:39 +020046
Michal Vasko9e036d52016-01-08 10:49:26 +010047#define ERRMEM ERR("%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__)
Michal Vasko45e53ae2016-04-07 11:46:03 +020048#define ERRARG(arg) ERR("%s: invalid argument (%s).", __func__, arg)
49#define ERRINIT ERR("%s: libnetconf2 not initialized.", __func__)
Michal Vasko9e036d52016-01-08 10:49:26 +010050#define ERRINT ERR("%s: internal error (%s:%d).", __func__, __FILE__, __LINE__)
Radek Krejci52b37022015-10-06 16:11:48 +020051
Radek Krejci5fe60cc2015-09-01 17:14:39 +020052#endif /* NC_LOG_PRIVATE_H_ */