blob: 5cb6aa04760bd5310bef558ad41b8b5e34455c8f [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);}
45
Michal Vasko9e036d52016-01-08 10:49:26 +010046#define ERRMEM ERR("%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__)
Michal Vasko45e53ae2016-04-07 11:46:03 +020047#define ERRARG(arg) ERR("%s: invalid argument (%s).", __func__, arg)
48#define ERRINIT ERR("%s: libnetconf2 not initialized.", __func__)
Michal Vasko9e036d52016-01-08 10:49:26 +010049#define ERRINT ERR("%s: internal error (%s:%d).", __func__, __FILE__, __LINE__)
Radek Krejci52b37022015-10-06 16:11:48 +020050
Radek Krejci5fe60cc2015-09-01 17:14:39 +020051#endif /* NC_LOG_PRIVATE_H_ */